Can't install Ruby on OS X - ruby-on-rails

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.

Related

Issues with installing Ruby 2.0.0 on macOS Catalina

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)!

Uninstall Ruby, rbenv and homebrew and reinstall Ruby on Rails with RVM on MAC

I'm very new to RoR specially on Mac. I have installed it many times on Ubuntu with RVM and I'm very comfortable with that. Here is what happened on Mac:
I went through instructions as explained here http://goo.gl/zsHcCC then when I got to the point to install Rails with " gem install rails " I got this error:
Error installing rails:
ERROR: Failed to build gem native extension.
Now I want to roll-back everything and uninstall rbenv and it's ruby versions and reinstall the Ruby On Rails environment using RVM.
I tried to find how to uninstall Homebrew, RBENV and Ruby, but no success.
Thank you.
Sia
Homebrew or Rbenv are very good tools to have as a dev, I would think twice before removing either.
In this case I doubt they are at fault.
Can you confirm you have installed the GCC command line utils for OSX by running $ xcode-select --install in your terminal.
Here is a useful post explaining that process but I find that command generally works fine for me.
If this succeeds what does your $ gem install rails output next?
If you are very new you and you don't need specially the last version of Ruby. You can use Rails Installer http://railsinstaller.org/fr-FR.
To uninstall brew https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/FAQ.md

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 /.

Rails doesn't complete installation on OS X Lion

I'm quite new to Ruby in general and especially RoR, so tell me if I need to add more information.
Upon running sudo gem install rails (after a long delay) I receive the following error message:
ERROR: While executing gem ... (Gem::RemoteFetcher::UnknownHostError)
no such name (https://api.rubygems.org/quick/Marshal.4.8/mime-types-1.17.2.gemspec.rz)
I entered the link and it downloaded something, so I tried again - not entirely surprisingly, I got the same error.
I'm running OSX 10.7.5 and I've installed XCode 4.6.3 as well as the command line tools. I've installed Ruby 2.1.0 so I know I have that up to date. I thought the error might have something to do with sudo typically running whatever came with the machine, but if that's true, wouldn't it give me an error saying I needed a version of Ruby >= 1.9.3?
To be perfectly clear what I'm asking: why will Rails not install under the above conditions, and how can this be remedied?
Edit: I ran the command yet another time and this time it worked, and I don't know why it didn't before or what made it work now. As a note for anyone who should care, I do have RVM installed and used it to install Ruby.
OS X comes with ruby 1.8.x
My guess is that you are still defaulting to that version and not the 2.1 you have installed.
I would recommend installing RVM or equivalent so that you can shift from system 1.8.x to your 2.1 (or else as you can manage several versions of ruby and rails with RVM)
I would recommend against installing rails as root. I ran into this issue where
ruby -v
returned ruby 2.1.0 and
sudo ruby -v
returned ruby 1.9.1
Every time I tried to run
gem install rails
I kept getting errors as a result. I'm not familiar with Mac's package manager but this is what worked for me on ubuntu
sudo apt-get remove ruby1.9.1
then
sudo ruby -v
should return command not found. Then installing rails worked fine
gem install rails
These were the directions I followed. The main problem was I had already installed ruby prior to running(I think heroku toolbelt did it).
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm

Installing Gems under RVM Error

I just purchased my first Mac, a 13" Air with Lion, and am coming from Linux. I'm installed RVM and my first Ruby (1.8.6), but I can't get a gem to install. Here's the input:
Ryan's Air :sudo gem install rails --version 2.0.2
Password:********
and the result:
/usr/local/rvm/rubies/ruby-1.8.6-p420/lib/ruby/1.8/timeout.rb:59: [BUG] Bus Error
ruby 1.8.6 (2010-09-02) [i686-darwin11.2.0]
Ryan's Air :
Thanks in advance for any help on this.
Ryan
The issue is with Lion, and I've encountered this myself on now 2 brand-new 13-inch MBP's.
What you need to do is install the OSX GCC Compilers separately.
They can be found here: https://github.com/kennethreitz/osx-gcc-installer (scroll down to downloading pre-build binaries)
After downloading and running through the package installer (you should not need to install Homebrew), you need to find where the GCC folder is located. For some people, it was in /usr/bin; however, for me I found it in /Developer/usr/bin
Add this directory to your $PATH variable in your ~/.profile or ~/.bash_profile file. For me, I'm using ~/.bash_profile and added it to the end using vim.
Close your Terminal and open it again, and then echo $PATH to make sure the changes saved.
Completely uninstall that version of ruby, and install again normally:
rvm install 1.8.7
rvm use 1.8.7
If it still doesn't work, I recommend installing your version of rails using the following command as Hans specified in Why can't I install Rails on Lion using RVM?:
CC=/usr/bin/gcc-4.2 rvm install ruby-1.8.7 --force
the CC directory would change based on where your install was. However, after adding the correct path to gcc to my $PATH variable, I did not need to do the above command.
If you were still having this problem, hope this helps.
Look at this article. It seems that you get deadlocks with your combination of old rails, sqlite and Webrick. Michael is right, try to use modern version of rails.
rvm install 1.8.7-head
This worked for me, everything else failed. I did not install the gcc specifically, just clean Xcode 4.2

Resources