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
PNPM_HOME
does not expand on Windows
#5696
Comments
PNPM_HOME
in Path
does not expand on WindowsPNPM_HOME
does not expand on Windows
How can we run then native API? Should we generate a powershell file and run it? As far as I remember Windows doesn't allow to run unsigned ps1 files. |
I'm unsure what this looks like practically in terms of security-related permissions but you should be able to run the PowerShell executable with the necessary function as an argument |
Based on the fact this works: powershell -command "[System.Environment]::SetEnvironmentVariable('PNPM_HOME', '$pnpmHome', [System.EnvironmentVariableTarget]::User)"
I know this looks silly, but it's probably the best solution here unless you want to embed a native binary or FFI that somehow calls the API await execa('powershell', ['-command', '"[System.Environment]::SetEnvironmentVariable(\'${envVarName}\', \'${envVarValue}\', [System.EnvironmentVariableTarget]::User)"'], EXEC_OPTS) You may want to split this up somehow to avoid the long single string, but that's all for however you want to style your own code :P |
By the way, for this issue there was this suggestion: #4658 (comment) that I released in v7.17.1 That didn't help? |
Looks like it is solved but only if PNPM_HOME wasn't configured by pnpm older than v7.17 |
yes the findings in that comment make sense with my previous findings! maybe a separate change needs to be made to retrieve, unset, and reset (or would unsetting be necessary at all?) |
pnpm version:
7.17.0
Code to reproduce the issue:
n/a
Expected behavior:
%PNPM_HOME%
expands when inserted into other environment variables such asPath
.Example
If Path is set to
%PNPM_HOME%;%USERPROFILE%\.bin
, when opening a shell it becomesC:\Users\user\AppData\Local\pnpm;C:\Users\user\.bin
Actual behavior:
Example
If Path is set to
%PNPM_HOME%;%USERPROFILE%\.bin
, when opening a shell it becomes%PNPM_HOME%;C:\Users\user\.bin
Additional information:
node -v
prints: v19.1.0Suspected cause
This has been reproduced by myself and @maplefins in further testing:
During
pnpm setup
, pnpm sets an environment variable calledPNPM_HOME
. On Windows, it does this by directly calling reg.exe instead of using a native system API (seepath-extender-windows.ts
; also see Workaround below).Reproduced on
Workaround
Update the
PNPM_HOME
variable via a native API (in a shell or the Environment Variables editor UI).In PowerShell:
The text was updated successfully, but these errors were encountered: