Skip to content
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

[Package Issue]: Gyan.FFmpeg sets environment path incorrectly #95349

Closed
2 tasks done
rlaphoenix opened this issue Feb 2, 2023 · 48 comments
Closed
2 tasks done

[Package Issue]: Gyan.FFmpeg sets environment path incorrectly #95349

rlaphoenix opened this issue Feb 2, 2023 · 48 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Milestone

Comments

@rlaphoenix
Copy link

rlaphoenix commented Feb 2, 2023

Please confirm these before moving forward

  • I have searched for my issue and not found a work-in-progress/duplicate/resolved issue.
  • I have not been informed if the issue is resolved in a preview version of the winget client.

Category of the issue

Installation issue.

Brief description of your issue

The ffmpeg, ffprobe, and ffplay aliases do not work even after restarting shell due to the environment path being wrong.

The environment path added was C:\Users\...\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe but it needs to be C:\Users\...\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-5.1.2-full_build\bin before it works.

Steps to reproduce

  1. winget install ffmpeg
  2. Wait for installation to complete
  3. Close and re-open shell
  4. Type ffmpeg --help, it will fail and say it's unrecognised

Actual behavior

the ffmpeg, ffplay, and ffprobe aliases are not recognized

Expected behavior

They should be found and refer to the binary.

Environment

Windows Package Manager (Preview) v1.5.101-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.1105
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.20.101.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

User Settings: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json

Screenshots and Logs

image

@rlaphoenix rlaphoenix added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Feb 2, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage This work item needs to be triaged by a member of the core team. label Feb 2, 2023
@Trenly
Copy link
Contributor

Trenly commented Feb 2, 2023

This is because ffmpeg is a library and not truly a portable application or portable installer

Blocked by microsoft/winget-cli#2711

@SpecterShell
Copy link
Contributor

It works for me though.
image

@Trenly
Copy link
Contributor

Trenly commented Feb 2, 2023

Interesting.

I wonder if it's due to path cramming differences between user/admin and whether or not developer mode is enabled. Might have something to do with symlink creation

@rlaphoenix
Copy link
Author

rlaphoenix commented Feb 2, 2023

Doesn't work for me, I had to explicitly put \ffmpeg-5.1.2-full_build\bin to the end of the environment path. It looks like you're either on Linux or using a different terminal to me. Maybe it's something to do with that? But I tried Windows Terminal, PowerShell (latest from the Windows Store), normal PowerShell, and Command Prompt. It didn't work on any.

The normal environment path has nothing but that ffmpeg-5.1.2-full_build folder within it. Maybe a solution would be to symlink the ffmpeg, ffprobe and ffplay binaries to the root?

@SpecterShell
Copy link
Contributor

SpecterShell commented Feb 2, 2023

Also tried in my virtual machine. Even if the directory C:\Users\<Username>\AppData\Local\Microsoft\WinGet\Links has been added to PATH by WinGet and can be seen in the system's "Environmental Variables" settings, it is not shown in the subsequent processes. 🤔
image

@rlaphoenix
Copy link
Author

rlaphoenix commented Feb 2, 2023

Also tried in my virtual machine. Even if the directory C:\Users\<Username>\AppData\Local\Microsoft\WinGet\Links has been added to PATH and can be seen in the system's "Environmental Variables" settings, it is not shown in the subsequent processes. 🤔

I believe you need to fully close all previous terminals, then open a new one for it to actually refresh. Hence why it's not in your PATH yet.

@Trenly
Copy link
Contributor

Trenly commented Feb 2, 2023

C:\Users<Username>\AppData\Local\Microsoft\WinGet\Link

Even when doing that, I still don't see it reflected in $env:Path.

It looks to me like it is only added to the User Variable path and not the System Variable path, Adding %LOCALAPPDATA%\Microsoft\WinGet\Links to the System Variable path seemed to resolve the issue for me. I'm not sure why it wouldn't be detecting the user path
image

@SpecterShell
Copy link
Contributor

I believe you need to fully close all previous terminals, then open a new one for it to actually refresh.

Doesn't work for me.

It looks to me like it is only added to the User Variable path and not the System Variable path, Adding %LOCALAPPDATA%\Microsoft\WinGet\Links to the System Variable path seemed to resolve the issue for me.

Simply opening User Variable Path edit dialog and then clicking on "OK"s twice also resolves the issue.

@rlaphoenix
Copy link
Author

For me, %LOCALAPPDATA%\Microsoft\WinGet\Links was never added. Only %LOCALAPPDATA%\Microsoft\WindowsApps. I tried adding it to both user and system PATH, as well as one or the other, and nothing still.

I also tried undoing my change and just opening and hitting save twice, and still nothing.
The fact that did work for you has to be incredibly odd.

@GyanD
Copy link

GyanD commented Feb 2, 2023

This is because ffmpeg is a library and not truly a portable application or portable installer

The pkg being downloaded is ffmpeg-5.1.2-full_build.zip which contains three statically linked i.e. standalone bnaries.

P.S. The PackageName in the locale files should be corrected to just FFmpeg.

@Trenly
Copy link
Contributor

Trenly commented Feb 2, 2023

The pkg being downloaded is ffmpeg-5.1.2-full_build.zip which contains three statically linked i.e. standalone bnaries.

My mistake, I was misunderstanding between multiple issues

@rlaphoenix
Copy link
Author

rlaphoenix commented Feb 2, 2023

P.S. The PackageName in the locale files should be corrected to just FFmpeg.

I think the package names require authors, and therefore it should be Gyan.FFmpeg as it is now. Theoretically, it could be FFmpeg.FFmpeg, however, FFmpeg did not author the builds themselves.

@GyanD
Copy link

GyanD commented Feb 2, 2023

I'm referring to PackageName, not PackageIdentifier.
See line 12 of https://github.com/microsoft/winget-pkgs/blob/master/manifests/g/Gyan/FFmpeg/5.1.2/Gyan.FFmpeg.locale.en-US.yaml and https://github.com/microsoft/winget-pkgs/blob/master/manifests/g/Gyan/FFmpeg/5.1.2/Gyan.FFmpeg.locale.zh-CN.yaml

'Codex FFmpeg' is the name of my site. The package is simply 'FFmpeg;'.

@rlaphoenix
Copy link
Author

I'm referring to PackageName, not PackageIdentifier. See line 12 of https://github.com/microsoft/winget-pkgs/blob/master/manifests/g/Gyan/FFmpeg/5.1.2/Gyan.FFmpeg.locale.en-US.yaml and https://github.com/microsoft/winget-pkgs/blob/master/manifests/g/Gyan/FFmpeg/5.1.2/Gyan.FFmpeg.locale.zh-CN.yaml

'Codex FFmpeg' is the name of my site. The package is simply 'FFmpeg;'.

Ahh my mad. I do agree with this.

@SpecterShell
Copy link
Contributor

P.S. The PackageName in the locale files should be corrected to just FFmpeg.

I forgot to change the PackageName and have opened a PR for this 😂:
#95368

@mstevens83
Copy link

mstevens83 commented Feb 2, 2023

Doesn't work for me, I had to explicitly put \ffmpeg-5.1.2-full_build\bin to the end of the environment path. It looks like you're either on Linux or using a different terminal to me. Maybe it's something to do with that? But I tried Windows Terminal, PowerShell (latest from the Windows Store), normal PowerShell, and Command Prompt. It didn't work on any.

The normal environment path has nothing but that ffmpeg-5.1.2-full_build folder within it. Maybe a solution would be to symlink the ffmpeg, ffprobe and ffplay binaries to the root?

I have the exact same problem. This was added my PATH: C:\Users\steven89\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\
But the exe's live 2 folders deeper: C:\Users\steven89\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-5.1.2-full_build\bin

@sitiom
Copy link
Contributor

sitiom commented Feb 2, 2023

and whether or not developer mode is enabled. Might have something to do with symlink creation

I have developer mode enabled, and it works for me. A symlink is added to %localappdata%\Microsoft\WinGet\Links\, people who report it to not work have the binary PATH directly added instead. Is it related to that? Does Winget not create symlinks on non-developer machines and adds the binary directly to the PATH instead? If so, that is a non-developer mode-specific bug.

@mstevens83
Copy link

and whether or not developer mode is enabled. Might have something to do with symlink creation

I have developer mode enabled, and it works for me. A symlink is added to %localappdata%\Microsoft\WinGet\Links\, people who report it to not work have the binary PATH directly added instead. Is it related to that? Does Winget not create symlinks on non-developer machines and adds the binary directly to the PATH instead? If so, that is a non-developer mode-specific bug.

What "developer mode" are you referring to? Is this a winget-cli thing? A powershell thing? Windows itself?
As you can tell from the question it is safe to assume I'm not running developer mode :), so you may be on to something.

@sitiom
Copy link
Contributor

sitiom commented Feb 2, 2023

What "developer mode" are you referring to? Is this a winget-cli thing? A powershell thing? Windows itself?

See https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development. Yes, it is a Windows thing. The important thing that you need to know is that creating symlinks normally require admin previlages, and developer mode bypasses that:
image

I'm thinking the "Add binary directory to PATH directly" is a fallback to non-admin and non-developer mode machines. Try enabling it and see if it resolves your problem.

@mstevens83
Copy link

mstevens83 commented Feb 2, 2023

What "developer mode" are you referring to? Is this a winget-cli thing? A powershell thing? Windows itself?

See https://learn.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development. Yes, it is a Windows thing. The important thing that you need to know is that symlinks normally only work under admin, and developer mode bypasses that:

I'm thinking the "Add binary directory to PATH directly" is a fallback to non-admin and non-developer mode machines. Try enabling it and see if it resolves your problem.

Ok, I'll try that. But even if it would fix my problem, there is still a bug at work here, no? The directory path being added to PATH on non-developer mode machines should not be incomplete...

@sitiom
Copy link
Contributor

sitiom commented Feb 2, 2023

I'm thinking the "Add binary directory to PATH directly" is a fallback to non-admin and non-developer mode machines.

  • Handles the scenario for installing a portable where a user does not have developer mode enabled or is not running as admin by skipping the symlink creation step and adding the exe directly.

I am now able to replicate this bug by turning off developer mode. Note that refreshenv is a Chocolatey command that refreshes environment variables in the current terminal session:
image

@sitiom
Copy link
Contributor

sitiom commented Feb 2, 2023

This bug should only affect people without developer mode enabled and don't have admin previlages.

@stephengillie stephengillie removed the Needs-Triage This work item needs to be triaged by a member of the core team. label Feb 2, 2023
@rlaphoenix
Copy link
Author

This same issue is happening with aria2.aria2, in the exact same way.

@KevinMarquette
Copy link

KevinMarquette commented Apr 15, 2023

I also ran into this issue. Fresh Win11 install, unelevated, no developer mode.

winget install ffmpeg

Closed and opened the terminal, then checked the path:

PS> $env:path -split ';'
...
C:\Users\kevma\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe

PS> ls C:\Users\kevma\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         4/15/2023   2:38 PM                ffmpeg-6.0-full_build

Going deeper into the path, at \ffmpeg-6.0-full_build\bin, I can find the executables.

    Directory: 
C:\Users\kevma\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe
\ffmpeg-6.0-full_build\bin

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          3/4/2023  11:54 AM      131666944 ffmpeg.exe
-a----          3/4/2023  11:54 AM      131504128 ffplay.exe
-a----          3/4/2023  11:54 AM      131544064 ffprobe.exe

edit: Running uninstall also does not remove it from the path.

@davidnr
Copy link

davidnr commented Apr 23, 2023

Same here

@mdanish-kh
Copy link
Contributor

Resolved in WinGet v1.5.1081-preview release

@ZhiZe-ZG
Copy link

It may be a bug. For now, try winget install Gyan.FFmpeg with administrator status.

@mdanish-kh
Copy link
Contributor

Resolved in WinGet v1.5.1081-preview release

Close with reason: Stated above;

@rvxfahim
Copy link

Resolved in WinGet v1.5.1081-preview release

I tried with the prerelease winget, doesn't solve for me.

@GavinRay97
Copy link

This is happening for me still as a heads up

The issue is that the install seems to add the parent directory to the PATH, instead of full-build/bin:

image

@brizolara
Copy link

The issue is that the install seems to add the parent directory to the PATH, instead of full-build/bin

Same here...

@mdanish-kh
Copy link
Contributor

@rvxfahim Did you already have an installation of ffmpeg from an older version of WinGet?

@GavinRay97 @brizolara Can you please share the version of WinGet you are running from winget -v command?

@GavinRay97
Copy link

@mdanish-kh Certainly, thanks for the swift reply (and on a weekend, no less)

S C:\Users\rayga> winget -v
v1.4.11071

I suspect this is because of your earlier comment:

#95349 (comment)

Resolved in WinGet v1.5.1081-preview release

Sorry, I should have double-checked my version. For some reason I thought WinGet auto-updated.

@mdanish-kh
Copy link
Contributor

mdanish-kh commented May 27, 2023

@GavinRay97 No worries :) Note that an uninstall would be required first to benefit from the fix. I would advise uninstalling the package first from WinGet 1.4 (if you haven't upgraded already) as there's a bug currently in the preview version where the uninstall command gets stuck infinitely for these packages if there is a prior installation from WinGet 1.4. (microsoft/winget-cli#3279)

If you have upgraded though, the most convenient workaround I've found is to downgrade to WinGet 1.4 (i.e. download and install msix from https://github.com/microsoft/winget-cli/releases/download/v1.4.10173/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle), force uninstall the package using winget uninstall ffmpeg --force, then upgrade to the preview release and install the package with winget install ffmpeg

@rvxfahim
Copy link

@rvxfahim Did you already have an installation of ffmpeg from an older version of WinGet?

yes, I installed 1.4 then force uninstalled and then installed preview version of winget and then installed ffmpeg. Now it works

@mtuan293
Copy link

mtuan293 commented Jun 7, 2023

This bug should only affect people without developer mode enabled and don't have admin previlages.

can confirm I still get this bug as of June of 2023. winget version is "v1.4.11071"
I didn't turn on Developer Mode at all, just launched Terminal as admin that makes a difference.

  • Without admin privileges: C:\Users\_YourName_\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe got added as PATH. Nothing in C:\Users\_YourName_\AppData\Local\Microsoft\WinGet\Links, just an empty folder.
  • With admin privileges: C:\Users\_YourName_\AppData\Local\Microsoft\WinGet\Links is added as PATH instead. There are also 3 symlinks: "ffmpeg.exe", "ffplay.exe" and "ffprobe.exe" in this folder.

So, if you installed ffmpeg using winget with no admin nor developer mode enabled, I'd recommend you winget uninstall ffmpeg first, then restart your computer, then manually remove any remaining files AND remove the wrong PATH because winget will screw up the removal process and left over those stuff.

@MJWexer
Copy link

MJWexer commented Jun 21, 2023

Confirmed issue and solution for 6.0
..\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-6.0-full_build\bin

@B4ttleMast0r
Copy link

Why was this closed? I have the same issue. It added the path two directories up to PATH instead of the bin directory

@dan-mcdonald
Copy link

Why was this closed? I have the same issue. It added the path two directories up to PATH instead of the bin directory

@B4ttleMast0r I had the same problem as you, but it was because I didn't carefully read the all the messages in this thread. It is fixed only if you installed FFmpeg with winget 1.5+. It has been in release candidate stage for almost a month so hopefully they can push it to GA soon and us poor folks will stop cutting our metaphorical fingers on this issue.

@XueshiQiao
Copy link

Also tried in my virtual machine. Even if the directory C:\Users\<Username>\AppData\Local\Microsoft\WinGet\Links has been added to PATH and can be seen in the system's "Environmental Variables" settings, it is not shown in the subsequent processes. 🤔

I believe you need to fully close all previous terminals, then open a new one for it to actually refresh. Hence why it's not in your PATH yet.

works for me, thank you.

@ZhymabekRoman
Copy link

+1, Same error: as workaround:

$env:path += ";C:\Users\Administrator\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-6.0-full_build\bin"

@seancheung
Copy link

For me, I found out that I wasn't running winget as admin. It got installed but no environment variables can be added.

@JetUni
Copy link

JetUni commented May 9, 2024

Still not working for me with fresh install on Windows 11 22H2
Winget v1.7.11261
FFmpeg C:\Users\Administrator\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-7.0-full_build\bin

Error:

PS C:\Users\Jarrett> ffmpeg
ffmpeg : The term 'C:\Users\Jarrett\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3
d8bbwe\ffmpeg-6.0-full_build\bin\ffmpeg.exe' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ ffmpeg
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Jarret...\bin\ffmpeg.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

@mikfar
Copy link

mikfar commented May 11, 2024

I uninstalled the package and reinstalled as admin, then the PATH was actually updated.

@rlaphoenix
Copy link
Author

I recently clean installed Windows 11 with the latest Media Creation Tool -> USB. I did winget install ffmpeg as admin and it properly added to path correctly for ffmpeg, ffplay, and ffprobe. I did not attempt without admin but I presume it would have failed.

@niwazukihon
Copy link

niwazukihon commented Jul 1, 2024

This is not fixed with the latest version of winget. When I installed ffmpeg it was fine, but today I upgraded it and ffmpeg got removed from PATH. I had to add it manually. Maybe should be merged with #120360.

@dave2nian
Copy link

when you used command: "winget install ffmpeg"
the bin PATH maybe not add in windows 11.

resolution:

run sysdm.cply
to add a new record in $PATH in Windows
its path as below:
C:\Users<username>\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-7.0.2-full_build\bin

updated Sep.14 2024.

@NeoMod
Copy link

NeoMod commented Oct 25, 2024

when you used command: "winget install ffmpeg" the bin PATH maybe not add in windows 11.

resolution:

run sysdm.cply to add a new record in $PATH in Windows its path as below: C:\Users\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-7.0.2-full_build\bin

updated Sep.14 2024.

thank you @dave2nian, I was trying to figure out where the binary was after using winget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
None yet
Development

No branches or pull requests