Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

[Enhancement] Install-PowershellModulePath to modify PSModulePath #292

Open
fschwiet opened this issue May 24, 2013 · 7 comments
Open

[Enhancement] Install-PowershellModulePath to modify PSModulePath #292

fschwiet opened this issue May 24, 2013 · 7 comments

Comments

@fschwiet
Copy link

It would be nice if I could use something like Install-ChocolateyPath to modify $env:PSModulePath

@gep13
Copy link
Member

gep13 commented May 27, 2013

Rob, what are your thoughts on this? Does it make sense to add this functionality into another helper method, such as InstallChocolateyPowerShellPath? There is an existing helper method for a generic environment variable: https://github.com/chocolatey/chocolatey/wiki/HelpersInstallChocolateyEnvironmentVariable but if it makes sense to split out the PowerShell Module Path, happy to take a stab at implementing this.

@JimFicarra
Copy link

I see this is an old request but I would second this one - it looks like the Install-ChocolateyEnvironmentVariable handles addition of a single variable/value key pair, not something like a path variable where you want to modify a delimited set of strings like a PATH or PSModulePath.

I created a chocolatey package that deployed some powershell modules and I had to write my own code to add the path to the PSModulePath. I also had to write my own removal as I also wrote a ChocolateyUninstall.ps1 with it. (Having something existing would have been preferable)

One nuance I ran across while retrieving the PATH variable with [System]::GetEnvironmentVariable (specifying the machine scope) is that it still returned the user + machine scope, so I had to also handle if the user-scoped path was there or not. (I found this out the hard way and ended up breaking the Chocolatey prefetch in the puppet module because I did not properly remove the path from $PSModulePath).

Whether this is implemented or not, kudos to Rob and all involved in Chocolatey - it's fantastic!

@ferventcoder
Copy link
Contributor

Install-PowershellModulePath (or something like that).

  • This copies something to a path specified.
  • If the path is not already created in the environment variable, it will add it.
  • Be able to specify user/machine (unless this is only one or the other).

So looks like three parameters to be passed.

@ferventcoder
Copy link
Contributor

@Jaykul may also be interested in this discussion and being more of an SME on this, he probably has suggestions on how to implement.

@ferventcoder ferventcoder changed the title nice to have: use Install-ChocolateyPath to modify PSModulePath [Enhancement] Install-PowershellModulePath to modify PSModulePath Jun 28, 2014
@JimFicarra
Copy link

Sounds interesting - so when I implemented the PS Modules they came from the author as organized in a directory structure. I zipped those up and created a chocolatey zip package and deployed that, and augmented with powershell to update the PSModulePath env variable. Point is, that some modules may be a single psm1, maybe psd1, or even a larger structure of files.worthy of being compressed in a zip.

If it's going to be wrapped in an inclusive function to copy modules and update the PSModulePath, perhaps the "copies something" part could support multiple "somethings" or split it out if you see fit.

I also think support for user or machine scope for the path is helpful. (In my case I deployed at the machine scope.)

@ctaggart
Copy link

This is exactly what I was looking for tonight. both Install and Uninstall

@ferventcoder
Copy link
Contributor

I know @Jaykul had something he was working on for this kind of thing.

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

Successfully merging a pull request may close this issue.

5 participants