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

Option to treat PUB_HOSTED_URL as a replacement of pub.dev #2993

Open
kmod-midori opened this issue May 12, 2021 · 4 comments
Open

Option to treat PUB_HOSTED_URL as a replacement of pub.dev #2993

kmod-midori opened this issue May 12, 2021 · 4 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@kmod-midori
Copy link

The majority of our team work in China, so we need PUB_HOSTED_URL=https://pub.flutter-io.cn otherwise pub get can take forever. Some even have different mirror configuration. However, some of our members and our CI service are not located in China, they sometimes can not even connect to the mirror.

The problem is, this URL ends up being written in pubspec.lock and is updated every time a different member works on the project, quickly becoming noisy. Currently we are ignoring pubspec.lock from our repository, but it is far from ideal. Is there any way around this?

@yujiuqie
Copy link

yujiuqie commented Oct 18, 2021

You can try this way

#2226 (comment)

@jonasfj
Copy link
Member

jonasfj commented Jan 3, 2022

Option to treat PUB_HOSTED_URL as a replacement of pub.dev

I think this a bad idea from a security perspective.

Maybe one day, we'll have package signing and protection from replay attacks, etc... then we can contemplate implementing support for actual mirrors. But all of this is non-trivial, I've been looking at things like https://theupdateframework.io/

A workaround might be to do a pre-commit hook that rewrites pubspec.lock or something like that.


It's also possible we should consider dropping the URL in pubspec.lock for packages from the default repository. This might be reasonable if we have content-hashes in pubspec.lock.

@kmod-midori
Copy link
Author

In addition to that, the CI pileline might rewrite the URLs with sed -i.

Git hooks would be fragile since we can not reject invalid commits on GitHub in the case the hooks fail to run or some new member/new machine forget to set that up (why isn't there some way to automatically configure that in 2022?). We also need something that works reliably across Windows/macOS/Linux.

Currently we are ignoring pubspec.lock in our repositories and hope for the best. This is not optimal and sometimes slow, but better than getting hit by network errors every time.

@kmod-midori
Copy link
Author

Having to use a mirror without some signing/verification in place is already unsafe, but let's face the reality that pub.dev is not reliably accessible in China.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants