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

Powershell profile not being loaded in terminal #5049

Closed
6 tasks done
flamableassassin opened this issue Sep 20, 2024 · 2 comments
Closed
6 tasks done

Powershell profile not being loaded in terminal #5049

flamableassassin opened this issue Sep 20, 2024 · 2 comments
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!

Comments

@flamableassassin
Copy link

flamableassassin commented Sep 20, 2024

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

To get around PowerShell/PSResourceGet#1494 I've been modifying $env:PSModulePath to include a folder where my modules are stored done using Save-Module. Due to the extension not loading my Powershell profile the env isn't being modified and is breaking access to modules.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.3
PSEdition                      Core 
GitCommitId                    7.4.3
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : Visual Studio Code Host
Version          : 2024.2.2
InstanceId       : 15edc23a-1b05-4c1c-bf82-ffc23928363a
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-GB
CurrentUICulture : en-GB
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.94.0-insider
527e41ff551bb1001d2f224c2dec2e2ea3b66832
x64

Extension Version

Steps to Reproduce

NaN

Visuals

No response

Logs

No response

@flamableassassin flamableassassin added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Sep 20, 2024
@o-l-a-v
Copy link
Contributor

o-l-a-v commented Oct 13, 2024

You might have to use a different path for profile with vscode. See:

I use following paths for profile, which also loads in VSCode:

# PowerShell 6/7
[System.IO.Path]::Combine(
    [System.Environment]::GetFolderPath('MyDocuments'),
    'PowerShell',
    'Profile.ps1'
)

# Windows PowerShell 5.1
[System.IO.Path]::Combine(
    [System.Environment]::GetFolderPath('MyDocuments'),
    'WindowsPowerShell',
    'Profile.ps1'
)

Or you can modify $env:PSModulePath in user or system context, then a $profile is not needed.

# User context
[System.Environment]::SetEnvironmentVariable(
    'PSModulePath',
    '<value1>;<value2>',
    'User'
)

# System context
[System.Environment]::SetEnvironmentVariable(
    'PSModulePath',
    '<value1>;<value2>',
    'Machine'
)

@flamableassassin
Copy link
Author

Well I missed the fact that my vscode profile was named Microsoft.VSCode_profile.ps1.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

2 participants