Skip to content
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

$env:PSModulePath Question / Potential Issue #1266

Open
GHRoss opened this issue Apr 11, 2018 · 7 comments
Open

$env:PSModulePath Question / Potential Issue #1266

GHRoss opened this issue Apr 11, 2018 · 7 comments
Labels

Comments

@GHRoss
Copy link

GHRoss commented Apr 11, 2018

I'm having an issue with Intellisense being very slow.

I've managed to whittle it down to VS Code loading modules over the network, so every time I hit tab, it goes off to the network share and does what it needs to do and then Intellisense works.

This can be up to 2 minutes at a time, however.

I removed the entry from $env:PSModulePath in the integrated VS Code terminal, fine, Intellisense is once again rapid and I can continue happily with my work, then around 30 seconds or so later, everything slows down again.

Lo and behold, the UNC of the file share is back in $env:PSModulePath! I've tested this in the ISE and do not get the same issue after removing the UNC share path.

Happy to submit logs if required, hoping there's just something I'm missing, however.

EDIT: It seems to be that when I hit tab or Intellisense trys to fire, it adds the UNC share path back to my $env:PSModulePath. Again tried with the ISE and don't get the same thing, so I believe this to be a bug.

SECOND EDIT: It appears to add the path back into $env:PSModulePath as soon as you click into the editor window.

@TylerLeonhardt
Copy link
Member

fascinating... sounds like a bug... Thanks for the report! Where does it get the file share path from? Are you adding that to the PSModulePath in your profile or something?

It'd be helpful if you could share the logs.

@GHRoss
Copy link
Author

GHRoss commented Apr 12, 2018

@tylerl0706 I'm not sure where it gets the file share path from.

I took everything out of my profile to eliminate that as an issue.

I don't like to assume, but I think as we have our documents redirected, it's using that location instead of the normal C:\Users\User.Name\WindowsPowerShell\Modules location.

I've moved all of the modules in there to C:\Program Files\WindowsPowerShell\Modules, and the speed is back to normal.

@TylerLeonhardt
Copy link
Member

Glad to see you're at least unblocked. Seems like a bug. We'll take a look.

@Cirzen
Copy link

Cirzen commented Jan 2, 2019

This is becoming a pain for me too. I have a number of module paths being inserted via my profile, and they seem to be overwritten whenever the script analyzer starts up. It's a piece of cake to replicate - is there anything I can provide to help with this?

@rjmholt rjmholt self-assigned this Jan 9, 2019
@rjmholt rjmholt removed their assignment Mar 5, 2019
@ajklotz
Copy link

ajklotz commented Dec 31, 2019

Any updates?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 31, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Jan 2, 2020

This is caused by an underlying issue within PowerShell: PowerShell/PowerShell#9921. I had hoped it would be fixed in PS 7, but unfortunately PS 7 still mutates the module path when new runspaces are opened.

Some approaches we can try:

  • Save and re-set the module path around PSSA invocations
  • Work with PSSA to allow runspace pools to be provided or disabled

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jan 6, 2020
@o-l-a-v
Copy link
Contributor

o-l-a-v commented Aug 29, 2024

This seems to still be a problem? VSCode v1.92.2, extension v2024.2.2, PowerShell v7.4.5.

In my profile I change the order of PSModulePath in process context. It works great in standalone PowerShell consoles, in Windows Terminal, and I've verified with output that the profile runs successfully when VSCode and the extension starts up.

But right after when I write $env:PSModulePath.Split(';') in the integrated terminal using "PowerShell Extension", the PSModulePath in process context has been reset to default.

Related issues:

This causes conflicting assemblies when trying to load a PowerShell module thats also included with PowerShell, like Microsoft.PowerShell.PSResourceGet. Related issues:

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

No branches or pull requests

7 participants