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

Add base support for XDG base user executable dir #28

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scop
Copy link

@scop scop commented Jan 3, 2022

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

There is a single base directory relative to which user-specific
executable files may be written.

User-specific executable files may be stored in $HOME/.local/bin.

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

> There is a single base directory relative to which user-specific
> executable files may be written.

> User-specific executable files may be stored in $HOME/.local/bin.
@scop scop marked this pull request as draft January 3, 2022 22:25
@scop
Copy link
Author

scop commented Jan 3, 2022

Please feel free to push to this branch to help complete it. WIP/things to consider at least:

  • Support for other OS's besides usual Unixy XDG ones
  • Relation to the existing other/non-standard ApplicationDirs
  • TODO comments in code

@adrg
Copy link
Owner

adrg commented Jan 4, 2022

Hi @scop. Thank you for the PR.

I've been thinking of defining an ExecutableHome directory too. Maybe ExecutableDirs as well, which would contain the paths in the $PATH environment variable (maybe adding ~/bin too if not already there), with sensible defaults. Not sure how useful would that be, but it would mimic the usual pair-like behavior of other XDG base directories (XDG_DATA_HOME and XDG_DATA_DIRS), even though there are no standard environment variables for this.

I'm trying to find a suitable equivalent for Windows. I wasn't able to find anything similar among the Windows Known Folders. For Plan 9, ExecutableHome would probably be $home/bin. For macOS, it could be ~/.local/bin although I'm not really sure that's the best practice.

@scop
Copy link
Author

scop commented Jan 4, 2022

I'd steer clear from adding anything to ExecutableDirs that aren't dirs from which executables without a path are searched from. They don't work the way it's reasonable to assume they would based on the name. Then again that's something one could say about ~/.local/bin too -- if it's not in $PATH, then dropping an executable there doesn't make it available for running without giving a path to it.

But that's actually one use case for ExecutableDirs: something installing an executable to ExecutableHome could check that the dir is in ExecutableDirs and emit a warning if not.

BTW, ISTR Windows has some other mechanisms besides the PATH envvar for locating pathless executables. Maybe it searches implicitly from the current working dir first? And maybe there was some other set of dirs configured in the registry in addition to the current working dir and the PATH envvar? I'm unable to locate a reference, but those would be fine additions to ExecutableDirs.

@scop
Copy link
Author

scop commented Jan 4, 2022

Ah, found a useful looking reference: https://docs.microsoft.com/en-gb/windows/win32/shell/app-registration#finding-an-application-executable

"App Paths" doesn't seem like something that would fit in the concept of ExecutableDirs though. But the current working dir and the Windows and Windows\System32 dirs would.

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

Successfully merging this pull request may close these issues.

None yet

2 participants