Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installation/setup: run choco once to initialize the config file #1401

Closed
KirillOsenkov opened this issue Sep 15, 2017 · 4 comments
Closed

Comments

@KirillOsenkov
Copy link

What You Are Seeing?

First time after installing Chocolatey as admin, I start a non-admin command prompt, run choco pack and see this error:
image

What is Expected?

It should work fine (whatever Chocolatey wants to write to ProgramData needs to be written at install time). Alternatively, consider saving the config file to LocalAppData (this doesn't need admin permissions to write, and is generally a better thing to do. Program Data goes to one place, configs, logs etc. go to another).

Output Log

Unfortunately I didn't grab the output log other than the screenshot above. I tried a workaround (which is to run pack under admin, and that created the config file and I got unblocked).

@KirillOsenkov
Copy link
Author

And here's the output:

This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 Access to the path 'C:\ProgramData\chocolatey\config' is denied.
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 Access to the path 'C:\ProgramData\chocolatey\config' is denied.
Maximum tries of 3 reached. Throwing error.
Cannot create directory "C:\ProgramData\chocolatey\config". Error was:
System.UnauthorizedAccessException: Access to the path 'C:\ProgramData\chocolatey\config' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.<>c__DisplayClass64.<create_directory>b__63()
   at chocolatey.infrastructure.tolerance.FaultTolerance.<>c__DisplayClass1.<retry>b__0()
   at chocolatey.infrastructure.tolerance.FaultTolerance.retry[T](Int32 numberOfTries, Func`1 function, Int32 waitDurationMilliseconds, Int32 increaseRetryByMilliseconds, Boolean isSilent)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.create_directory(String directoryPath)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.create_directory_if_not_exists(String directoryPath, Boolean ignoreError)
Chocolatey had an error occur:
System.UnauthorizedAccessException: Access to the path 'C:\ProgramData\chocolatey\config' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.<>c__DisplayClass64.<create_directory>b__63()
   at chocolatey.infrastructure.tolerance.FaultTolerance.<>c__DisplayClass1.<retry>b__0()
   at chocolatey.infrastructure.tolerance.FaultTolerance.retry[T](Int32 numberOfTries, Func`1 function, Int32 waitDurationMilliseconds, Int32 increaseRetryByMilliseconds, Boolean isSilent)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.create_directory(String directoryPath)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.create_directory_if_not_exists(String directoryPath, Boolean ignoreError)
   at chocolatey.infrastructure.extractors.AssemblyFileExtractor.extract_text_file_from_assembly(IFileSystem fileSystem, IAssembly assembly, String manifestLocation, String filePath, Boolean overwriteExisting)
   at chocolatey.infrastructure.app.builders.ConfigurationBuilder.get_config_file_settings(IFileSystem fileSystem, IXmlService xmlService)
   at chocolatey.infrastructure.app.builders.ConfigurationBuilder.set_up_configuration(IList`1 args, ChocolateyConfiguration config, Container container, ChocolateyLicense license, Action`1 notifyWarnLoggingAction)
   at chocolatey.console.Program.Main(String[] args)

@ferventcoder
Copy link
Member

@KirillOsenkov thanks for adding this. Adding to backlog.

@ferventcoder ferventcoder changed the title Consider initializing the config file when Chocolatey gets installed installation/setup: run choco once to initialize the config file Nov 3, 2017
@ferventcoder ferventcoder added this to the 0.10.9 milestone Nov 3, 2017
@ferventcoder ferventcoder self-assigned this Nov 29, 2017
gep13 added a commit to gep13/choco that referenced this issue Feb 22, 2018
- This ensures that all necessary setup is completed
- Ready for further execution
gep13 added a commit to gep13/choco that referenced this issue Feb 22, 2018
- This ensures that all necessary setup is completed
- Ready for further execution
gep13 added a commit to gep13/choco that referenced this issue Feb 22, 2018
- This ensures that all necessary setup is completed
- Ready for further execution
ferventcoder added a commit that referenced this issue Feb 22, 2018
(GH-1401) Added initial call to Chocolatey after installation
@ferventcoder
Copy link
Member

Merged into stable at 3cb969b - will be released in v0.10.9.

ferventcoder added a commit to ferventcoder/choco that referenced this issue Feb 23, 2018
* stable:
  (chocolateyGH-1401) Added initial call to Chocolatey after installation
ferventcoder added a commit that referenced this issue Apr 9, 2018
With Chocolatey v0.10.9 and #1401, we added a call to choco to
initialize the config file during installation so that it was generated
during and administrative run. That was done in commit 35add3b.

A call to choco with no switches results in an exit code of 1 instead
of 0. Recently a call to choco to create the config file on install was
added as the last step in installing Chocolatey. Unfortunately this
resulted in an install or upgrade of Chocolatey resulting in a 1
instead of a 0. Call choco -v instead ot show the version, which exits
with a 0 and also ensures the first time generation of the
chocolatey.config file.
@daihieptn97
Copy link

run PowerShell with admin rights

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants