Error installing Ruby with rvm: "__rvm_make -j8"
Asked Answered
M

2

17

I was trying to install latest stable Ruby versions (3.1.x, 3.2.x) using rvm. However, the rvm install command of any of those versions fails when compiling Ruby. For instance, when trying to run

rvm install 3.1.4

I get the following output:

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/13.5/arm64/ruby-3.1.4.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating certificates bundle '/opt/homebrew/etc/[email protected]/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/davidlj95/.rvm/rubies/ruby-3.1.4, this may take a while depending on your cpu(s)...
ruby-3.1.4 - #downloading ruby-3.1.4, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.9M  100 19.9M    0     0  12.8M      0  0:00:01  0:00:01 --:--:-- 12.8M
No checksum for downloaded archive, recording checksum in user configuration.
/Users/davidlj95/.rvm/tmp/rvm_src_74481
ruby-3.1.4 - #extracting ruby-3.1.4 to /Users/davidlj95/.rvm/src/ruby-3.1.4 - please wait
ruby-3.1.4 - #configuring - please wait
ruby-3.1.4 - #post-configuration - please wait
ruby-3.1.4 - #compiling - please wait
Error running '__rvm_make -j8',
please read /Users/davidlj95/.rvm/log/1692282742_ruby-3.1.4/make.log

There has been an error while running make. Halting the installation.

Looked for errors in the file with less -p error /Users/davidlj95/.rvm/log/1692282742_ruby-3.1.4/make.log.

Seems the last error appearing before failing is related to OpenSSL:

ossl_ts.c:829:5: error: incomplete definition of type 'struct TS_verify_ctx'
    TS_VERIFY_CTX_set_certs(ctx, x509inter);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ...
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2
+__rvm_make:0> return 2
1 warning and 1 error generated.

I am using an M1 / ARM chipset MacBook Pro. With macOS Ventura 13.5.

I've tried:

  • Installing latest version appearing in rvm list known: 3.0.0. It fails too.
  • Going to the path where Ruby source code has been extracted and run make -j8. Fails because of same reason.
  • brew install [email protected] after seeing you may need an older version of OpenSSL to build Ruby. It was already installed. No luck either.
  • Ensuring the location of OpenSSL appearing in Makefile exists
  • Install latest version of OpenSSL: brew install openssl@3. No luck either.
Marabelle answered 17/8, 2023 at 14:56 Comment(2)
See #37337073Snowslide
It worked too, thanks! Didn't came across that post when had the issue :( I still prefer Ruby build guide suggestion though, so you can pick everything from brew if possible. I've seen other posts where libyaml fails. So looks like configuring everything to come from brew could give better results in the general caseMarabelle
M
43

As the Ruby build guide suggests, export the configuration arguments environment variable for the pre-compilation step indicating where libraries installed by Homebrew are installed. You can do so by running:

export CONFIGURE_ARGS=""
for ext in openssl readline libyaml zlib; do 
  CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-$ext-dir=$(brew --prefix $ext)" 
done

Then, run the rvm install command. Compilation succeeded and that Ruby version was installed. Worked for several Ruby versions.

Marabelle answered 17/8, 2023 at 14:57 Comment(5)
do you put that in your .zshrc? and keep it there?Corves
I don't install Ruby often so honestly I just go here and copy/paste this before the rvm install everytime. Placing that in .zshrc feels a bit dirty, as other software may pick the CONFIGURE_ARGS environment variable and fail because of the value in there. If you use this often, maybe you could add an alias in your .zshrc though. Like: alias rvm-preinstall=export CONFIGURE_ARGS=""; for ext.... Then, run rvm-preinstall before installing with rvm installMarabelle
Coming back to it, again and again is very annoying, as obv one can't remember when installing after monthsManatee
@Marabelle That's a good idea to put that in .zshrc, but it seems that aliases cannot handle multi-line commands directly. We can define a function in zshrc rvm-preinstall() { export CONFIGURE_ARGS="" for ext in openssl readline libyaml zlib; do CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-$ext-dir=$(brew --prefix $ext)" done }Sulfurous
Hmm can be done with an alias if you add ";" to separate commands. Here's how it would look like: alias rvm-preinstall='export CONFIGURE_ARGS=""; for ext in openssl readline libyaml zlib; do CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-$ext-dir=$(brew --prefix $ext)"; done'. Notice also usage of ' when defining the alias to avoid shell from interpreting special charactersMarabelle
M
0

For old Ruby versions, the other answer wasn't enough. Used ruby-build which tries to take into account all those compilation caveats.

For instance, if installing 3.0.x or older, OpenSSL < 3.0 (1.1) is required

In order to let rvm know about the Ruby built with ruby-build, you can install it into rvm's path:

export v2install=2.5.3
ruby-build $v2install $rvm_path/rubies/ruby-$v2install

💡 As explained in ruby-build, ensure that you have installed the dependencies needed to build Ruby first

Now you can use it with rvm as usual:

rvm list
   ruby-2.5.3 [ broken ]
=* ruby-3.2.2 [ arm64 ]

It appears as broken, but it works anyway

Reason of appearing as broken is because it can't get the CPU arch. ruby-build built the Ruby in another directory and installed it in rvm directory so rvm is aware of it. So compilation files with that rvm uses to read that metadata are not in that directory and therefore rvm can't display that info. It displays broken, but actually should be something like N/A

Using -k with ruby-build to keep source files doesn't work either. rvm reads files generated as part of compilation, which aren't technically source files

Moar caveats: Using ruby-build fixed OpenSSL error but in my case another error appeared related to libffi:

closure.c:264:14: error: call to undeclared function 'ffi_prep_closure'; ISO C99 and later do not support implicit function declarations [
-Wimplicit-function-declaration]
    result = ffi_prep_closure(pcl, cif, callback, (void *)self);

After a bit of searching, went with a workaround found in libffi's repo about this issue:

brew install libffi
export PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig"

And then running the ruby-build command stated above

Marabelle answered 12/6 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.