Choco: $profile is empty string when installing packages - does not automatically install the ChocolateyProfile.

Created on 23 Mar 2016  Â·  16Comments  Â·  Source: chocolatey/choco

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

$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
  Import-Module "$ChocolateyProfile"
}

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.

3 - Done Bug PowerShell Internal Host

Most helpful comment

I asked this Stack Overflow question for help on this one: http://stackoverflow.com/q/36239010/18475

All 16 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]]
Sent: Thursday, 24 March 2016 11:30 AM
To: chocolatey/choco [email protected]
Cc: David Gardiner [email protected]
Subject: Re: [choco] Provide manual steps to updating PowerShell profile if installer can't do it automatically (#667)

I'm wondering if the profile is missing due to the way Chocolatey calls PowerShell.exe (e.g. -noprofile).

—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHubhttps://github.com/chocolatey/choco/issues/667#issuecomment-200602215

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 Write-Output "profile = '$profile'"

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 powershell -noprofile from a new cmd I still see the normal $PROFILE path. :confused:

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

$profile is really the only thing missing.

I resolved this by setting $profile for now.

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

Added some comments to the SO question

Was this page helpful?
0 / 5 - 0 ratings