October 29, 2019 at 11:34 am #185375
Does anyone know why “$env:PSModulePath” returns different results in VSCode to the PowerShell console or ISE?
(PowerShell Console and ISE both match the System Environmental variables and changes show up in there, VSCode just seems to be doing its own thing and wherever it sees “\WindowsPowerShell\” it uses “\PowerShell\” instead. This seems to be the same for the PowerShell profile path as well.
I’ve tried restarting everything and uninstalling /installing VSCode.
October 29, 2019 at 12:24 pm #185399ParticipantTopics: 4Replies: 11Points: 103Rank: Participant
The only difference on the variable you mention, at least on my machines, is the following path added to VS Code:
Not having your “Powershell/WindowsPowershell” make me think of some addon installed, is that you case?
Have you installed anithing else apart for the powershell addon in VS Code?
October 29, 2019 at 1:08 pm #185414
Spot on! Thanks Pete, it looks like when I uninstalled and reinstalled it came back with my previous extensions. I had 1 extension aside from the PowerShell one which was ToDo. As soon as I uninstalled ToDo PSModule Path is now reporting correctly.
October 29, 2019 at 1:24 pm #185423
I spoke too soon….. The difference is if I have a file open or not!!
If I have a powershell file open then i get the VSCode set of environmental variables, if my files are closed and I type straight into the terminal window I get the PowerShell set of environmental variables. I’m going to keep digging and testing with other files etc.
October 29, 2019 at 9:16 pm #185546ParticipantTopics: 10Replies: 119Points: 631Rank: Major Contributor
I’m noticing a similar thing.
In VS Code, I have “powershell” and “PowerShell Integrated Console”.
powershell refers to Windows PowerShell, and Integrated refers to PowerShell 6.2.3.
When using Integrated (6.2.3), I’m getting bugged paths as well, even in the PowerShell 6 console.
Using powershell outputs the correct paths that also match ISE and the Windows PowerShell console.
Looks like this one should be filed as an issue with 6.2.3.
October 30, 2019 at 12:20 am #185570ParticipantTopics: 4Replies: 11Points: 103Rank: Participant
I have a similar behavior of Aaron’s VS Code, but different in some way: in my case when i open a .ps1 file i have two instances of powershell console
– powershell (which maintain color code as the ‘classic shell’, for example variables are green coloured
– Powershell Integrated Console (every keyword here is white as all the other text)
The difference is that in my case both shells give me identical $env:PSModulePath results, with the latter adding the path i reported in my previous post.
Even the variable $PSVersionTable has an identical value on both integrated VS Code’s consoles and the classic Powershell CLI
As far as I can tell the only difference i spotted is the specific VS Code Module path added on the Powershell Integrate Console
My VS Code addons are:
Material Icon Theme (and the ISE Theme just for the habit)
Plus I added Snippets for behavior consistency with the previous editor i used (ISE)
Last information I can think of is that if i try to close Powershell Integrate Console it give me an error asking if i want to restart it, hence i leave it there but using the ‘powershell’ that i find more readable (due to the keyword color)
- The topic ‘Visual Studio Code and Environmental Variables’ is closed to new replies.