chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.26k stars 901 forks source link

pack - run in portable mode #1470

Open patriksvensson opened 6 years ago

patriksvensson commented 6 years ago

What You Are Seeing?

When using choco pack, attempts are made to access C:\ProgramData which results in warnings and errors. I do not have Chocolatey installed on the machine this error occured on, but installed the chocolatey package (version 0.10.8) from nuget as part of a Cake script.

This also affects CI builds.

What is Expected?

For choco.exe not to do attempt anything that requires Chocolatey to be installed when packing or elevated rights. If this behavior can't be changed, an opt-out flag to choco.exe would be appreciated (when running it in "portable" mode).

How Did You Get This To Happen? (Steps to Reproduce)

I ran the following command:

D:/Source/Git/spectre/jarvis/tools/chocolatey.0.10.8/chocolatey/tools/chocolateyInstall/choco.exe" pack -y --version "0.3.0-alpha0074" "D:/Source/Git/spectre/jarvis/installer/chocolatey/jarvis.temp.nuspec

Output Log

This is try 1/3. Retrying after 400 milliseconds.
 Error converted to warning:
 Access to the path 'C:\ProgramData\chocolatey\config\chocolatey.config.20700.update' is denied.
This is try 2/3. Retrying after 600 milliseconds.
 Error converted to warning:
 Access to the path 'C:\ProgramData\chocolatey\config\chocolatey.config.20700.update' is denied.
Maximum tries of 3 reached. Throwing error.
Chocolatey v0.10.8
Attempting to build package from 'jarvis.temp.nuspec'.
Successfully created package 'D:\Source\Git\spectre\jarvis\.artifacts\jarvis.0.3.0-alpha0074.nupkg'

I would be happy to help out with a PR for this issue if you think it's worth pursuing (and if I get some pointers).

ferventcoder commented 6 years ago

@patriksvensson I don't think this scenario is supported currently. To be able to run pack, one must have Chocolatey installed. I agree on some sort of flag that would change its behavior some and we've been thinking about how we might do that.

Something like --portable

patriksvensson commented 6 years ago

@ferventcoder I was thinking of (trying to) submitting a PR for this tonight. If you have any objections, speak now 😄

ferventcoder commented 6 years ago

@patriksvensson go for it, you already know our expectations for contributing ;)

ferventcoder commented 6 years ago

@patriksvensson it looks like @gep13 has some work on this.

ferventcoder commented 6 years ago

I hope it's okay that we let @gep13 continue and see where it ends. Then we'll see what is left from there.

patriksvensson commented 6 years ago

@ferventcoder Sounds good to me. I forked and started on it, but didn't get anywhere at that time.

gep13 commented 6 years ago

Related to https://github.com/chocolatey/choco/issues/1496

jzabroski commented 5 years ago

If pack was an independent operation in an independent library, then it could be added to dotnettools in the same way as dotnet push allows people to easily publish chocolatey packages using the same csproj metadata as dotnet push uses for nuget packages.