What's the new location of credentials.json for dart/flutter pub

Viewed 410

I noticed that after switching to the beta channel (Flutter 2.9.0-0.1.pre), ~/.pub-cache/credentials.json no longer exists. I was using this file to set up CI jobs to deploy my Flutter packages. Where did it go?

1 Answers

Looks like it was moved to the following locations:

On Linux:

  • If $XDG_CONFIG_HOME is defined:
    • $XDG_CONFIG_HOME/dart/pub-credentials.json
  • else
    • $HOME/.config/dart/pub-credentials.json

On Mac OS:

  • ~/Library/Application Support/dart/pub-credentials.json

On Windows:

  • %APPDATA%/dart/pub-credentials.json

(Source: dart-lang/pub#2999 - Do not store credentials in PUB_CACHE)

(Relevant code: https://github.com/dart-lang/cli_util/blob/master/lib/cli_util.dart#L88)


On GitHub Actions, $XDG_CONFIG_HOME was defined, so I do the following:

- name: Prepare pub credentials
  run: echo '${{ secrets.PUB_CREDENTIALS }}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json"
Related