Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby installation fails in macOS Catalina #1409

Closed
dsoegijono opened this issue Mar 3, 2020 · 22 comments
Closed

Ruby installation fails in macOS Catalina #1409

dsoegijono opened this issue Mar 3, 2020 · 22 comments

Comments

@dsoegijono
Copy link

dsoegijono commented Mar 3, 2020

EDIT: Solution in comment below


I've seen the other issues #1408 #1394 #1395 but the error I'm experiencing is slightly different. This happens on any version of ruby I try to install.

$ rbenv install 2.7.0

Downloading openssl-1.1.1d.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2
Installing openssl-1.1.1d...

BUILD FAILED (OS X 10.15.3 using ruby-build 20200224)

Inspect or clean up the working tree at /var/folders/s4/6_9qvyzn6kvcd2lz2jm3y_fw0000gq/T/ruby-build.20200303110227.33296.Nfnu5g
Results logged to /var/folders/s4/6_9qvyzn6kvcd2lz2jm3y_fw0000gq/T/ruby-build.20200303110227.33296.log

Last 10 log lines:
include/openssl/crypto.h:341:33: error: unknown type name 'time_t'; did you mean 'size_t'?
struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
                                ^~~~~~
                                size_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_size_t.h:31:32: note: 'size_t' declared here
typedef __darwin_size_t        size_t;
                               ^
1 error generated.
make[1]: *** [apps/app_rand.o] Error 1
make: *** [all] Error 2

I've updated ruby-build and rbenv to the latest versions

@wadkar
Copy link

wadkar commented Mar 3, 2020

As I mentioned on the other issue try following:

$ brew install openssl
$ export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
$ rbenv install 2.7.8

It should work (not tested on Catalina).

@dsoegijono
Copy link
Author

A different error but it still failed to install

Downloading ruby-2.7.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0.tar.bz2
Installing ruby-2.7.0...
ruby-build: using readline from homebrew

BUILD FAILED (OS X 10.15.3 using ruby-build 20200224)

Inspect or clean up the working tree at /var/folders/s4/6_9qvyzn6kvcd2lz2jm3y_fw0000gq/T/ruby-build.20200304140824.35624.zDAaZW
Results logged to /var/folders/s4/6_9qvyzn6kvcd2lz2jm3y_fw0000gq/T/ruby-build.20200304140824.35624.log

Last 10 log lines:
        lzma_bool reserved_bool2;
        ^
/usr/local/include/Block.h:264:2: error: unknown type name 'lzma_bool'
        lzma_bool reserved_bool3;
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
compiling gc.c
20 errors generated.
make: *** [file.o] Error 1
make: *** Waiting for unfinished jobs....

@wadkar
Copy link

wadkar commented Mar 4, 2020

Huh, that's weird. Why don't you create a gist with your build log and post a link here?

I suspect you have stray headers in your /usr/local/include. What does brew doctor say? Search stack overflow and see if you can fix any complaints that it might throw and try again.

@mislav
Copy link
Member

mislav commented Mar 4, 2020

Also are your Xcode tools up to date? xcode-select --install

@tobius
Copy link

tobius commented Apr 17, 2020

I had this same issue with a recent install of Catalina and worked around it by ensuring that readline and openssl were both installed by homebrew and that my .zshrc was configured to include those libraries in my compiler flags.

First:

[~] brew install readline openssl

Then (via .zshrc):

# Setup Compiler paths for readline and openssl
local READLINE_PATH=$(brew --prefix readline)
local OPENSSL_PATH=$(brew --prefix openssl)
export LDFLAGS="-L$READLINE_PATH/lib -L$OPENSSL_PATH/lib"
export CPPFLAGS="-I$READLINE_PATH/include -I$OPENSSL_PATH/include"
export PKG_CONFIG_PATH="$READLINE_PATH/lib/pkgconfig:$OPENSSL_PATH/lib/pkgconfig"

# Use the OpenSSL from Homebrew instead of ruby-build
# Note: the Homebrew version gets updated, the ruby-build version doesn't
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$OPENSSL_PATH"

# Place openssl@1.1 at the beginning of your PATH (preempt system libs)
export PATH=$OPENSSL_PATH/bin:$PATH

# Load rbenv
eval "$(rbenv init -)"

# Extract the latest version of Ruby so you can do this:
# rbenv install $LATEST_RUBY_VERSION
export LATEST_RUBY_VERSION=$(rbenv install -l | grep -v - | tail -1)

Last:

[~] source .zshrc
[~] rbenv install $LATEST_RUBY_VERSION
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
ruby-build: using readline from homebrew
Installed ruby-2.7.1 to /Users/tobius/.rbenv/versions/2.7.1

@dsoegijono
Copy link
Author

Thank you @tobius, that worked perfectly

@jenksguo
Copy link

As I mentioned on the other issue try following:

$ brew install openssl
$ export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
$ rbenv install 2.7.8

It should work (not tested on Catalina).

works for Catalina 10.15.5 using bash

