ruby-build
ruby-build copied to clipboard
bin/ruby-build: support DESTDIR setting
We can't just use MAKE_INSTALL_OPTS because DESTDIR modifies the location of the installed ruby binary, so anything that used the old RUBY_BIN also failed - it needed to be modified as well.
Instead introduce a new variable that edits both RUBY_BIN and MAKE_INSTALL_OPTS if set.
Also edit LDFLAGS so we can find libruby.so in the DESTDIR for post-install checks.
Fixes #1415. Updates #413.
I've verified that this works on Linux installing to a temporary directory.
Here's the script I have currently...
install_ruby() {
set -x
local -r numcpu=$(grep -c ^processor /proc/cpuinfo)
if [[ "${numcpu}" == '' ]]; then
numcpu='1'
fi
pushd /tmp
git clone git://github.com/meterup/ruby-build.git
pushd ruby-build
PREFIX="${2}" "./install.sh"
# https://github.com/rbenv/ruby-build#custom-build-configuration
MAKE_OPTS="-j${numcpu}" DESTDIR="${3}" ruby-build "${1}" "${2}"
popd
popd
}
Another option would be to tell people using DESTDIR
that they're on their own and skip the post-install RUBY_BIN
verification steps. Then you wouldn't need to set RUBYLIB etc.
Another option would be to tell people using
DESTDIR
that they're on their own and skip the post-installRUBY_BIN
verification steps.
That sounds like a pretty good idea! Could you tell how much work would be involved in that compared to this PR?
Oh... basically it would be to just add a bit before every invocation of RUBY_BIN (for example verify_config) that skips running the command if DESTDIR is set.
Another issue with this patch I am noticing now that 2.7.1 has been released:
This patch sets RUBYLIB to e.g.
$DESTDIR/usr/local/lib/ruby/2.7.1:$DESTDIR/usr/local/lib/ruby/2.7.1/x86_64-linux
However, Ruby installs the directories for 2.7.1 to $DESTDIR/usr/local/lib/ruby/2.7.0
. So this patch is looking in the wrong place.
This also unfortunately means we need some kind of logic for getting the base patch version (2.7.0) from the updated patch version (2.7.1), which I don't think we currently have in the bash script.
The 2.7.1 issue should be fixed now.
Thank you for your contribution, but see https://github.com/rbenv/ruby-build/issues/1415#issuecomment-1257277411 🙇