Issues with installing Ruby 2.0.0 on macOS Catalina - ruby-on-rails

I'm running to issue installing Ruby 2.0.0 on a new macbook with macOS Catalina (version 10.15.7). At first I installed Ruby with rvm which did not work. I figured out that it was because Catalina's default terminal is ZSH instead of Bash (https://gorails.com/setup/osx/10.15-catalina). I was able to install Ruby 2.6.3 with the instructions but the issue is that the project I'm currently working on was written in Ruby 2.0.0. I tried installing this version with rbenv install 2.0.0-p0 but I ran to the following errors:
ruby-build: using libyaml from homebrew
Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/vydoan/.rbenv/versions/2.0.0-p0
Downloading ruby-2.0.0-p0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.bz2
Installing ruby-2.0.0-p0...
WARNING: ruby-2.0.0-p0 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20201005)
Inspect or clean up the working tree at /var/folders/m4/3k5xfdwx7x7gqkzzlyrlc_gc0000gn/T/ruby-build.20201006082731.4615.0q3Cat
Results logged to /var/folders/m4/3k5xfdwx7x7gqkzzlyrlc_gc0000gn/T/ruby-build.20201006082731.4615.log
Last 10 log lines:
compiling cont.c
compiling ./enc/ascii.c
thread.c:928:27: error: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Werror,-Wshorten-64-to-32]
tp->tv_usec = ts.tv_nsec / 1000;
~ ~~~~~~~~~~~^~~~~~
compiling ./enc/us_ascii.c
1 error generated.
make: *** [thread.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.
I've tried doing the follow:
1.
brew tap homebrew/dupes
which gives me this error log
Error: homebrew/dupes was deprecated. This tap is now empty and all its contents were either deleted or migrated.
brew install gcc
rbenv install 2.0.0-p0
which gives me the same errors as above.
I've asked my team and found that another person also have issue with installing ruby on their new mac machines. The older mac didn't not have this problem. Was anyone able to successfully install Ruby 2.0.0 on the newer mac?

Hello I had numerous issues trying to install ruby 2.2.7 the project I work on has quiet a deprecated version of ruby necessary stated above now I ran into numerous problems they use rvm I could not install 2.2.7 using rvm I have however succeeded using rbenv the thing that ruins your experience is mainly the command line tools provided by Apple since in newer version it does not support compiling older ruby versions.
I also run the same version of MacOS :
Your best bet (since I've tried several days in a row to get my setup working installing ruby being the biggest blocker).Go to apple's developer site and download an older version of command line tools here and browse for 11.4.1(Before running the next steps make sure to purge previous attempts and ruby version managers and symlinks so it won't interfere with you next install and make your life hard).
Before downloading and installing it check your gcc -v remember that and install the command line tools you've downloaded and check it again to see if things went according to plan you should get something like:
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
I haven't tried other versions but this one works afterwards go to rbenv official website install the tools add the shell scripts to your local .zshrc file (if you don't have one just create it).Besides adding what the guide says it ommits an important step you also need to add this to your .zshrc:
export PATH="$HOME/.rbenv/bin:$PATH"
Then you should just close and open the terminal and install the ruby version you need :
# list latest stable versions:
$ rbenv install -l
# list all local versions:
$ rbenv install -L
# install a Ruby version:
$ rbenv install 2.0.0-p247
Consult the docs as of how to use them globally or locally also if use is not working end all terminal windows and the process restart and it should work just okay.
!Important mentions is to not change the command line tools when compiling different ruby related version may break the setup (ignore brew messages to update command line tools when running brew doctor)!

Related

Error running '__rvm_make -j10' while installing ruby 2.6.5 on mac

I am trying to install the ruby 2.6.5 on mac having m1 pro chip but it's giving error of "__rvm_make -j10".
I tried to google but won't find error with "__rvm_make -j10". there is one question with the same error on stackoverflow and i tried the same method but it won't worked too.
i tried "rvm install 2.6.5 --with-out-ext=fiddle"
i tried with open ssl 1.0 too, but not any one worked.
sammalik#Sams-MacBook-Pro rubyporgram % rvm install 2.6.5
ruby-2.6.5 - #removing src/ruby-2.6.5 - please wait
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/13.0/arm64/ruby-2.6.5.
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/openssl#1.1/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/sammalik/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/sammalik/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
Error running '__rvm_make -j10',
please read /Users/sammalik/.rvm/log/1668327329_ruby-2.6.5/make.log
There has been an error while running make. Halting the installation.
UPDATE: Here's an updated blog post I wrote with the possible options if you really must use Ruby 2.6.x: https://www.rubyonmac.dev/how-to-install-ruby-2-6-on-macos-13-ventura
Instead, I highly recommend updating your project to at least 2.7.7. Here's a detailed guide I wrote that shows How and Why to Upgrade the Ruby Version in Your Project
Ruby 2.6.x is no longer supported on any Mac that has version 14 or higher of Apple's command line tools, which would be the case on macOS Ventura (13.0). Assuming you have Homebrew installed, you can check which version you have by running brew config, and then look towards the bottom for the lines that starts with CLT: and Xcode:
Ruby 2.6 reached end of life in March 2022, so it should not be used in production for security reasons. A lot of people get stuck because they think they have to use the version of Ruby that's specified in the project's .ruby-version and/or Gemfile. Instead, it's recommended to update the project to a newer version.
In most cases, it would be as easy as following these steps:
Install Ruby 2.7.7
Replace "2.6.x" with "2.7.7" in .ruby-version and Gemfile, and any other file where the Ruby version is specified (except Gemfile.lock because it should never be edited manually)
Run bundle install
Update any gems if necessary
Run your tests and make sure your app still works
Now that you know the recommended approach, let's go over 2 solutions in case you have a special need to use Ruby 2.6 before you update to 2.7.7:
Install Ruby with Homebrew
Downgrade to version 13.4 of the command line tools
Install Ruby with Homebrew
Install Homebrew if you haven't already
Install Ruby 2.6.10: brew install ruby#2.6
Follow the instructions for setting your PATH. For example, Homebrew will say something like this:
By default, binaries installed by gem will be placed into:
/opt/homebrew/lib/ruby/gems/2.6.0/bin
You may want to add this to your PATH.
If you need to have ruby first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
The reason this works is because this is a pre-built version of Ruby that was compiled with version 13.3 of the command line tools. However, note that it's not officially supported.
Note that you'll need to disable RVM or any other version manager you might have used before. And you'll only be able to use 2.6.10 with this setup. You won't be able to switch to other versions that you might have installed with RVM or another version manager.
This is meant as a temporary solution so that you can run your project with 2.6.10 and then update it to 2.7.7. Also, note that either way, you will need to update your project to at least 2.6.10. There's absolutely no reason to use 2.6.5. You should always make sure your apps are running the latest version in a series. For 2.6, it's 2.6.10, for 2.7, it's 2.7.7, then 3.0.5, and 3.1.3.
Downgrade to version 13.4 of the command line tools
This is not possible on macOS Ventura (13.0), so don't waste your time trying. If you're on macOS Monterey, you can download version 13.4 of the command line tools from Apple's developer site, and then install them. I also wrote step-by-step instructions for installing version 13.4 of the command line tools if you need them.
The following works fine with macOS Ventura 13.1. You have to choose an older openssl version e.g. openssl#1.0.2t
Make sure you have home-brew installed /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(Optional) Check if you already have openssl versions installed via home-brew. Uninstall not ncessary versions brew uninstall openssl
Install openssl via home-brew: brew install openssl#1.0.2t
Check the path where your local home-brew packages go. In my case it is /usr/local/opt/openssl#1.0/.
Install ruby with rvm rvm install 3.1.3 --with-openssl-dir=/usr/local/opt/openssl#1.0/
I've been through a similar problem in Ubuntu 22.10. Here are some points that may help you:
Your OpenSSL may be too updated and probably has some breaking changes that don't allow some of your ruby C files to be compiled. Download a previous version at OpenSSL website, install it in a different location than your current version and use rvm install --with-openssl-dir=<old-openssl-dir> 2.6.5 as mentioned in Chris' answer.
Instead of using --with-openssl-dir option, you could add your old OpenSSL /bin and /include files directly in environment variables in your rvm command, like this: PATH=<old-openssl-bin-path>:$PATH C_INCLUDE_PATH=<old-openssl-include-path>:/usr/include rvm install 2.6.5. This could be useful in the case that --with-openssl-dir option isn't available for some reason. You also need to create links to the /lib files in your old OpenSSL folder. You'll probably find paired files like libssl.so and libssl.so.1.1. You can just move the version-named files into /usr/lib(or similar for macos), otherwise when you execute openssl command from your old OpenSSL folder, it will probably raise an error saying that openssl can't find libraries. If you choose to use this method, make sure that your rvm user bin files (at ~/.rvm/usr/bin) don't contain any files that may mess the ruby installing (like another openssl executable). You may get rid of this folder using rvm pkg remove.
Another possible solution is changing your gcc version. My OS came with gcc version 12.2.0, which comes with a change in computer gotos that failed my make step. To find errors in your ruby installation, check the make.log file specified at the rvm command error message and look for lines like this:

Inspect or clean up the working tree error when installing Ruby 2.1.3 on Mac OS X 10.9.5

I'm trying to install Ruby 2.1.3 on Mac OS X 10.9.5 using the rbenv install 2.1.3 command. However I get the error message below. I tried every suggestion on stack overflow and elsewhere. Nothing seems to be working. I currently have the original ruby version that came with 10.9.5, Ruby 2.1.3p242. Brew doctor says everything is fine and rbenv is up to date. Thanks so much! Trying to learn Ruby and Ruby on Rails but I can't get passed this stage.
Inspect or clean up the working tree at /var/folders/zg/s1jqg94n0hjggdnmb442n2lc0000gn/T/ruby-build.20141025184549.88303
Results logged to /var/folders/zg/s1jqg94n0hjggdnmb442n2lc0000gn/T/ruby-build.20141025184549.88303.log
Last 10 log lines:
linking shared-object openssl.bundle
installing default openssl libraries
compiling raddrinfo.c
compiling ifaddr.c
installing default socket libraries
compiling init.c
compiling constants.c
linking shared-object socket.bundle
linking shared-object ripper.bundle
make: [build-ext] Error 2
I have a m1 mac and I also got this error installing ruby,
this command worked for me:
export optflags="-Wno-error=implicit-function-declaration";
run this and then try rbenv install again.
Did you try this:
CC=/usr/bin/gcc rbenv install 2.1.3
From this SO answer: Unable to build Ruby 2.1.3 on OSX 10.10 GM 3.0 with rbenv
I had to remove the existing openssl that came with macOS and instead install from brew with brew install openssl.
NOTE: I also had to disable SIP with csrutil disable and then remount root with writable permissions, with sudo mount -uw /.

Trouble installing Homebrew

I have just started learning Ruby on Rails and am having a little trouble getting the environment set up on a Macbook Air OS X version 10.9.3
I installed Ruby from rvm.io
I have:
Ruby 2.0.0p451
Rails 4.1.4
Git 1.7.4.4
XCode version 2003 (is this wrong?)
I used ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
but I get back Failed during: /usr/bin/sudo /usr/bin/xcode-select --install
I looked around and I have seen that people suggest Homebrew not be installed using sudo access, but it keeps asking for my password. What am I doing wrong here? Why does Homebrew refuse to install?
What is the exact version of XCode? 5.1.1? The failed command is to install XCode command line tool. Probably you can install that first before installing Ruby.

How to use RVM to install Ruby 1.9.3 when Xcode 4.3.2 is installed and gcc is missing?

I got a new iMac with Lion and installed Xcode 4.3.2. After running
curl -L get.rvm.io | bash -s stable
I opened up a new bash, and used
$ rvm install 1.9.3
to install Ruby 1.9.3, but there were errors and the log said that the C compiler is not there. And rvm requirements says:
$ rvm requirements
[...]
Xcode 4.3+ users
- please be warned
- only ruby-1.9.3-p125+ is partially supported
- in case of any compilation issues:
* downgrade to Xcode 4.1
* uninstall Xcode and install osx-gcc-installer
and reinstall your rubies.
So does that mean I might need to downgrade to Xcode 4.1? What if I want to keep Xcode 4.3.2? Then will 1.9.3-p125+ be able to work, but only partially?
Update: or how about installing Ruby 1.9.2 -- will it work with the latest Rails 3.2.3? If so, how to add gcc? (using Xcode's gcc?)
To install 1.9.2 or lower you need to follow the instructions in this blog post. It outlines how it get a copy of GCC which does not conflict with Xcode but can be used to build Ruby.
Xcode 4.3, Homebrew and Ruby.
You cannot install the osx-gcc-installer as it will conflict with Xcode 4.3.2, overwriting the working versions of llvm-gcc and clang.
install osx-gcc-installer
use latest ruby:
rvm install ruby
it will be 1.9.3-p125 as it's latest ruby

Can't install Ruby on OS X

I'm trying to follow the installation instructions for Ruby on Rails from Hivelogic.com. I've done this before on previous installs of OSX without trouble. I'm having trouble this time installing on Snow Leopard.
At the end of the "make" step installing Ruby, I get a number of errors related to readline. Not sure if this matters, but here they are:
readline.c: In function ‘username_completion_proc_call’:
readline.c:730: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:730: error: (Each undeclared identifier is reported only once
readline.c:730: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1
make: *** [all] Error 1
When I try to sudo make install, I get more errors. When I "which ruby", I get /usr/local/bin/ruby which is correct. But as soon as I try to use ruby, I get this message: "You need the Rosetta software to run ruby. The Rosetta installer is in Optional Installs on your Mac OS X installation disc." That's weird, but I installed Rosetta, and was able to proceed.
Except: I still have Ruby1.8.6 installed (not 1.8.7). "ruby -v" reports 1.8.6. 1.8.6 was the version that was migrated (I assume) from the Leopard install on this machine. In other words: where's my new Ruby? How do I get 1.8.7 (required by the current version of Rails) installed correctly?
I've always found macports the best way to install/manage my ruby versions. I have 1.8.6, 1.8.7 and 1.9.1 all installed using macports.
First, grab macports and install it.
Then, update (or create) your ~/.bashrc file to include the following line:
export PATH=/opt/local/bin:$PATH
This places all macports executables in front of you path, so you system will find them first.
Finally, install any of the versions of ruby you want:
sudo port install ruby186
sudo port install ruby
sudo port install ruby19
I also recommend installing rubygems from scratch after ruby is installed. Grab the latest rubygems release here and then run the following from inside the downloaded rubygems directory:
sudo ruby setup.rb
Hope this works out for you.
If you have snow leopard than 1.8.7 is pre-installed in /usr/bin
Another option is to use VirtualBox and install Ubuntu on VirtualBox. Ruby installation and usage is much smoother this way I have found, as I wasted a lot of time trying to get Ruby working properly on the Mac.

Resources