dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.23k stars 1.57k forks source link

Adhere to XDG base directory spec #41560

Open retnikt opened 4 years ago

retnikt commented 4 years ago

Currently, on Linux, Dart stores some data in ~/.dart and ~/.dartServer, which is annoying because it clutters up the user's home directory. Please consider following the XDG Base Directory spec by moving these files to appropriate locations specified in the environment variables $XDG_CONFIG_HOME, $XDG_DATA_HOME, and $XDG_CACHE_HOME. (typically, and by default, ~/.config, ~/.local/share, and ~/.cache).

devoncarew commented 4 years ago

I'm not aware of how widely used this XDG directory spec is. Following common pattens would be useful, if these are common patterns; I have not previously heard of this convention.

cc @kevmoo @bwilkerson @jonahwilliams for thoughts

bwilkerson commented 4 years ago

I hadn't heard of it either, but then it's well outside my wheelhouse. Personally I have no preference about where we store cached files.

kevmoo commented 4 years ago

https://maex.me/2019/12/the-power-of-the-xdg-base-directory-specification/

TIL

On Sun, Apr 19, 2020, 08:35 Brian Wilkerson notifications@github.com wrote:

I hadn't heard of it either, but then it's well outside my wheelhouse. Personally I have no preference about where we store cached files.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dart-lang/sdk/issues/41560#issuecomment-616164114, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEFCWHMJQA6BDHS7NACWLRNMK3NANCNFSM4MLHM7DA .

kevmoo commented 4 years ago

@devoncarew @bwilkerson – I'm a fan of following conventions and not dirtying up directories.

If at some point, if we want to entertain moving things around I'm not against this. 🤷

bwilkerson commented 4 years ago

I'm not against it either. The first question is how to prioritize this against the other work that needs to be done.

retnikt commented 4 years ago

Here is a partial list of applications that have adopted it: https://wiki.archlinux.org/index.php/XDG_Base_Directory#Supported

They include:

To name some of the more notable ones

hildebro commented 4 years ago

Any update on the priority of this issue?

Jaakkonen commented 3 years ago

The .dart folder is hard-coded in https://github.com/dart-lang/sdk/blob/master/pkg/dartdev/lib/src/analytics.dart and .dartServer in https://github.com/dart-lang/sdk/blob/master/pkg/analyzer/lib/file_system/physical_file_system.dart and https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/benchmark/benchmarks.dart These foldernames don't appear seem to appear elsewhere in the codebase so making a PR should be doable :) I think approaching this with following kind of implementation would be good:

Moving the conf file to the new location automatically is pretty nice too but will annoy some people using dotfile managers when their dotfiles have changed on their own.

For caching files, it's already possible to set pub to use other cache dir than ~/.pub-cache with PUB_CACHE environment variable. Logic here: https://github.com/dart-lang/sdk/blob/master/pkg/nnbd_migration/tool/src/package.dart#L32 I think this should use $XDG_CACHE_HOME/pub as default, $HOME/.cache/pub as 1st fallback (XDG default) and the $HOME/.pub-cache as 2nd fallback.

The XDG spec is being adopted in Flutter here: https://github.com/flutter/flutter/issues/59430 It'd be nice to have it in dart too :)

Surendrajat commented 3 years ago

Any update on this one? Is it being considered?

jiampong212 commented 3 years ago

any updates? The XDG convention makes it easier to organize files and not clutter the home directory. I know it may not be the top priority, but it would certainly help if you guys would implement it.

jonasfj commented 3 years ago

In dart pub we're moving all configuration files to:

Migration: If a config file exists in the new location we use it, otherwise we read config file from old location.

mraleph commented 3 years ago

@jonasfj did you mean to close the whole issue? I'd assume that analyzer also needs to change?

jonasfj commented 3 years ago

Nope, that was unintentional... I think GitHub just decided to close it :)

Zweisamkeiten commented 2 years ago

Hello, is there any progress? .dart is still in my $HOME. I have defined $XDG_CONFIG_HOME before. And it's a fresh install for dart. When i execute dart pub, .dart appears in my home.

❯ pwd
/home/einsam/.dart
❯ tree .
.
├── dartdev.json
└── README.txt

0 directories, 2 files
❯ echo $XDG_CONFIG_HOME
/home/einsam/.config