@studious
Copy link

@tobius is ruby-build supposed to announce that it is using home-brew readline? I can't get mine to print that regardless of the method used.

@DirtyF
Copy link
Contributor

DirtyF commented Dec 25, 2020

For what it's worth, the above solutions didn't work to install Ruby 3.0 on macOS 11.1

sw_vers
ProductName:	macOS
ProductVersion:	11.1
BuildVersion:	20C69

rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.0.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.2gn6ht
Results logged to /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.log

Last 10 log lines:
In file included from compile.c:39:
./vm_callinfo.h:217:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:95:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1
make: *** Waiting for unfinished jobs....

edit : Compilation succeeds with Xcode 12.3 and xcode-select version 2384 installed. ✅

rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew
Installed ruby-3.0.0 to /Users/frank/.rbenv/versions/3.0.0

@pftg
Copy link

pftg commented Dec 29, 2020

Updating of the command tools helped me:

sudo rm -rf /Library/Developer/CommandLineTools          
sudo xcode-select --install

@34code
Copy link

34code commented Dec 29, 2020

For what it's worth the above solutions didn't work to install Ruby 3.0 on macOS 11.01

rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.0.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.2gn6ht
Results logged to /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.log

Last 10 log lines:
In file included from compile.c:39:
./vm_callinfo.h:217:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:95:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1
make: *** Waiting for unfinished jobs....

same problem on OSX Catalina 10.15.7
error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'

@emschult
Copy link

@DirtyF
I have my macbook running 11.0.1

I was trying to following what you were doing to resolve your issue and was not sure what to do. Could you help? I am trying to get ruby 2.5.1 downloaded to do course work. I confirmed that Homebrew is installed, ruby-build is installed and so is rbenv. My issue is similar to yours. I am getting a failure:

WARNING: ruby-2.5.1 is nearing its end of life.
It only receives critical security updates, no bug fixes.

ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.0.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/8q/3_kkmpr9335_5lbl29t0tnfh0000gn/T/ruby-build.20210110201435.35535.fAL4k0
Results logged to /var/folders/8q/3_kkmpr9335_5lbl29t0tnfh0000gn/T/ruby-build.20210110201435.35535.log

Last 10 log lines:
3 warnings generated.
compiling ../.././ext/psych/yaml/reader.c
compiling ../.././ext/psych/yaml/emitter.c
compiling ../.././ext/psych/yaml/parser.c
5 warnings generated.
linking shared-object date_core.bundle
linking shared-object zlib.bundle
1 warning generated.
linking shared-object psych.bundle
make: *** [build-ext] Error 2

Do you know what I need to do? I have no clue how to change to " Compilation succeeds with Xcode 12.3 and xcode-select version 2384 installed. ✅"

@DirtyF
Copy link
Contributor

DirtyF commented Jan 12, 2021

@emschult

  1. Open a terminal
  2. Run xcode-select -v to check what version you're running (mine is currently 2384 on macOS 11.1).
  3. Run Ruby installation fails in macOS Catalina #1409 (comment) to see if it helps to install the latest CLI Tools
  4. Optional: Go to the App Store and install the latest XCode (12.3) if you can't get Ruby to compile. It should work with only the latest CLI tools though.

@emschult
Copy link

@DirtyF
I went ahead and upgraded to macOS 11.1 and checked that xcode was at 2384. Any idea what else might be the issue? This is what is showed me:

erikschulte@Eriks-MacBook-Pro ~ % xcode-select -v
xcode-select version 2384.
erikschulte@Eriks-MacBook-Pro ~ % rbenv install 2.5.1
Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/erikschulte/.rbenv/versions/2.5.1

Downloading ruby-2.5.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
Installing ruby-2.5.1...

WARNING: ruby-2.5.1 is nearing its end of life.
It only receives critical security updates, no bug fixes.

ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/8q/3_kkmpr9335_5lbl29t0tnfh0000gn/T/ruby-build.20210112120819.73940.BmgW0u
Results logged to /var/folders/8q/3_kkmpr9335_5lbl29t0tnfh0000gn/T/ruby-build.20210112120819.73940.log

Last 10 log lines:
compiling ../.././ext/psych/yaml/dumper.c
compiling ../.././ext/psych/yaml/reader.c
compiling ../.././ext/psych/yaml/emitter.c
compiling ../.././ext/psych/yaml/parser.c
5 warnings generated.
linking shared-object date_core.bundle
linking shared-object zlib.bundle
1 warning generated.
linking shared-object psych.bundle
make: *** [build-ext] Error 2

@romicaiarca
Copy link

@DirtyF
I went ahead and upgraded to macOS 11.1 and checked that xcode was at 2384. Any idea what else might be the issue? This is what is showed me:

erikschulte@Eriks-MacBook-Pro ~ % xcode-select -v
xcode-select version 2384.
erikschulte@Eriks-MacBook-Pro ~ % rbenv install 2.5.1
Downloading openssl-1.1.1i.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
Installing openssl-1.1.1i...
Installed openssl-1.1.1i to /Users/erikschulte/.rbenv/versions/2.5.1

Downloading ruby-2.5.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.bz2
Installing ruby-2.5.1...

WARNING: ruby-2.5.1 is nearing its end of life.
It only receives critical security updates, no bug fixes.

ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/8q/3_kkmpr9335_5lbl29t0tnfh0000gn/T/ruby-build.20210112120819.73940.BmgW0u
Results logged to /var/folders/8q/3_kkmpr9335_5lbl29t0tnfh0000gn/T/ruby-build.20210112120819.73940.log

Last 10 log lines:
compiling ../.././ext/psych/yaml/dumper.c
compiling ../.././ext/psych/yaml/reader.c
compiling ../.././ext/psych/yaml/emitter.c
compiling ../.././ext/psych/yaml/parser.c
5 warnings generated.
linking shared-object date_core.bundle
linking shared-object zlib.bundle
1 warning generated.
linking shared-object psych.bundle
make: *** [build-ext] Error 2

I have the same issue. If you find anything please post here.

@emschult
Copy link

@romicaiarca Hey man. What I ended up finding out is that 2.5.1 is not compatible with Big Sur or the M1 chip.

2.7.2+ is. I was able to download 2.7.2 and 3.0.0

see comments at: #1705

@romicaiarca
Copy link

Ok, thanks! It looks like this is not a solution for me. I need to install ruby 1.9.3 because I'm using capistrano 2 on one of my project and the client don't approve updating it.

@dubistdu
Copy link

dubistdu commented May 1, 2021

For what it's worth, the above solutions didn't work to install Ruby 3.0 on macOS 11.1

sw_vers
ProductName:	macOS
ProductVersion:	11.1
BuildVersion:	20C69

rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 11.0.1 using ruby-build 20201225)

Inspect or clean up the working tree at /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.2gn6ht
Results logged to /var/folders/sh/jqmw4djd1f7_5c2qr92cn1sw0000gn/T/ruby-build.20201225183431.58053.log

Last 10 log lines:
In file included from compile.c:39:
./vm_callinfo.h:217:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:95:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1
make: *** Waiting for unfinished jobs....

edit : Compilation succeeds with Xcode 12.3 and xcode-select version 2384 installed. ✅

rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
ruby-build: using readline from homebrew
Installed ruby-3.0.0 to /Users/frank/.rbenv/versions/3.0.0

You saved my day and my laptop(I was about to throw it across the room)

@misraelson
Copy link

For any beings from the future, use this command to install on M1 Mac (I'm using asdf but works for rbenv as well):
RUBY_CFLAGS="-Wno-error=implicit-function-declaration" asdf install ruby 2.5.1
via: Prabin Poudel
https://dev.to/truemark/fix-issue-while-installing-ruby-with-rbenv-in-m1-mac-3dfd

@34code
Copy link

34code commented Jun 19, 2021

i managed to work around this by using the homebrew gcc and symlinking it so that its picked up as the default compiler instead of the incompatible apple clang one.

@haejinjo
Copy link

haejinjo commented Dec 18, 2021

👏 bless you @pftg

That fix worked for me installing 2.7.5 on MacOS 12.0.1 Monterey after spending hours trying to reinstall ruby after messing up all my permissions/environment running sudo gem install bundler.

One thing to note is that my xcode-select version (2392) didn't change so I guess the reinstall alone did the trick.

@stevecondylios
Copy link

I was getting a similar problem when trying this on non m1 macbook:

rbenv install 3.1.1           
Downloading ruby-3.1.1.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.1.tar.gz
Installing ruby-3.1.1...
ruby-build: using readline from homebrew

BUILD FAILED (macOS 12.2.1 using ruby-build 20220218)

Inspect or clean up the working tree at /var/folders/44/81bh_1z97y5gknbwd84w4fqm0000gp/T/ruby-build.20220220193637.67378.eyJyHr
Results logged to /var/folders/44/81bh_1z97y5gknbwd84w4fqm0000gp/T/ruby-build.20220220193637.67378.log

Last 10 log lines:
                                                                       ^
In file included from compile.c:40:
./vm_callinfo.h:216:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:94:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1

After much fumbling about, the solution was these 2 things:

  1. brew update && brew upgrade ruby-build
  2. Open App Store -> xcode -> update

I did not set any environment variables (in fact, I had tried setting some based on helpful tips above and elsewhere, but even after the 2 steps above the install wouldn't succeed until I removed those extra environment variables.

Note I found all these steps by running brew doctor and starting with the most likely candidates. This was the bit that told me to update xcodebuild

Warning: Your Xcode (12.4) is too outdated.
Please update to Xcode 13.2.1 (or delete it).
Xcode can be updated from the App Store.

Hope it helps someone else.

@rbenv rbenv locked and limited conversation to collaborators Feb 20, 2022
@hsbt hsbt converted this issue into discussion #1938 Feb 20, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests