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

Adhere to XDG base directory spec #41560

Open
retnikt opened this issue Apr 18, 2020 · 14 comments · Fixed by dart-lang/cli_util#66
Open

Adhere to XDG base directory spec #41560

retnikt opened this issue Apr 18, 2020 · 14 comments · Fixed by dart-lang/cli_util#66
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). type-question A question about expected behavior or functionality

Comments

@retnikt
Copy link

retnikt commented Apr 18, 2020

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).

  • Dart SDK Version (dart --version) = 2.7.2
  • Applies to Linux only
@devoncarew devoncarew added area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). type-question A question about expected behavior or functionality labels Apr 19, 2020
@devoncarew
Copy link
Member

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
Copy link
Member

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
Copy link
Member

kevmoo commented Apr 19, 2020 via email

@kevmoo
Copy link
Member

kevmoo commented Apr 20, 2020

@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
Copy link
Member

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

@retnikt
Copy link
Author

retnikt commented Apr 21, 2020

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

They include:

  • git
  • KDE
  • GTK
  • LibreOffice
  • NeoVim

To name some of the more notable ones

@hildebro
Copy link

Any update on the priority of this issue?

@Jaakkonen
Copy link

Jaakkonen commented Dec 21, 2020

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:

  • conf_dir = (env["XDG_CONFIG_HOME"] || env["HOME"]+"/.config")+"/dart"
  • If conf_dir/CONFFILE exists, use it
  • Else check if old file exists and use it
  • Else (neither files exist) create default file to conf_dir.

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: flutter/flutter#59430
It'd be nice to have it in dart too :)

@Surendrajat
Copy link

Any update on this one? Is it being considered?

@jiampong212
Copy link

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
Copy link
Member

jonasfj commented Sep 14, 2021

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

  • On Linux (see XDG specification)
    • If $XDG_CONFIG_HOME is defined:
      • $XDG_CONFIG_HOME/dart/
    • else
      • $HOME/.config/dart/
  • On Mac OS (see developer.apple.com):
    • ~/Library/Application Support/dart/
  • On Windows:
    • %APPDATA%/dart/

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

@mraleph
Copy link
Member

mraleph commented Sep 17, 2021

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

@jonasfj
Copy link
Member

jonasfj commented Sep 17, 2021

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

@Zweisamkeiten
Copy link

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

4e554c4c added a commit to 4e554c4c/dart_cli_util that referenced this issue Dec 15, 2023
4e554c4c added a commit to 4e554c4c/dart_cli_util that referenced this issue Dec 15, 2023
This should be used to eventually fix dart-lang/sdk#41560.

See dart-lang/sdk#49166 (comment)

Test plan:
```
$ dart test
00:00 +4: All tests passed!
```
run `dart doc` and inspect docs for correctness.
4e554c4c added a commit to 4e554c4c/dart_cli_util that referenced this issue Dec 15, 2023
This should be used to eventually fix dart-lang/sdk#41560.

See dart-lang/sdk#49166 (comment)

Test plan:
```
$ dart test
00:01 +16: All tests passed!
```
run `dart doc` and inspect docs for correctness.
4e554c4c added a commit to 4e554c4c/dart_cli_util that referenced this issue Dec 15, 2023
This should be used to eventually fix dart-lang/sdk#41560.

See dart-lang/sdk#49166 (comment)

Test plan:
```
$ dart test
00:01 +16: All tests passed!
```
run `dart doc` and inspect docs for correctness.
4e554c4c added a commit to 4e554c4c/dart_cli_util that referenced this issue Dec 15, 2023
This should be used to eventually fix dart-lang/sdk#41560.

See dart-lang/sdk#49166 (comment)

Test plan:
```
$ dart test
00:01 +16: All tests passed!
```
run `dart doc` and inspect docs for correctness.
StaticRocket added a commit to StaticRocket/meta-flutter that referenced this issue Apr 27, 2024
Pull the dart and flutter configs by overriding the XDG_CONFIG_HOME and
HOME directories as necessary.

These hacks are required as dart and flutter currently only loosely
respect the XDG Base Directory Specification and do not provide a proper
mechanism for overriding the config file locations [1] [2].

[1] dart-lang/sdk#41560
[2] flutter/flutter#59430

Signed-off-by: Randolph Sapp <rs@ti.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). type-question A question about expected behavior or functionality
Projects
None yet