Closed karlhorky closed 1 month ago
after running those commands in the terminal to upgrade node latest
brew upgrade node@20
corepack disable
corepack enable
corepack prepare pnpm@latest --activate
i have the same problem now that it shows:
Warning: node@20 20.11.1 already installed
zsh: command not found: corepack
zsh: command not found: corepack
zsh: command not found: corepack
It seems like this can happen after upgrading Node.js via commands like brew upgrade node@20
.
In that case, we needed to also run:
brew link --overwrite node@20
Added to upgrade cheatsheet:
@ProchaLu on Windows it appears that this may sometimes be caused on some Windows machines by an execution policy of Restricted
(the following was on a Windows 10 machine):
PS C:\Windows\system32> corepack enable
corepack : Die Benennung "corepack" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie den Vorgang.
PS C: \Windows\system32> Get-ExecutionPolicy - List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
PS C: \Windows\system32> Get-ExecutionPolicy
Restricted
PS C: \Windows\system32> Set-ExecutionPolicy RemoteSigned
Ausführungsrichtlinie ändern
Die Ausführungsrichtlinie trägt zum Schutz vor nicht vertrauenswürdigen Skripts bei. Wenn Sie die Ausführungsrichtlinie
andern,
sind Sie möglicherweise den im Hilfethema
"about_Execution_Policies" unter
"https:/go.microsoft.com/fwlink/?LinkID=135170™ beschriebenen Sicherheitsrisiken ausgesetzt. Möchten Sie die
Ausführungsrichtlinie ändern?
[0] Ja
[A] Ja, alle [N] Nein [K] Nein, keine [H] Anhalten [?] Hilfe (Standard ist "N"): J
PS C:\Windows\system32> Get-ExecutionPolicy
RemoteSigned
PS C: \Windows\system32> corepack enable
PS C: \Windows\system32> corepack prepare popm@latest --activate
Preparing prpm@latest for immediate activation...
Enabling the RemoteSigned
execution policy with Set-ExecutionPolicy RemoteSigned
allowed this student with this Windows 10 machine to proceed and use corepack
Before we can change the guide, this needs further research as to:
PowerShell's execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. This feature helps prevent the execution of malicious scripts. The default execution policy for Windows client computers is Restricted
. This setting prevents running all script files.
To allow PowerShell to run scripts, we need to change the setting to RemoteSigned
, that is the default policy for Windows server computers. This setting allows:
we still need some kind of first explanation / investigation for this:
3. and why all other systems have not needed this so far
I edited the comment above to remove the bit about speculation, which didn't add anything to the discussion
let's confirm that specific thing. the only two bits of information at PowerShell's execution policy linked above are:
Restricted
- The default execution policy for Windows client computers.
Default
- Restricted for Windows clients.
Restricted
, then we can continue to any suggestions that you have for a solutionWhen installing Windows for the first time, Windows 10/11 uses Windows PowerShell 5.1. as default. The default execution policy for Windows 10/11 is Restricted
, also explained in these different blog posts:
I think this confirms the default behavior. If we don't want to change it, we could change the execution policy for the single pnpm setup
command because we do the same already when installing Chocolatey.
Set-ExecutionPolicy Bypass -Scope Process -Force;
If we don't want to change it, we could change the execution policy for the single
pnpm setup
command because we do the same already when installing Chocolatey.
this sounds like the best, most secure option, but I think the UX would have a downside here, because it would be required for every time a student installs a new version of pnpm with corepack, right?
this sounds like the best, most secure option, but I think the UX would have a downside here, because it would be required for every time a student installs a new version of pnpm with corepack, right?
Yes, students always have to set the execution policy when running pnpm with corepack.
Maybe a different solution would be to set the execution policy to AllSigned
. In the install guide of the Chocolatey docs, we are currently using this install command
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
This command sets the execution policy to Bypass
for this single command. As an alternative, the Chocolatey docs suggest changing the execution policy to AllSigned
. AllSigned
requires that all scripts and configuration files are signed by a trusted publisher, including scripts written on the local computer.
The script to install Chocolatey would be:
Set-ExecutionPolicy AllSigned; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
When changing the execution policy in this step, we don't have to make additional changes to the System Setup Guide.
When changing the execution policy in this step, we don't have to make additional changes to the System Setup Guide.
nice, sounds like a secure option, and we don't need to add a new step 👍
Running any of the Corepack commands eg.
corepack enable
orcorepack prepare pnpm@latest --activate
can sometimes cause a "not found" message:Example on macOS
Example on Windows
TODO