-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Follow XDG Base Directory Specification #1678
Comments
FWIW, this is not how this is not exactly how the XDG base-dir spec works.
So the directory layout mapping should look like the following:
In addition, globally installed modules should go in |
Good catch! I would also add that since the project is not yet 1.0, it's important to implement these breaking changes sooner or schedule them before 1.0 to mitigate the impact to the early adopters who can expect to see these sorts of breaking changes. |
I noticed the banner for 1.0 launching September 7th, very cool! However I wanted to re-emphasize that adherence to XDGBDS should probably happen before or in 1.0 to avoid delaying the breaking changes to a future X.0 release and impacting a larger audience or other projects that might use the |
Just another note on this: For example, https://github.com/oven-sh/bun/blob/b93f304c063698ada698eddc4321c5c7010e5e5d/src/install/install.zig uses This is unusual, in that I have yet to see see any other program use a I personally show all hidden files and folder, so this is not really an issue for me, but I think it's an opportunity to reduce the potential for surprise if these paths are revisited. |
… var is set). This addresses the comment at oven-sh#1678 (comment) > … I have yet to see see any other program use a `.` prefix for folders > *inside* the XDG convention folders. This may cause the folder to be > unexpectedly hidden when viewing it in a file explorer app or running > `ls` without `-a`. (That is, someone may expect `~/.cache` to be > hidden — but that all folders are visible once they are viewing that > hidden folder.) The only previous workaround would have been to set `$BUN_INSTALL`, but that affects more than the cache directory. (And people who have been using `$XDG_CACHE_HOME` presumably want to opt into the convention that all cache directories are grouped into a single place that is easy to audit and clean, separate from all config data.) Since this: - only affects the subset of users who have explictly opted into `$XDG_CACHE_HOME`, and - only affects cache data, which is meant to be safe to abandon/lose at any moment, … it shouldn't be harmful to leave the old directory lying around and allow a new one to be created. But it would also be possible to move the existing directory with an additional change.
This addresses the comment at oven-sh#1678 (comment) > … I have yet to see see any other program use a `.` prefix for folders > *inside* the XDG convention folders. This may cause the folder to be > unexpectedly hidden when viewing it in a file explorer app or running > `ls` without `-a`. (That is, someone may expect `~/.cache` to be > hidden — but that all folders are visible once they are viewing that > hidden folder.) The only previous workaround would have been to set `$BUN_INSTALL`, but that affects more than the cache directory. (And people who have been using `$XDG_CACHE_HOME` presumably want to opt into the convention that all cache directories are grouped into a single place that is easy to audit and clean, separate from all config data.) Since this: - only affects the subset of users who have explictly opted into `$XDG_CACHE_HOME`, and - only affects cache data, which is meant to be safe to abandon/lose at any moment, … it shouldn't be harmful to leave the old directory lying around and allow a new one to be created. But it would also be possible to move the existing directory with an additional change.
… var is set). This addresses the comment at oven-sh#1678 (comment) > … I have yet to see see any other program use a `.` prefix for folders > *inside* the XDG convention folders. This may cause the folder to be > unexpectedly hidden when viewing it in a file explorer app or running > `ls` without `-a`. (That is, someone may expect `~/.cache` to be > hidden — but that all folders are visible once they are viewing that > hidden folder.) The only previous workaround would have been to set `$BUN_INSTALL`, but that affects more than the cache directory. (And people who have been using `$XDG_CACHE_HOME` presumably want to opt into the convention that all cache directories are grouped into a single place that is easy to audit and clean, separate from all config data.) Since this: - only affects the subset of users who have explictly opted into `$XDG_CACHE_HOME`, and - only affects cache data, which is meant to be safe to abandon/lose at any moment, … it shouldn't be harmful to leave the old directory lying around and allow a new one to be created. But it would also be possible to move the existing directory with an additional change.
I incorporated a change by @lgarron and also added to it in my PR. There was another place Edit: After catching up a bit, I think my proposed change is not a hard breaking change. It would invalidate some peoples' cache (because the cache would move) but I think it doesn't break anything critical. It's definitely looking like the kinda thing that's better to do sooner than later |
Based on some comments from @lgarron it seems like:
|
Workaround for anyone trying to defend their
Result:
|
@jtrv (OP)
Disagree with you as this behavior is still not specs compliant. Programs should use user's XDG envs if they are set and fall back to default values when they are not set. Program can still use user's This behavior I am talking about is described in document you are sourcing:
Could you please update description of the issue according to the spec? Software must not force users to define environment variables in order to keep their It's sad bun did not included this in 1.0 as now it's not as easy to implement with backward compatibility support. |
@ZerdoX-x thank you, I've updated the issue per ju1ius's comment as well |
I'm trying to shed light on this issue! Has there been any work towards this? |
(upd in post-install script) simplify part of the script + make it follow https://wiki.archlinux.org/title/XDG_Base_Directory https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html see - oven-sh/bun#12987 - oven-sh/bun#12990 - oven-sh/bun#1678
What is the problem this feature would solve?
The
.bun/
directory unnecessarily pollute users'$HOME
directory.Related: #696, #965
What is the feature you are proposing to solve the problem?
The XDGBDS defines where these files should be placed with environment variables to avoid polluting the
$HOME
directory.From the XDGBDS:
Implementing XDGBDS should work as follows:
IF a corresponding XDG environment variable exists THEN use it's location according to the spec.
ELSE If the corresponding XDG_* env var is not defined, the program must fallback to the specified defaults:
So the default/fallback directory layout mapping should be:
In addition, globally installed modules should go in
~/.local/lib/node_modules
, with binaries symlinked under~/.local/bin
(which is what npm does).What alternatives have you considered?
We can also fallback to the
.bun
directory for backwards compatibility but as others have mentioned below this is not ideal and not part of the XDGBDS.The other alternative is to let all programs arbitrarily use the
$HOME
directory and create their own structure and organization for cache, data, config, etc. This is not optimal for any system with more than a few programs installed, which is why the XDGBDS exists to keep your system organized and easily navigable.(Edited per ju1ius, ZerdoX-x)
The text was updated successfully, but these errors were encountered: