Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

flutter pub get: flutter_lints any (authorization failed), version solving failed

ErrorBecause my_app depends on flutter_lints any which doesn't exist (authorization failed), version solving failed.

Short answer

Pub asked a package server for flutter_lints and the server refused it, so pub treats the package as missing. The server is not pub.dev when PUB_HOSTED_URL points to a mirror, or when a hosted entry names a private repository. Unset or correct that address, or add a valid token for the repository with dart pub token add.

  • Applies to Flutter 3.35, Dart 3.9
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the pub server address your shell gives pub, and look for hosted entries in pubspec.yaml.

    echo "PUB_HOSTED_URL=$PUB_HOSTED_URL"
    grep -n -B1 -A3 "hosted" pubspec.yaml
  2. 2Match what you see, then jump to its fix

    1. 1echo shows a value that is not https://pub.dev, often from a shell profile or a CI setting.PUB_HOSTED_URL points at a mirror or private serverFix
    2. 2The hosted URL in pubspec.yaml or in PUB_HOSTED_URL is a private repository that asks for authentication.The repository needs a token and pub has none storedFix
    3. 3The pubspec entry for flutter_lints has a hosted: block with a custom url.flutter_lints is declared with a hosted URL that is not pub.devFix

What does the error look like?

  • Because my_app depends on flutter_lints any which doesn't exist (authorization failed), version solving failed.
  • version solving failed

Cause 1 of 3

PUB_HOSTED_URL points at a mirror or private server

1Check

PUB_HOSTED_URL changes where pub downloads dependencies. A mirror that needs a login or lacks the package answers with a refusal, and pub reports it as missing.

env | grep PUB_
grep -n PUB_HOSTED_URL ~/.zshrc ~/.bashrc ~/.profile 2>/dev/null

2Fix

Unset the variable for this shell, or point it at a mirror that works. Remove the line from the profile if you no longer need the mirror.

unset PUB_HOSTED_URL
flutter pub get

3Verify

pub get resolves flutter_lints from pub.dev.

flutter pub get

Confirmed by dart.dev

Did this fix it?

Cause 2 of 3

The repository needs a token and pub has none stored

1Check

Pub sends requests without authentication when it has no token for a repository URL. A repository that wants a token then refuses the request.

grep -n -B2 -A3 "hosted" pubspec.yaml

2Fix

Add the token for that exact repository URL. Pub prompts for the secret. In CI use the env-var form so the secret is not saved.

dart pub token add https://dart-packages.example.com
# CI: read the secret from an environment variable
dart pub token add https://dart-packages.example.com --env-var MY_SECRET_TOKEN

3Verify

Run pub get again.

dart pub get

Confirmed by dart.dev

Did this fix it?

Cause 3 of 3

flutter_lints is declared with a hosted URL that is not pub.dev

1Check

A hosted dependency names its repository in pubspec.yaml. If the URL there is wrong or private, pub asks that server and not pub.dev.

grep -n -A4 "flutter_lints" pubspec.yaml

2Fix

Use the plain version form for packages on pub.dev.

dev_dependencies:
  flutter_lints: any # or the version shown on pub.dev

3Verify

Resolve the dependencies again.

flutter pub get

Confirmed by dart.dev

Did this fix it?

How do I stop it coming back?

  • Keep mirror settings in one documented place, and say so in the project README.
  • Use the --env-var form for tokens on CI instead of a stored secret.
  • Check the flutter_lints version on pub.dev before copying a constraint from an old project.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.