ruby-build icon indicating copy to clipboard operation
ruby-build copied to clipboard

bin/ruby-build: support DESTDIR setting

Open kevinburke1 opened this issue 4 years ago • 7 comments

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.

kevinburke1 avatar Mar 12 '20 04:03 kevinburke1

I've verified that this works on Linux installing to a temporary directory.

kevinburke1 avatar Mar 12 '20 04:03 kevinburke1

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
}

kevinburke1 avatar Mar 13 '20 17:03 kevinburke1

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.

kevinburke1 avatar Mar 13 '20 17:03 kevinburke1

Another option would be to tell people using DESTDIR that they're on their own and skip the post-install RUBY_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?

mislav avatar Mar 16 '20 13:03 mislav

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.

kevinburke1 avatar Mar 16 '20 17:03 kevinburke1

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.

kevinburke1 avatar Apr 24 '20 17:04 kevinburke1

The 2.7.1 issue should be fixed now.

kevinburke avatar Aug 03 '20 05:08 kevinburke

Thank you for your contribution, but see https://github.com/rbenv/ruby-build/issues/1415#issuecomment-1257277411 🙇

mislav avatar Sep 25 '22 20:09 mislav