Search code examples
chocolatey

Chocolatey doesn't work from a Vagrant Shell Script


I'm trying to provision a brand new Windows 2012 Server Core machine using a combination of vagrant and chocolatey. So I have a powershell provisioning script that runs under the Vagrant (as administrator) account on the base box.

To install chocolatey I run the following as the first line of the powershell provisioning script:

iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))

I also add chocolateys bin directory to the path so powershell has access to it without restarting the shell by calling:

$env:Path += ";C:\ProgramData\Chocolatey\bin"

It installs chocolatey just fine, and in its next steps uses "choco install" to install the rest of the required software.

All choco installs fails with:

Unable to read package from path

Now this seems to be a NUGET bug (scriptcs - Unable to read package and https://github.com/chocolatey/chocolatey/issues/325), with the work around being to clear the NUGET cache.

But this is a brand new box, and until I install chocolatey packages, has an empty NUGET cache - so there are no package conflicts going on here. I've tried adding code in to clear out the cache folder first but that has no impact, cause its blank to start with (brand new box).

If I log onto the machine and manually run the provisioning script inside from powershell I get the same result - no packages install at all and all packages fail with the same error message.

Does anyone have a clue as to what could be going on here? Any help appreciated.


Solution

  • Eventually tracked this down to our Firewall doing application level inspection and sending HTTP 307 responses. Spoke nicely to the firewall gods and this problem went away. For those who hit similar, hosting a chocolatey mirror won't work either. Your original package will come down fine but if it needs to download an executable or other external package then that package will fail.