terminal
terminal copied to clipboard
Doesn't detect pwsh installed in custom directory from Scoop
Environment
Windows build number: 10.0.19042.0 Windows Terminal version (if applicable): 1.4.3141.0
PowerShell Core: 7.1.0 Scoop
Steps to reproduce
- Installing Scoop to Custom Directory
- Install PowerShell Core via Scoop
- Open Windows Terminal
Expected behavior
When environment variable SCOOP or SCOOP_GLOBAL is defined, Terminal should search pwsh.exe in %SCOOP% and %SCOOP_GLOBAL% in addition to %USERPROFILE%\scoop.
Actual behavior
Error dialog is opened. The content of error message is "An error occurred while loading the settings." (Sorry, I don't know the message of English version because I use Japanese version).
And, PowerShell is used instead, and PowerShell Core doesn't appear in the shell list.
Searching place is only %USERPROFILE%scoop for Scoop.
(ref: PowershellCoreProfileGenerator.cpp Line 281, Tag 1.4.3141.0)
Related issue
#1415
Thanks for reporting this! I didn't know about the %scoop% env var and the ability to install scoop to a custom directory. Probably wouldn't be too hard to fix this...
/cc @DHowett
Is it guaranteed that SCOOP and SCOOP_GLOBAL are set?
Every location we search needs a differentiator; otherwise, we may detect three instances of PowerShell and they'll collapse into one. Right now, we only have one Scoop differentiator.
I think those variables are not set by default (I don't find them in my system).
From the documentation here, it looks like you can change the directory for user-installed programs and global-installed programs independently.
In my case too, those variables were not set by default before changing into custom directory.
Using Scoop, we can install following 4 locations,
- %USERPROFILE%\scoop (default of user scope),
- %SCOOP% (custom of user scope),
- %ProgramData%\scoop (default of global scope),
- %SCOOP_GLOBAL% (custom of global scope).
To decide which PowerShell is used from these, I think the priorities of search is needed.
I think checking %PATH% first would largely solve the problem. pwsh.exe is in PATH by default when installing either way (scoop or official .msi).
terminal is now able to detect from scoop default directory hence a more generic workaround using mklink (based on https://github.com/microsoft/terminal/issues/1415)
mklink /J "%USERPROFILE%\scoop" "%SCOOP%"