Skip to content

The extension conflicts with my custom PowerShell profile #5146

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

Closed
6 tasks done
ylazy opened this issue Feb 24, 2025 · 2 comments
Closed
6 tasks done

The extension conflicts with my custom PowerShell profile #5146

ylazy opened this issue Feb 24, 2025 · 2 comments
Labels
Issue-Bug A bug to squash. Needs: Author Feedback Please give us the requested feedback!

Comments

@ylazy
Copy link

ylazy commented Feb 24, 2025

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

I'm using a custom powershell profile:

"terminal.integrated.profiles.windows":
{
    "ActionScript Debug Terminal":
    {
        "overrideName":true,
        "icon": "terminal-powershell",
        "color": "terminal.ansiMagenta",
        "path": "Y:/Development/ActionScript/SDK/Ylazy/Application/NativeProcess/PowerShell/bin/Windows/pwsh.exe",
        "args":
        [
            "-NoProfile",
            "-NoLogo",
            "-NoExit",
            "-ExecutionPolicy",
            "ByPass",
            "-Command",
            ". \"${execPath}${/}..${/}..${/}Data${/}Tasks${/}ActionScript${/}init.ps1\""
        ],
        
    }
}
"terminal.integrated.defaultProfile.windows": "ActionScript Debug Terminal",

The init.ps1 does some tasks and create some initial variables for using in sub scripts.

Whenever I run a shell script via the Command Runner, the script file no longer runs on my powershell profile. Instead, it runs on the PowerShell Extension profile. Thus, these initial variables are not available, so the extension show me errors.

How to config your extension to use my custom profile ActionScript Debug Terminal instead of PowerShell Extension?

Thanks!

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Microsoft Windows 10.0.26100
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          : 2025.0.0
InstanceId       : fb59126e-695b-4889-9b61-0fea15ff61b4
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.97.2
e54c774e0add60467559eb0d1e229c6452cf8447
x64

Extension Version

Steps to Reproduce

 & "$asTasks/reveal-workspace-folder.ps1"

Error:

&: The term '/reveal-workspace-folder.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

The error occurred because $asTasks not found.

Visuals

No response

Logs

No response

@ylazy ylazy added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Feb 24, 2025
@JustinGrote
Copy link
Collaborator

Thanks for your submission!

Please see the setting powershell.powerShellAdditionalExePaths to configure additional PowerShell executables to run with the PowerShell extension. Please note our official support statement in the README that the extension is supported only where PowerShell is supported, and that excludes custom builds of PowerShell if you in fact have one. It may work, but we will not take any action to fix it for anything that isn't reproducible on a standard PowerShell build.

As to your initial script, the PowerShell extension code host has its own profile file at $profile.currentusercurrenthost. You may want to consider adding your "init" script to that profile, since that's what the profile is.

@JustinGrote JustinGrote added Needs: Author Feedback Please give us the requested feedback! and removed Needs: Triage Maintainer attention needed! labels Feb 24, 2025
@ylazy
Copy link
Author

ylazy commented Feb 25, 2025

Thank you @JustinGrote

I'm new in PowerShell. Adding a profile file in $PSHome/profile.ps1 and using a variable to specify where to load the init file, I resolved the problem.

@ylazy ylazy closed this as completed Feb 25, 2025
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: Author Feedback Please give us the requested feedback!
Projects
None yet
Development

No branches or pull requests

2 participants