Monday, November 24, 2014

ruby-build Offline

ruby-build downloads package files via HTTP in many cases, not HTTPs. The integrity of package files is assured by including the sha256 checksums in the ruby-build git repository which is cloned via HTTPs and comparing them with the checksums of the downloaded files. This is problematic when something like Blue Coat gets in the way, requiring authentication for HTTP (but not necessarily for HTTPs). It occurred to me download the package files manually, using a web browser, and provide them to ruby-build. (I suppose it would be possible to get cURL and wget to authenticate by providing the right environment variables or configuration file elements, too.)
ruby-build supports this with the RUBY_BUILD_CACHE_PATH environment variable which may be set to the path of a directory containing package files. The ruby-build builtin definitions are composed of calls to functions in ruby-build, for instance install_package, a package name, a URI for the package, and other parameters for the call. Use the URIs to download the packages with a web browser, place them in a directory, and execute something like
sudo RUBY_BUILD_CACHE_PATH=/home/john/Downloads/ ruby-build 2.1.5 /usr/local/lib/ruby/2.1.5
Of course, skip the sudo if you’re building in home.
If a package checksum doesn't match, it seems that ruby-build continues without warning, attempting to download the package.
I would be surprised if this approach didn't work for ruby-build as a rbenv plugin, also.