-
Notifications
You must be signed in to change notification settings - Fork 903
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
adds helpers/functions/Install-PSModulePath.ps1 #327
Conversation
…PSModulePath.ps1
@@ -0,0 +1,56 @@ | |||
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be a little different since it originates here. The & original...
should be removed.
On the actual commit message itself, please create an issue here in chocolatey/choco, link it back to that issue and then format your commit message according to CONTRIBUTING.md. Once you've done that please force push your branch to update the PR. Thanks! |
From chocolatey-archive/chocolatey#292 (comment) :
@JimFicarra how did you end up handling the split of user from machine scope? |
Hey Rob, Are you having this issue? I remember writing this and having the issue, but I don't remember the conditions that triggered it. I looked back at the code I wrote and I don't see me handling it other than using the Machine scope (EnvironmentVariableTarget Enumeration) so perhaps I was not using the proper parameter for targeting the machine scope at the time I wrote it.. :) In any case, below are snippets of code I wrote back then in the ChocolateyInstall.ps1 to handle the addition of the variable to machine scope. Hope they are helpful.
And here's a function I wrote in the chocolateyuninstall.ps1 that removes the desired path from the PSModulePath env variable. It handles the cases where the path is either at the beginning, end, or middle of the entire semicolon-delimited path string. In my implementation, this function is called in my uninstall ONLY IF the module path I'm removing from the PSModulePath env variable doesn't contain any other modules after removing the specific modules within this uninstall. (I have other company-specific modules that I write and put in this path, hence the check before removing from the PSModulePath - I don't want to break usage for other modules I put in my common path)
Below is the function called.
|
@JimFicarra It looks like you've done much more work here. Would you like to replace this PR with a better one? |
@ctaggart - I'd be happy to contribute! Let me clean up the code a bit and I'll submit a PR. |
Any update on this? I've been trying to set PSMODULEPATH in two modules where one is dependent on the other. If they both get installed in the same choco session, the second one (dependent on the other) fails since Update-SessionEnvironment, and setting $env and [Environment]::SetEnvironmentVariable don't work across the installs. No, I can't combine the modules - on some machines users will install one, on some both. |
@eavonius last I knew I believe @JimFicarra was going to fix up his code and submit a superseding PR for this feature. |
Thanks rob. @JimFicarra any update? That was 5 months ago ;). Hopefully this is still working code, I could sure use it! :) |
This has been fixed in 0.9.10. |
@JimFicarra any updates on submitting those fixes? |
Cross-referencing chocolatey-archive/chocolatey#475.
Glad to hear! |
Revisiting this - how has this been fixed in 0.9.10? I just tried on Windows 10 using 0.9.9.12 (current version) installing my two powershell modules that have chocolatey packages again. It appears that when the dependent package installs, the next package does now see the change to PSMODULEPATH which is good, however the calling process doesn't see the new modules. Here's the chocolateyInstall from PowerDelivery3Node (PowerDelivery3 package depends on it). When I install PowerDelivery3 locally off the built nuget package, it does find the dependency to PowerDelivery3Node, installs it first, and there are no errors - but at the end of both packages being installed the current PowerShell session doesn't have the new cmdlets available. Should I just show a message that the person has to reload their shell to use it? I'm using this as part of infrastructure automation and if I call chocolatey on a remote node to install PowerDeliveryNode, I want the calling script to be able to access its cmdlets immediately after installation. |
0.9.10.0 versus 0.9.9.12. 0.9.10 is still in beta. I'm not sure if you made that determination or not. |
@eavonius in 0.9.10 a user can refresh their shell with |
Note a couple of really important things there - Chocolatey tells the user that they need to refresh their environment when it detects changes to the environment values. |
You can call |
Sorry Rob I didn't notice I was reading the version wrong. Is there a way I'll do some testing, really want to get these packages up there! Thanks for your support, Jayme On Mon, May 30, 2016 at 11:08 AM, Rob Reynolds notifications@github.com
|
choco upgrade chocolatey --pre On Tuesday, May 31, 2016, Jayme Edwards notifications@github.com wrote:
Rob http://codebetter.com/robreynolds |
Darn it. OK thanks Rob, I tried it with the pre package and the packages On Tue, May 31, 2016 at 7:06 PM, Rob Reynolds notifications@github.com
|
Sorry for the lack of clarity. The chocolatey packages for my two Hopefully that helps. On Wed, Jun 1, 2016 at 4:40 PM, Rob Reynolds notifications@github.com
|
That makes sense. I just gave a cursory look at #295. On Wed, Jun 1, 2016 at 4:45 PM, Rob Reynolds notifications@github.com
|
I think with some other discussion in various places it was suggested this could really just be a specific call to Install-ChocolateyEnvironmentVariable with maybe some logic checks for existing within the environment already, or and is very similar to Install-ChocolateyPath. I'm not sure if just making it an alias or a special case inside the Install-ChocolateyEnvironmentVariable would make sense, detecting when --case-insensitive "PATH"/"PSModulePath" is the target and doing some extra checks like ensuring the ExpandSZ or whatever properties are intact. |
@ctaggart reviving an old thread. I would love to get something in regarding PS ModulePath. Still interested in moving forward with this? |
@ferventcoder I think it is still a good idea, but I will be unable to contribute. |
Seems like this commit was abandoned. I'm waiting for changes to this commit to go through or be abandoned before sending my own PR. |
Cameron Taggart seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Dear contributor, As this PR seems to have been inactive for 30 days after changes / additional information |
This fixes chocolatey-archive/chocolatey#292. I simply copied
Install-ChocolateyPath.ps1
and made minimal changes. I'm using it like this fromchocolateyInstall.ps1
:I would think
Machine
would be a better default, but I left it asUser
. It would be great to have anUninstall-PSModulePath.ps1
too.