uv: uv self update: failed to execute installer (status: exit code: 1) on Windows

When running uv self update --verbose on my Windows 11 machine, I get the following output:

DEBUG uv 0.2.28
info: Checking for updates...
error: failed to execute installer (status: exit code: 1)

Installing and updating uv through the following command works as expected: irm https://astral.sh/uv/install.ps1 | iex uv has only been installed via the standalone installer, not via pip.

I can’t seem to reproduce the issue on any other system or virtual machine.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

I agree it would be great to just run in the current version of powershell, core on not. Unfortunately, explicitly invoking powershell here is a workaround for the reverse problem: people would paste this command into cmd and it would fail. And microsoft quite explicitly made classic powershell and powershell core have different commands (powershell vs pwsh) to make sure you don’t accidentally invoke one when you meant the other, since they have fairly different semantics (especially around utf8 vs utf16).

I’m pretty confident the cmd case is more pervasive than the pwsh one, but still, it would be good for us to find a way to manage this execution policy thing better.

Yes, the issue persists. Also tried different older versions of uv and deleted everything uv-related from the AppData directory.

I also tried changing the ExecutionPolicy from RemoteSigned to Unrestricted, but that didn’t help either.

I’ve hit this too. I have a pretty default Windows 11, with PowerShell core, but with dev mode disabled:

PowerShell 7.4.4

PS C:\Users\user> powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
Error: PowerShell requires an execution policy in [Unrestricted, RemoteSigned, ByPass]
to run uv. For example, to set the execution policy to 'RemoteSigned' please run:

    Set-ExecutionPolicy RemoteSigned -scope CurrentUser

PS C:\Users\user> irm https://astral.sh/uv/install.ps1 | iex
Downloading uv 0.3.3 (x86_64-pc-windows-msvc)
Installing to C:\Users\user\.cargo\bin
  uv.exe
  uvx.exe
everything's installed!

C:\Users\user\.cargo\bin was added to your PATH, you may
need to restart your shell for that to take effect.

The alternative ways of installing on Windows should at least be documented:

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
powershell -ExecutionPolicy Bypass -c "irm https://astral.sh/uv/install.ps1 | iex"
irm https://astral.sh/uv/install.ps1 | iex

It might be worth mentioning that under cmd one should use the powershell -c variant, and the irm ... variant for powershell.

Windows also ships with curl now, so a variation of this would work under both cmd and powershell. The .bat file would autodetect the env it’s run under and proceed accordingly:

curl -LsSf https://astral.sh/uv/install.bat -o uv_install.bat && .\uv_install.bat

@jon-ton would you be willing to contribute that to the installation docs?

Trying to update uv v0.2.36 via uv self update --verbose revealed some information which helped me fix the problem.

DEBUG uv 0.2.36
info: Checking for updates...
error: The installation failed. Output from the installer:
C:\Users\Thomas\AppData\Local\Temp\.tmpCelC4m\installer.ps1 : File
C:\Users\Thomas\AppData\Local\Temp\.tmpCelC4m\installer.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.
At line:1 char:1
+ C:\Users\Thomas\AppData\Local\Temp\.tmpCelC4m\installer.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

My Execution-Policy is set to RemoteSigned. The uv standalone installer also works, so what’s going on here?

Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    RemoteSigned
 LocalMachine    RemoteSigned

It turnes out that the current PowerShell Core (v7) and the integrated PowerShell Classic (v5) have separate Execution-Policy settings and for some reason the integrated uv updater runs in PowerShell Classic!

powershell.exe Get-ExecutionPolicy -List

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine       Undefined

Changing the Execution-Policy to RemoteSigned in PowerShell Classic too fixes my issues! 😄

I think the updater should run in the same shell as the uv command is run from to prevent these kind of issues.