-
Notifications
You must be signed in to change notification settings - Fork 511
Provide an easy way to add additional module paths to PSModulePath via settings #880
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
Comments
I like this idea. I imagine this would be an array and it could default to perhaps We probably need to set expectations. If your "module under development" has issues with either the PSD1 (invalid) or script files don't parse you're not likely to get the Intellisense you might be expecting. Maybe there's a way to surface such issues in a helpful (other than missing Intellisense)? |
Yep, exactly what I'm thinking, the setting would be a list of paths that defaults to just |
This might be a problem that can be solved using workspace profiles (#190). |
The workspace profiles feature seems like it will be much harder to land than adding profiles, as it would automatically invoke external code on a user's system. Can someone from the extension team provide a brief summary of how they would implement adding additional module paths to PSModulePath via settings, and perhaps someone from the community (such as myself) might be able to implement it? Seems like it should be as easy as setting The vscode-powershell extensions cannot currently autocomplete user-defined functions/types that aren't in the same file. This is a big feature gap compared to any other major scripting language's extension, so hopefully, this is a high-priority issue and we can fix this ASAP. |
Autocomplete in PowerShell is based on what's available in a session. We use the same logic that hitting tab in the console uses. Without running any files, how would I know that you want to use the functions/types defined in another file? This is the nature of PowerShell and I'm not sure how this could ever be fixed... Unless intellisense came from looking at the AST... But then dynamic parameters, functions/types/variables added in the Integrated Console, and more wouldn't show up in intellisense. Pros and cons... You probably want to look at this issue though: #144 |
I really really really really wish that this issue was an easy one to fix, but It's non-trivial because every single time a runspace is opened, the |
Pretty sure we already add the bundled modules path to It's worth noting though, this could also cause some unintended code execution. If a workspace adds a A lot less problematic than workspace profiles, but still something to consider. |
I am shocked that after so long, there is still no traction on this. This feature is common to every other IDE and language, and is essential for any non-trivial project. If the developers are not willing to implement this feature, is there an easy workaround? Right now I'm setting the PSModulePath environment variable in a shell, then running code from that shell so it picks up the variable. While it works, it's very annoying. |
@ilsaloving I think the main reason this hasn't had much interest for implementation is because you can do this in your PowerShell profile, and have it apply everywhere, not just VSCode. |
But that is a different solution that solves a completely different problem. If one is working on a powershell project that is complex enough to split into multiple modules, that are specific to the app and so don't belong in the general library path, you need this functionality. That's what I'm doing right now, and it's shocking that the powershell plugin doesn't provide such basic functionality. |
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.The text was updated successfully, but these errors were encountered: