You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently pnpm creates 3 different files for dependency binaries (bash, ps1 and CMD), in most cases the OS will select the correct binary to use, such as bash for UNIX, CMD for Windows CMD and ps1 when using Powershell.
In Powershell it is possible to limit the execution of scripts through a list of Execution Policies, normally, users will not modify that policy and will keep the default one (unrestricted for <6 powershell and RemoteSigned for >6 Powershell, also known as PWSH).
In some cases the policy may be changed to a stricter one that could block the execution of binaries and therefore break applications when using pnpm with Powershell.
Describe the solution you'd like
Automatically check if the user has a permissive policy that allows execution of .ps1 scripts by checking Get-executionPolicy. If the policy restricts it, generate only the bash and CMD files to force Powershell to use the CMD file.
Describe the drawbacks of your solution
Small performance degradation in Windows when installing dependencies in clean project (200ms aprox., response is memory cached)
Does not work with process-specific policies (Set-ExecutionPolicy -ExecutionPolicy Restricted -Scope Process) as the checker runs in a new process.
When using Powershell <6, it does not detect user profiles and uses the system one.
Describe alternatives you've considered
Keep it as it is. We don't have any issue opened about this problem, seems very specific but some users could find this issue at some point.
The text was updated successfully, but these errors were encountered:
For reference, this is what currently appears when trying to run a globally installed package if the Policy is Restricted.
PS E:\>set-ExecutionPolicy-ExecutionPolicy Restricted -Scope Process
PS E:\> rimraf -v
rimraf: File C:\Users\nacho\AppData\Local\pnpm\rimraf.ps1 cannot be loaded because running scripts is disabled
on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
By default as pnpm creates the .ps1 file, so globally packages installed with pnpm don't have that prompt when running in Powershell.
And about npm, the CLI itself has the prompt (at least in my side), so when running npm run build it appears, even though npm also creates .ps1 files in the node_modules/.bin directory.
Contribution
Describe the user story
Currently pnpm creates 3 different files for dependency binaries (
bash
,ps1
andCMD
), in most cases the OS will select the correct binary to use, such asbash
for UNIX,CMD
for Windows CMD andps1
when using Powershell.In Powershell it is possible to limit the execution of scripts through a list of Execution Policies, normally, users will not modify that policy and will keep the default one (
unrestricted
for <6 powershell andRemoteSigned
for >6 Powershell, also known as PWSH).In some cases the policy may be changed to a stricter one that could block the execution of binaries and therefore break applications when using pnpm with Powershell.
Describe the solution you'd like
Automatically check if the user has a permissive policy that allows execution of
.ps1
scripts by checkingGet-executionPolicy
. If the policy restricts it, generate only thebash
andCMD
files to force Powershell to use theCMD
file.Describe the drawbacks of your solution
Set-ExecutionPolicy -ExecutionPolicy Restricted -Scope Process
) as the checker runs in a new process.Describe alternatives you've considered
Keep it as it is. We don't have any issue opened about this problem, seems very specific but some users could find this issue at some point.
The text was updated successfully, but these errors were encountered: