rbenv install ruby BUILD FAILED - ruby

I'm quite new to rbenv let alone ruby and having some difficulty diagnosing the following installation failure:
rbenv install 2.0.0-p0
Downloading yaml-0.1.6.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/5fe00cda18ca5daeb43762b80c38e06e
Installing yaml-0.1.6...
Installed yaml-0.1.6 to /Users/Haani/.rbenv/versions/2.0.0-p0
Downloading ruby-2.0.0-p0.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/50d307c4dc9297ae59952527be4e755d
Installing ruby-2.0.0-p0...
BUILD FAILED
Inspect or clean up the working tree at /var/folders/50/wzjqg8d11sn7xnkrsmgr1gn80000gn/T/ruby-build.20140420110650.75863
Results logged to /var/folders/50/wzjqg8d11sn7xnkrsmgr1gn80000gn/T/ruby-build.20140420110650.75863.log
Last 10 log lines:
compiling ossl_x509cert.c
compiling ossl_x509crl.c
compiling ossl_x509ext.c
compiling ossl_x509name.c
compiling ossl_x509req.c
compiling ossl_x509revoked.c
compiling ossl_x509store.c
installing default openssl libraries
linking shared-object openssl.bundle
make: *** [build-ext] Error 2
See full log here

There seems to be a problem with the Homebrew package "readline".
brew uninstall readline
brew install https://raw.githubusercontent.com/Homebrew/homebrew/0181c8a1633353affefabe257c170edbd6d7c008/Library/Formula/readline.rb
brew pin readline
Then retry installing ruby with
rbenv install 2.0.0-p0
Answer found thanks to https://github.com/sstephenson/rbenv/issues/579#issuecomment-41122071

I needed to update my command line tools.
sudo rm -rf /Library/Developer/CommandLineTools
Then
sudo xcode-select --install

Related

rbenv and Apple m1. Failed installing ruby 3.2, 2.7 and 2.6

I can't install any ruby version with rbenv. I tried 2.6.10 2.7.7 or 3.2.0 .
This is the error I got when executing:
❯ rbenv install 3.2.0
To follow progress, use 'tail -f /var/folders/4v/kyv3nw1s7lq8s7lz7r6djvsr0000gn/T/ruby-build.20230125170342.85553.log' or pass --verbose
Downloading openssl-3.0.7.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e
Installing openssl-3.0.7...
Installed openssl-3.0.7 to /Users/idanahal/.rbenv/versions/3.2.0
Downloading ruby-3.2.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.gz
Installing ruby-3.2.0...
ruby-build: using readline from homebrew
ruby-build: using gmp from homebrew
BUILD FAILED (macOS 13.1 using ruby-build 20221225)
Inspect or clean up the working tree at /var/folders/4v/kyv3nw1s7lq8s7lz7r6djvsr0000gn/T/ruby-build.20230125170342.85553.VSOgmw
Results logged to /var/folders/4v/kyv3nw1s7lq8s7lz7r6djvsr0000gn/T/ruby-build.20230125170342.85553.log
Last 10 log lines:
compiling ossl_x509ext.c
compiling ossl_x509name.c
compiling ossl_x509req.c
compiling ossl_x509revoked.c
compiling ossl_x509store.c
installing default openssl libraries
linking shared-object date_core.bundle
linking shared-object openssl.bundle
linking shared-object ripper.bundle
make: *** [build-ext] Error 2
When installing with Homebrew it's working. I don't know what to do. Should rbenv even suppose to work with m1 computers?
I have MacOS 13.1
Setting the environment variable below solves the problem:
export RUBY_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-openssl-dir=$(brew --prefix openssl#1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml) --with-gdbm-dir=$(brew --prefix gdbm)"
before running rbenv install for all versions.
Note: The configuration --with-openssl-dir=$(brew --prefix openssl#1.1) is needed only for versions 2.6.* and 2.7.*. You can (and should) remove it if you are trying to install ruby 3.*.*.
For 2.6 and 2.7 sometimes this environment variable also needed:
export RUBY_CFLAGS="-Wno-error=implicit-function-declaration"
If all of the above didn't work, you can install ruby with Homebrew.
If you want to manage the Homebrew installed version from rbenv read this answer.

Failing to build Ruby 2.5.0 with rbenv and ruby-build on macOS Sierra

I tried to install ruby 2.5.0 with rbenv and ruby-build on macOS Sierra, but it failed and I got error messages as below:
$ rbenv install 2.5.0
Downloading openssl-1.1.0g.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/de4d501267da39310905cb6dc8c6121f7a2cad45a7707f76df828fe1b85073af
Installing openssl-1.1.0g...
Installed openssl-1.1.0g to /Users/hikaru/.rbenv/versions/2.5.0
Downloading ruby-2.5.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.bz2
Installing ruby-2.5.0...
BUILD FAILED (OS X 10.12.6 using ruby-build 20171226)
Inspect or clean up the working tree at
/var/folders/5q/dy9blchn6fq1_673pm0ybt0h0000gn/T/ruby-
build.20180102205530.13528
Results logged to /var/folders/5q/dy9blchn6fq1_673pm0ybt0h0000gn/T/ruby-build.20180102205530.13528.log
Last 10 log lines:
make[1]: *** Waiting for unfinished jobs....
installing default ripper libraries
compiling ancdata.c
compiling raddrinfo.c
compiling ifaddr.c
installing default socket libraries
linking shared-object zlib.bundle
linking shared-object socket.bundle
linking shared-object ripper.bundle
make: *** [build-ext] Error 2
I checked the log files and found the error below:
ossl_x509cert.c:334:59: error: member reference type 'int' is not a pointer
if (!i2a_ASN1_OBJECT(out, X509_get0_tbs_sigalg(x509)->algorithm)) {
~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
I have no idea why this error happens. I would appreciate it if you would explain how to solve this problem.
After then, I tried to rbenv install 2.5.0 with gcc provided by Xcode on macOS High Sierra, and same problem happened.
It works for me on the same OS. An issue in ruby-build that produced this error was reported and fixed recently.
Update rbenv and ruby-build
If you're getting them from git:
cd ~/.rbenv
git pull
cd plugins/ruby-build
git pull
If you're getting them from homebrew:
brew update
brew upgrade rbenv ruby-build
and try rbenv install 2.5.0 again.
If you're using rbenv & ruby-build homebrew, you could try using them from git.
I finally fixed this problem. When this problem happened, my rbenv treid to install ruby 2.5.0 using openssl-1.1.0g. This openssl was selected by rbenv and ruby-build.
In my environment, I installed openssl#1.0.2n_0 by MacPort. I selected this openssl to installing ruby 2.5.0 with rbenv and ruby-build.
$ rbenv versions
system
* 2.4.0
$ port installed | grep openssl
openssl #1.0.2n_0 (active)
$ RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/local --with-gdbm-dir=/opt/local" rbenv install -v 2.5.0
$ rbenv versions
system
* 2.4.0
2.5.0
When I did not use --with-gdbm-dir=/opt/local, I got the below message:
*** Following extensions are not compiled:
gdbm:
Could not be configured. It will not be installed.
Check ext/gdbm/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
use this to install ruby last version with rbenv
RUBY_CONFIGURE_OPTS="--disable-dtrace" rbenv install 2.5.1

Trying to install ruby 2.1.2 with rbenv on OSX BUILD FAILED

So, as the title suggests, I'm trying to install ruby 2.1.2, altough I've tried to install other versions as well, and I'm getting the same errors. I'm running OSX 10.9.2.
I've tried:
Installing a fresh gcc compiler, via brew install gcc47
Installing updated OSX command line tools
Uninstalling rbenv and trying again
Restarting the machine
Here is the sum of what I'm getting:
rbenv install 2.1.2
Downloading ruby-2.1.2.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/f22a6447811a81f3c808d1c2a5ce3b5f5f0955c68c9a749182feb4 25589e6635
Installing ruby-2.1.2...
BUILD FAILED
Inspect or clean up the working tree at /var/folders/6c/h_82199n12515_hd3rcp2x5w0000gn/T/ruby-build.20140528115901.38728
Results logged to /var/folders/6c/h_82199n12515_hd3rcp2x5w0000gn/T/ruby-build.20140528115901.38728.log
Last 10 log lines:
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
compiling miniinit.c
compiling miniprelude.c
translating probes probes.d
compiling bignum.c
compiling class.c
dtrace: failed to compile script probes.d: Preprocessor not found
make: *** [probes.h] Error 1
make: *** Waiting for unfinished jobs....
compiling compar.c
Thoughts?
Gist of verbose output
I was able to build it using:
CONFIGURE_OPTS="--disable-dtrace" rbenv install 2.1.2
Basically that's what is suggested in the question's comment by wicz.
The solution by KurtPreston did not work for me. Also using OS X 10.9.
I was able to get this working in my own environment by:
Removing the gcc installed by Homebrew: brew remove gcc47
Re-installing the XCode Command Line Tools from the XCode Downloads page at https://developer.apple.com/downloads
I was trying to install 2.0 and ran into the same error. However now the CONFIGURE_OPTIONS override doesn't seem to work anymore with rvm at least, so I needed to build it with rvm install --reconfigure -C --disable-dtrace ruby-2.0.0-p594. This was the first Google result off the error message ("dtrace: failed to compile script probes.d: Preprocessor not found") so I figured I should add this as a current solution for rvm users. Running on OSX Mavericks.
I cannot reproduce this on my machine, sorry. For reference, here's my dtrace version if that should have anything to do with the error:
dtrace -V
dtrace: Sun D 1.7
You can try to check for XCode and command line tools updates. GCC 4 should not be necessary, you can use the compiler that ships with XCode:
brew uninstall gcc4
Finally, update everything and try again:
brew update
brew upgrade rbenv ruby-build
rbenv uninstall 2.1.2
rbenv install 2.1.2
If that does not work yet: some people have reported that a simple reboot of the machine solved similar errors with dprobe/dtrace.

Missing the OpenSSL lib?

I have been trying to install ruby 2.1.1 but when I run it in the terminal, this is what i get:
$rbenv install 2.1.1
Downloading yaml-0.1.6.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/5fe00cda18ca5daeb43762b80c38e06e
Installing yaml-0.1.6...
Installed yaml-0.1.6 to /Users/nthulanemakgato/.rbenv/versions/2.1.1
Downloading ruby-2.1.1.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/e57fdbb8ed56e70c43f39c79da1654b2
Installing ruby-2.1.1...
BUILD FAILED
Inspect or clean up the working tree at /var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby-build.20140427221824.34053
Results logged to /var/folders/tj/_bd6whds6lb7wtn2m8ylwx7h0000gp/T/ruby- build.20140427221824.34053.log
Last 10 log lines:
io-console 0.4.2
json 1.8.1
minitest 4.7.5
psych 2.0.3
rake 10.1.0
rdoc 4.1.0
test-unit 2.1.1.0
installing rdoc: /Users/nthulanemakgato/.rbenv/versions/2.1.1/share/ri/2.1.0/system
installing capi-docs: /Users/nthulanemakgato/.rbenv/versions/2.1.1/share/doc/ruby
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?
So I went on Google, searched and tried a few things like:
$brew link openssl --force
Linking /usr/local/Cellar/openssl/1.0.1f... Warning: Could not link openssl. Unlinking...
then i tried
$ brew update
error: unable to unlink old '.gitignore' (Permission denied) error: unable to create file CODEOFCONDUCT.md (Permission denied) error: unable to unlink old 'CONTRIBUTING.md' (Permission denied) error: unable to create file LICENSE.txt (Permission denied) error: unable to unlink old 'README.md' (Permission denied) error: unable to unlink old 'SUPPORTERS.md' (Permission denied) Checking out files: 100% (1995/1995), done. Error: Failure while executing: git pull - q origin refs/heads/master:refs/remotes/origin/master
$ brew upgrade ruby-build
Error: ruby-build not installed
and,
$brew install openssl
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/openssl- 1.0.1g.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.1g.mavericks.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, so it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
The OpenSSL provided by OS X is too old for some software.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
Error: Failed to create: /usr/local/opt/openssl
Things that depend on openssl will probably not build.
==> Summary
🍺 /usr/local/Cellar/openssl/1.0.1g: 429 files, 15M
and lastly,
$sudo brew install openssl
Password:
Error: Cowardly refusing to `sudo brew install`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.
and a couple of other things like(which details I won't go into unless you think its necessary):
$CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" rbenv install 2.1.1
$CFLAGS='-g -O2' RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl` rbenv install 2.1.1
and both haven't worked.
I have installed xcode
I have an OS X 10.9.2.
Homebrew is installed.
OpenSSL 0.9.8y 5 Feb 2013
I don't understand what's going on and I have been struggling with this for a long time, please help.
Let me know if there is more information that you need in order to help and i'll happily provide it.
I found the answer to this challenge in another site.
$rbenv install --patch 2.1.1
then
$curl https://gist.githubusercontent.com/andschwa/11334511/raw/563d5c2efb869cafb0c65404d12243822bba2817/ruby-2.1.1-readline.patch | rbenv install --patch 2.1.1
I got this information from this link:
https://schwartzmeyer.com/2014/04/26/building-ruby-2-0-0-and-2-1-1-on-os-x/

Error Installing Jekyll on Mac OS Mavericks (10.9.2)

Trying to install stable version of Jekyll on OSX Mavericks. I have Xcode and the command line tools installed, yet I get this error:
sudo gem install jekyll
Password:
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling porter.c
porter.c:359:27: warning: '&&' within '||' [-Wlogical-op-parentheses]
if (a > 1 || a == 1 && !cvc(z, z->k - 1)) z->k--;
~~ ~~~~~~~^~~~~~~~~~~~~~~~~~~~
porter.c:359:27: note: place parentheses around the '&&' expression to silence this warning
if (a > 1 || a == 1 && !cvc(z, z->k - 1)) z->k--;
^
( )
1 warning generated.
compiling porter_wrap.c
linking shared-object stemmer.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [stemmer.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/fast-stemmer-1.0.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/fast-stemmer-1.0.2/gem_make.out
Your problem appeared with Xcode 5.1. In order to avoid many problems related to MacOS' ruby version (this one and many others), you really should use RVM.
If you don't already have it, install Homebrew first: (it is not absolutely necessary, but allows us to install ruby and its dependencies without a looong compilation)
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Then, the following command will install RVM and the last version of Ruby:
\curl -L https://get.rvm.io | bash -s stable --ruby
Check everything is OK:
ruby --version
You can now install Jekyll:
gem install jekyll
Now, if you really don't want to use RVM, you can execute:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install jekyll
But I bet further problems would come.
You should definitely use RVM. Here are the steps:
Uninstall any existing XCode by deleting XCode from Applications folder.
Install Homebrew.
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Follow additional instructions listed in Homebrew install.
brew doctor
Install RVM.
\curl -L https://get.rvm.io | bash -s stable --ruby
Follow additional instructions upon RVM installation.
source ~/.rvm/scripts/rvm
Install jekyll.
gem install jekyll
Test jekyll.
$ jekyll serve
Configuration file: none
Source: /private/var/log
Destination: /private/var/log/_site
Generating... done.
Server address: ...
Server running... press ctrl-c to stop.
1) xcode-select --install
2) brew install ruby
3) sudo gem install jekyll
4) sudo gem install jekyll-import

Resources