-
Notifications
You must be signed in to change notification settings - Fork 910
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
$profile is empty string when installing packages - does not automatically install the ChocolateyProfile. #667
Comments
Thanks! |
I'm wondering if the profile is missing due to the way Chocolatey calls PowerShell.exe (e.g. -noprofile). |
I saw it once during testing and didn't really think about it as it was working in other places. Those other places were running the installer like it would from the web. |
Maybe.. because I definitely have an existing profile. From: Rob Reynolds [mailto:[email protected]] I'm wondering if the profile is missing due to the way Chocolatey calls PowerShell.exe (e.g. -noprofile). — |
So on a first install, it would work if you were using the install script from dot org, but as an upgrade it would not because Chocolatey runs PowerShell without a profile. In that case it would need a backup way of getting to the profile. This may also be why Posh-Git installer never works the first time. cc @dahlbyk |
easy to reproduce. Write a package with |
Confirmed choco install .\testprofile.1.0.nupkg
Chocolatey v0.9.10-beta1-201-g652a747 Professional
Installing the following packages:
.\testprofile.1.0.nupkg
By installing you accept licenses for the packages.
testprofile v1.0
The package testprofile wants to run 'chocolateyinstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider setting
'allowGlobalConfirmation'. Run 'choco feature -h' for more details.
Do you want to run the script?
1) yes
2) no
3) print
yes
profile = ''
The install of testprofile was successful.
Chocolatey installed 1/1 package(s). 0 package(s) failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). |
Interesting... When I spawn a new |
In the new betas it runs a custom PowerShell host. I'm thinking that if noprofile isn't causing the issue, this is. It also would explain why I saw it work in some cases and fail in just one case. |
So I created a package that logs all of the automatic variables to detect anomalies: https://gist.github.com/ferventcoder/132560fc67fe92d1fb2a
|
I resolved this by setting |
When running a custom host, it appears all automatic variables are set but `$profile`. It is empty for all the different profiles. When the profile value is empty and the documents folder exists for the user, set `$profile` to a string value that represents what it would have been set to in a normal PowerShell scenario. We can get away with a single value for `$profile` as most scripts do not look at each of the profiles, only what is returned by the `$profile` string, which is `CurrentUserCurrentHost`. We check for the existence of the documents folder because it tells us that this is not the LocalSystem user, and we don't want to set `$profile` when the SYSTEM user is running choco.
I asked this Stack Overflow question for help on this one: http://stackoverflow.com/q/36239010/18475 |
Then I promptly answered it a few hours later. We'll wait for someone to tell me that it is wrong to do it the way I'm doing it. |
This will be fixed in the next beta, but it will only work when upgrading from that next version. If you upgrade from a non-beta this will work fine. |
I still need to provide instructions when it doesn't work |
When adding the profile fails, provide advice on how to add it manually.
Added some comments to the SO question |
* stable: (GH-460) Amended Template (GH-623) Extract Nuspec on Install (GH-674)(GH-672) Color Overrides / Fix Write-Host (GH-181) log selection to log file only (GH-181)(GH-184) Short prompt/Prompt character (GH-675) Template include LICENSE/VERIFICATION (GH-258) Rename zip to detector.zip (GH-572) Fix: The handle is invalid - Output Redirection (maint) comments (GH-667) Provide How To Add Profile Manually (GH-667) PowerShell Custom Host - Set $Profile (GH-666) pass Write-ChocolateyError message param (GH-673) Ensure Get-BinRoot Warning is Shown (GH-666) setup logs colored write-host w/fallback
What You Are Seeing?
WARNING: Unable to add Chocolatey to the profile. You will need to do it manually. Error was 'Cannot bind argument to parameter 'Path' because it is an empty string.'
What is Expected?
Output advice to user about what to add to their profile.. eg
How Did You Get This To Happen? (Steps to Reproduce)
Upgraded to latest Chocolatey
Output Log
2016-03-24 09:08:16,294 [INFO ] - VERBOSE: Importing alias 'Remove-BinFile'.
2016-03-24 09:08:16,309 [INFO ] - WARNING: Unable to add Chocolatey to the profile. You will need to do it manually. Error was 'Cannot bind argument to parameter 'Path' because it is an empty string.'
2016-03-24 09:08:16,309 [DEBUG] - Install-DotNet4IfMissing
2016-03-24 09:08:16,325 [INFO ] - Chocolatey (choco.exe) is now ready.
The text was updated successfully, but these errors were encountered: