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

Suggestion: User binary dir #331

Open
tdeck opened this issue Jan 14, 2025 · 2 comments
Open

Suggestion: User binary dir #331

tdeck opened this issue Jan 14, 2025 · 2 comments

Comments

@tdeck
Copy link

tdeck commented Jan 14, 2025

Many platforms have a directory for user binaries that is already part of the PATH. This is useful when your application wants to set up some helper utilities by symlinking them in so they're easily accessible.

For example, the XDG specification states:

User-specific executable files may be stored in $HOME/.local/bin. Distributions should ensure this directory shows up in the UNIX $PATH environment variable, at an appropriate place.

Although it doesn't provide an env var for this directory, for some reason.

On Windows I believe an equivalent directory would be %UserProfile%\AppData\Local\Microsoft\WindowsApps

@Diapolo10
Copy link

For some additional context, a default Windows 11 24H2 installation has five paths in the PATH environment variable. These are from Windows Sandbox:

  • C:\Windows\system32
  • C:\Windows
  • C:\Windows\System32\Wbem
  • C:\Windows\System32\WindowsPowerShell\v1.0\
  • %UserProfile%\AppData\Local\Microsoft\WindowsApps

The first four are on the system-wide PATH, and the last one in the user-specific environment variables. For hopefully obvious reasons I'd advise against using the first four for anything unless you happened to be a Microsoft employee.

However, I'm not entirely convinced that last one would be suitable for this purpose, either. Based on other discussion regarding it it seems in order to actually make use of it you'd have to be editing registry keys, and it wouldn't be as simple as chucking a symlink there and calling it a day. So in other words I don't think Windows actually has a perfectly matching equivalent for this particular XDG recommendation.

Feel free to prove me wrong, though.

@tdeck
Copy link
Author

tdeck commented Mar 16, 2025

I was able to build this solution that works in both LInux and Windows - on Windows I'm using that directory. However, I found it impractical to use symlinks (in Windows) because they require admin permissions, which I was trying to avoid.

Instead what I did was drop a batch file that simply runs my program. This seems to work great, I've so far not had any reported issues with this setup and it doesn't require any special permissions or configurations. Granted, my use case may not be very common, but I'd certainly recommend this as an easy way to make sure your program ends up in PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants