question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide an easy way to add additional module paths to PSModulePath via settings

See original GitHub issue

Some projects might benefit from an easy way to add paths to their PowerShell session’s PSModulePath so that modules in non-standard paths are available for IntelliSense and parse-time checks.

One specific use case is developing multiple DSC resources in the same folder structure. You will get parse-time errors about missing DSC resources if your the other resources you’re developing cannot be found in the PSModulePath.

It’s fairly easy to change your Microsoft.VSCode_profile.ps1 to add your workspace path to $env:PSModulePath but that setting will not transfer to other developers in the project. If this was a workspace-level setting, it could be enabled for anyone who opens the code in VS Code.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:7
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
daviwilcommented, Jun 15, 2017

Yep, exactly what I’m thinking, the setting would be a list of paths that defaults to just ${workspaceRoot}. And the nice thing is that I’m already adjusting the PSModulePath to add the “bundledModulesPath” so this would just be a generalization of what I’m doing already 😃

0reactions
SeeminglySciencecommented, Dec 20, 2019

I need too dig more in the code to give you a better answer on how to properly implement this feature.

Pretty sure we already add the bundled modules path to PSModulePath, so it could probably be added there.

It’s worth noting though, this could also cause some unintended code execution. If a workspace adds a PSModulePath with a module that exports a function for every letter (i.e. one function called a, one called b, etc) then typing anything in the editor pane will cause the psm1 to be invoked.

A lot less problematic than workspace profiles, but still something to consider.

Read more comments on GitHub >

github_iconTop Results From Across the Web

about PSModulePath - PowerShell | Microsoft Learn
Modifying PSModulePath in Windows​​ The following example adds the C:\Program Files\Fabrikam\Modules path to the value of the PSModulePath ...
Read more >
PowerShell Add a Persistent Module Path to $env ... - Tom Talks
Often you might want to add an additional persistent path to check for modules to auto load. This information is actually held in...
Read more >
Everything you wanted to know about PowerShell's Module ...
The PSModulePath environment variable stores the paths to the locations of the modules that are installed on disk. PowerShell uses this variable ...
Read more >
Set PSModulePath Environment Variable with PowerShell in ...
"C:\Users\Username\Documents\WindowsPowerShell\Modules" - This would only exist in the user's PATH variable. It appears you are modifying the ...
Read more >
How to Install PowerShell Modules: A Step by Step Guide
This helps ensure that the new module is installed in a path listed in the PSModulePath environment variable. You can determine where to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found