I have this package hosted on JetBrains Space:
name: my_package
description: Description of my package
version: 1.0.0
homepage: https://www.mywebsite.com
publish_to: https://dart.pkg.jetbrains.space/path/to/my/repo
environment:
sdk: ^3.1.0
dependencies:
glob: ^2.1.2
I did the following:
dart pub token add https://dart.pkg.jetbrains.space/path/to/my/repo
and entered the secretexport PUB_HOSTED_URL=https://dart.pkg.jetbrains.space/path/to/my/repo
(override the default pub.dev repo)dart pub global activate my_package
and it fails with:
Because every version of my_package depends on glob any which doesn't exist (could not find package glob at
https://dart.pkg.jetbrains.space/path/to/my/repo/), my_package is forbidden.
So, because pub global activate depends on my_package any, version solving failed.
Of course it doesn't find glob
because I have configured dart pub
to fetch on my private repo. But what I'm supposed to do? Re-hosting glob
and all its transient dependencies? There must be a better way.
According to https://dart.dev/tools/pub/custom-package-repositories#retrieving-dependencies-from-a-custom-package-repository, I believe that you can explicitly specify the host URL for each dependent package with the
hosted:
property. For example:Alternatively, if your private package doesn't need to be a dependency for anything else, you could consider instead publishing it to a private Git repository and avoid using
PUB_HOSTED_URL
entirely.