devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Flutter Devtools create file in my $HOME and don't allow for relocation

Open bartekpacia opened this issue 1 year ago • 7 comments

In my home directory the following directory is created whenever I use devtools:

$ tree -a ~/.flutter-devtools
/Users/bartek/.flutter-devtools
└── .devtools

Content of that single file is:

$ cat ~/.flutter-devtools/.devtools
{
  "analyticsEnabled": true,
  "isFirstRun": false,
  "lastReleaseNotesVersion": "2.31.0",
  "2023-Q4": {
    "surveyActionTaken": false,
    "surveyShownCount": 0
  }
}

I don't like when programs clutter my personal ~. I very much echo sentiment of this article. Unfortunately it looks like the location of that file is currently hardcoded (example).

Therefore I'd like for Flutter DevTools to respect XDG Base Directory Specification, so that the .devtools file could be stored in (e.g.) ~/.local/state, that is, $XDG_STATE_HOME.

To support migration, Flutter Devtools would continue to use ~/.flutter-devtools/.devtools if it exists. If it does not exist, it should default to the appropriate XDG base directory.

I am willing to contribute this feature, if only the maintainers of this project agree with this suggestion.

bartekpacia avatar Mar 14 '24 22:03 bartekpacia

My concern with changing the location of the .flutter-devtools/.devtools file is that it would not be consistent with what Flutter does for the .flutter file and the .flutter_tool_state file. These all live in the home directory:

Screenshot 2024-03-18 at 8 57 12 AM

@christopherfujino have there been any discussions around the location of the .flutter and .flutter_tool_state files WRT to not using the user's home directory? For DevTools, I think we should defer to the pattern that Flutter uses.

kenzieschmoll avatar Mar 18 '24 15:03 kenzieschmoll

I'll risk a statement that Flutter is also doing the wrong thing with not respecting XDG Base Directory Specification – see https://github.com/flutter/flutter/issues/59430. Ditto for Dart – see https://github.com/dart-lang/sdk/issues/41560.

I had some spare time recently and spent it cleaning up my (sweet sweet) $HOME, and now I'm sad to say that the majority of unwanted files I have in my ~ right now come from either Flutter or Dart.

bartekpacia avatar Mar 18 '24 18:03 bartekpacia

My concern with changing the location of the .flutter-devtools/.devtools file is that it would not be consistent with what Flutter does for the .flutter file and the .flutter_tool_state file. These all live in the home directory:

Screenshot 2024-03-18 at 8 57 12 AM

@christopherfujino have there been any discussions around the location of the .flutter and .flutter_tool_state files WRT to not using the user's home directory? For DevTools, I think we should defer to the pattern that Flutter uses.

not that I'm aware of. I'm not against changing this, if we could come into alignment. I would just add, however, that while XDG is a nice idea, my current debian installation doesn't have $XDG_STATE_HOME set. Also, my understanding is that Windows and macOS don't follow XDG at all. That is to say, this migration would principally be of benefit to those Linux users who happened to have $XDG_STATE_HOME set.

christopherfujino avatar Mar 19 '24 21:03 christopherfujino

anecdotal argument: I am on macOS and chose to follow XDG (=set the env vars) to keep my home dir clean :-)

bartekpacia avatar Mar 19 '24 21:03 bartekpacia

anecdotal argument: I am on macOS and chose to follow XDG (=set the env vars) to keep my home dir clean :-)

ok, but by that argument, we could name the variable $FOO_BAR and you would be happy, right?

christopherfujino avatar Mar 19 '24 21:03 christopherfujino

yeah I guess?

Anyway

if we could come into alignment

I'm all for that. I guess backward compatibility is the main concern, right?

bartekpacia avatar Mar 19 '24 21:03 bartekpacia

polite ping :)

  • an additional env var called e.g. FLUTTER_DEVTOOLS_STATE_HOME could be introduced into devtools, or
  • devtools could start respecting XDG_STATE_HOME

bartekpacia avatar Apr 05 '24 14:04 bartekpacia