Skip to content

Conversation

@uzxmx
Copy link
Contributor

@uzxmx uzxmx commented Jul 17, 2020

When using a mirror, ruby-build requires the package is located at $RUBY_BUILD_MIRROR_URL/<SHA2>, which is not a generic case.

Here list all mirror sites of ruby source, and most of them provide the tarball with name format like http://host/pub/ruby/2.7/2.7.1.tar.bz2. To benefit from more mirror sites, and also keep compatibility, I propose adding another variable (which can be named as RUBY_BUILD_MIRROR_PACKAGE_URL) to specify the complete mirror URL. So a user can use it like this:

# I use `asdf` to manage versions, which depends on `ruby-build`. $ RUBY_BUILD_MIRROR_PACKAGE_URL=https://cache.ruby-china.com/pub/ruby/2.7/ruby-2.7.1.tar.bz2 asdf install ruby 2.7.1 

Fix #1032. As this comment said, the download speed in China is too slow when installing a new version from official ruby CDN, so at least this feature will be especially useful for users living in China.

Signed-off-by: Mingxiang Xue <mingxiangxue@gmail.com>
@jasonkarns
Copy link
Member

Fwiw, node-build had this same limitation and we solved it by adding a new env var "NODE-BUILD-MIRROR-CMD" which defines a user-provided command that will generate a mirror url when given the package name and checksum.

https://github.com/nodenv/node-build/blob/3c0318da0dd975420653d1cf8e14578a8709bd3b/bin/node-build#L473

This allows users full control over how mirror urls are constructed. It may be a feature worth up streaming into ruby-build.

@uzxmx
Copy link
Contributor Author

uzxmx commented Jul 20, 2020

@jasonkarns I considered the *_MIRROR_CMD mechanism you mentioned in #1032. I agree *_MIRROR_CMD will be the best way to allows users full control over how mirror urls are constructed. But I have two concerns:

  • Less straightforward than a simple variable that just specifies the final url. To use *_MIRROR_CMD, it needs either we export a function, or we write a simple script to print the final url.
  • I'm a bit worried that some kinds of user mistakes may lead to bad things. Because it just executes whatever a user feeds.

So I think a simple variable is enough to satisfy all the cases.

Anyway, if you or other members prefer *_MIRROR_CMD way, I also vote for it.

@jasonkarns
Copy link
Member

  • Less straightforward than a simple variable that just specifies the final url. To use *_MIRROR_CMD, it needs either we export a function, or we write a simple script to print the final url.

Yep, I agree it's not super simple. The downside with a variable containing the full URL is that users would need to construct that URL for each ruby they install. The _CMD approach allows a one-time setup that works for future ruby installs as well. I'd say the using a full URL env var would be easy, but not necessarily "simple".

It's also worth noting that the _CMD approach and the "full URL" approach are not mutually exclusive. We could support both so users have a choice for whichever suits their needs. I'd like some other maintainers to weigh in before proceeding with a PR.

@uzxmx
Copy link
Contributor Author

uzxmx commented Jul 21, 2020

users would need to construct that URL for each ruby they install. The _CMD approach allows a one-time setup that works for future ruby installs as well.

Totally agree.

It's also worth noting that the _CMD approach and the "full URL" approach are not mutually exclusive. We could support both so users have a choice for whichever suits their needs. I'd like some other maintainers to weigh in before proceeding with a PR.

Thanks. Waiting for your and other maintainers' further feedbacks.

@uzxmx
Copy link
Contributor Author

uzxmx commented Oct 13, 2020

@hsbt Sorry to ping you. Can you help to make progress on this issue? Really want to have another strategy to specify the mirror.

@jasonkarns I found another fix for this similar issue in python-build, which was merged several days ago. It uses PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM to "skip" the checksum.

@hsbt
Copy link
Member

hsbt commented Dec 3, 2020

@uzxmx Sorry, too late response. I knew the situation of Ruby in China. I believe this option helps Ruby users in China.

@hsbt hsbt merged commit 99f6bcb into rbenv:master Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants