JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.35k stars 2.38k forks source link

Update on Windows always fails with "access denied" #5318

Closed Bilge closed 3 months ago

Bilge commented 3 months ago

Code of Conduct

What happened?

It's very neat that the auto-update feature works, even on Windows, except that it doesn't because it always tries to replace the binary when it's still in use.

image

This seems to be because the upgrade command blocks during this upgrade process. There is no need to quit any terminals, but the upgrade command itself must be manually terminated with CTRL+C before "try again" will succeed.

Probably this could be fixed simply by not blocking waiting for the upgrade sub-process to finish before the parent oh-my-posh.exe process exits.

Theme

n/a

What OS are you seeing the problem on?

Windows

Which shell are you using?

bash

Log output

n/a
JanDeDobbeleer commented 3 months ago

@Bilge did you install as admin? Because we'll never have permissions in this case. I'll try to add that safety check in here because IMHO, that's exactly what happens. Running sudo oh-my-posh upgrade will work.

Bilge commented 3 months ago

It's been a while, but it seems I installed with Chocolatey, which I believe requires admin privileges. But this is not a privilege escalation issue, I don't think; the UAC prompt has already appeared by that point and works as expected. The issue is the upgrade process is blocking waiting for the upgrade to complete, but it doesn't complete because it can't overwrite the blocking process! If it just returned instead of blocking, it could be overwritten by the upgrade utility.

JanDeDobbeleer commented 3 months ago

@Bilge you're still using the "older" upgrade way that uses the installer. That's also why you saw the UAC, that one indeed had this issue. The new way uses a different technique and no longer has this bug, however, and that's fixed in the linked PR, it doesn't provide that feedback to the user (nicely). It does now. You still won't be able to use the CLI to upgrade oh-my-posh that was installed system wide as a user though, we can't popup an elevated prompt from golang, but at least we'll tell you :-)

github-actions[bot] commented 2 weeks ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.