chocolatey-archive / chocolatey

[DEPRECATED - https://github.com/chocolatey/choco] Chocolatey NuGet - Like apt-get, but for windows.
https://chocolatey.org
Apache License 2.0
2.81k stars 344 forks source link

TeamCity & Chocolatey not working together #412

Closed garethrepton closed 10 years ago

garethrepton commented 10 years ago

I'm having a persistent issue with chocolatey and Team City.

Using a TeamCity commandline build step, running a very simple chocolatey package restore command:

C:\Chocolatey\bin\cinst .nuget\ChocolateyPackages.config And a simple package file that looks like:

<?xml version="1.0" encoding="utf-8"?> <packages> <package id="pstools" /> </packages>

I consistently get, the package restore failed and the message "Cannot bind argument to parameter 'Path' because it is an empty string".

If I run this locally as the same user on the machine, the package restore succeeds.

I think this is something to do with TeamCity and the Path variable conflicting with chocolatey as it does add a BuildParameter called "Path" and "SystemDrive" when I added the commandline task to run Chocolatey.

I have tried setting the Path variable to %env.Path%, but this doesn't help.

gep13 commented 10 years ago

What version of Chocolatey are you using? Is Chocolatey already installed on the machine when you run the build on the TeamCity Build Agent, or are you installing it as part of the build?

garethrepton commented 10 years ago

I'm using the Latest version available using the easy install method. I think its v0.9.8.23 although I can't find a version number anywhere.

I have already installed chocolatey on the buildagent, but I do run a chocolatey install script as the first item as well to ensure new agents get it if they need it.

gep13 commented 10 years ago

On the Build Agent, open PowerShell and type

choco

This will output the current version number.

So, to confirm, although you have chocolatey installed on the Build Agent, you are running the Chocolatey installation script again as part of the TeamCity build, is that correct?

If so, then I think this is the issue. There is a known issue in 0.9.8.23 where after installing, you have to close and re-open the PowerShell window before running a cinst, otherwise, you get the issue you are seeing. Can you try taking out the Chocolatey install script just now?

This issue is fixed, and will be included in the next release.

garethrepton commented 10 years ago

FIXED using gep13's information :)

I can confirm I'm using v0.9.8.23

Thank you gep13, you're absolutely right. For completeness in case anyone finds themselves here, I had to:

  1. Remove the pre-build chocolatey install from the build script (retain the package install in the script).
  2. Restart the agent (I assume the build agent keeps the same console session open, restarting the agent must reset it).
  3. Run the build again... No error.
gep13 commented 10 years ago

Glad to hear that you got it working! :+1:

garethrepton commented 10 years ago

Thanks for the help.

ferventcoder commented 10 years ago

That is fixed in vNext which we should have a beta coming out soon for