Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Comments on Installing Ruby on MacOS 12.2 (or 11.6) produces compilation errors in the downloaded source; how do I fix?

Post

Installing Ruby on MacOS 12.2 (or 11.6) produces compilation errors in the downloaded source; how do I fix?

+5
−0

A project I want to work on requires Ruby. I was directed to RVM or rbenv. I tried rbenv first because it has Mac instructions, ran into failures, uninstalled it and installed RVM, and still ran into problems. I am not sure how to debug. Details:

I am on MacOS 12.2 (was 11.6 when I first asked this). I am using the terminal (bash command line). I'll jump to the problem with RVM because the developer I'm working with uses it.

I installed RVM using the following command (from their documentation):

\curl -sSL https://get.rvm.io | bash -s stable

That did not produce any error messages. This installation modified my .bash_profile, so I fired up a new shell. In it I used rvm list known and confirmed that the list includes [ruby-]2.6[.6], the version my project needs. I then typed:

rvm install "ruby-2.6.6"

Which produced a compilation error (substituting USER for my actual user name in paths):

Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/USER/.rvm/rubies/ruby-2.6.6, this may take a while depending on your cpu(s)...
ruby-2.6.6 - #downloading ruby-2.6.6, 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 13.4M  100 13.4M    0     0  7961k      0  0:00:01  0:00:01 --:--:-- 7957k
ruby-2.6.6 - #extracting ruby-2.6.6 to /Users/USER/.rvm/src/ruby-2.6.6.....
ruby-2.6.6 - #configuring......................................................|
ruby-2.6.6 - #post-configuration.
ruby-2.6.6 - #compiling...................................................
Error running '__rvm_make -j8',
please read /Users/USER/.rvm/log/1637706281_ruby-2.6.6/make.log
There has been an error while running make. Halting the installation.

I consulted the log file given at the end and found a puzzling error, which I included in an earlier version of this question (you can find it in the revision history). People suggested that I needed to reinstall homebrew because I was now running on the M1 chip. I've done that and repeated the steps to install Ruby, and this time I get a different make error:

installing default libraries
closure.c:264:14: error: implicit declaration of function 'ffi_prep_closure' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    result = ffi_prep_closure(pcl, cif, callback, (void *)self);
             ^
6 warnings and 1 error generated.
make[2]: *** [closure.o] Error 1

My attempt to install using rbenv ended with a very similar error, so switching from RVM to rbenv won't solve my problem.

How can I remedy this problem? I'm wondering if these Ruby managers require something in my environment that I'm missing, despite the output saying that dependencies were checked. Maybe it's assuming a different compiler than whatever I have? I see the reference to C99 there but don't know what it might be expecting.

This error isn't coming from my code; it's coming from the Ruby source code that RVM downloaded and tried to build. I guess I could try debugging that code, if I knew anything about it, but that seems like the wrong approach. I'm trying to get the "official" Ruby 2.6.6 to run, not my locally-hacked Ruby 2.6.6.

I don't know Ruby or its environment; I'm hoping to learn as I work on this project. Because of that lack of experience, though, I don't know where to look next or how to debug this problem. How do I successfully install this version of Ruby?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Check readline version and version requirements (3 comments)
A related bug report (2 comments)
Check readline version and version requirements
Canina‭ wrote almost 3 years ago

I get the feeling that this relates to readline, perhaps GNU readline, more so than Ruby, really. I suggest to check the installation documentation for mentions of readline version requirements, then look in your /usr/local/opt/readline to see if you can determine what version is actually on your system. It might be that the two are incompatible.

Monica Cellio‭ wrote almost 3 years ago

Thanks for the tip. I found my readline; it's 8.1.1, which brew says is the latest. I haven't found anything yet about what version RVM depends on; is it possible that it depends on an older version and there was a breaking change? (That sounds unlikely for something as widely used as RVM, but I can't rule it out.)

Canina‭ wrote almost 3 years ago

Monica Cellio‭ I wouldn't rule it out without at least checking. The fact that you're getting compilation errors that point toward files from readline at the very least strongly suggests that there's an issue there; it doesn't guarantee that that's the problem (some types of errors in the source code can make errors pop up in really weird places), but it's as good a first thing to look at as any. As for what's needed by RVM, look for somewhere in build documentation or where you can download the source; build dependencies are usually listed there, though I don't know about RVM specifically.