How can I install Ruby 1.9.3 in Mac OS X Mountain Lion without Xcode? - ruby

I would like to know about alternative ways to build a development machine for Ruby 1.9.3 on OS X 10.8 Mountain Lion, that does not require Xcode.
Mountain Lion is now Golden Master as I'm writing this question, so it could be considered as final version. That cannot be said about Xcode, that is a preview release yet.
RVM recommends to install osx-gcc-installer over Xcode, but I would like not to mess my system.
What is the cleanest way to install Ruby 1.9.3 on Mountain Lion without Xcode?

osx-gcc-installer turns out to be a very good option to replace Xcode in order to install Ruby 1.9.3
These are the steps I have followed:
Download & install the latest version of osx-gcc-installer here (GCC-10.7-v2 is fine): https://github.com/kennethreitz/osx-gcc-installer
Install RVM as usual and select 1.9.3-head as the default ruby installation: https://rvm.io/rvm/install/
Install Homebrew: https://github.com/mxcl/homebrew/wiki/installation
Install libksba to resolve some dependencies with Ruby 1.9.3: brew install libksba
That's it! You should now have Ruby 1.9.3 installed on Mountain Lion working perfectly.
If you need some other packages, install them now through Homebrew, such as Imagemagick for example: brew install imagemagick
It's possible that you need XQuartz for Homebrew to work properly, as Apple is not shipping X11 since Mountain Lion. You can download it here: http://xquartz.macosforge.org/trac/wiki
EDIT:
Now (since 29th July) Command line tools for Xcode 4.4 are available.
So, the new steps are these:
Download & install Command line tools for Xcode 4.4 (you don't need to download Xcode): https://developer.apple.com/downloads/index.action
Install Homebrew: https://github.com/mxcl/homebrew/wiki/installation
Install automake: brew install automake
Install RVM as usual and select 1.9.3-head as the default ruby installation: https://rvm.io/rvm/install/
Optional step: You may need XQuartz for some components, for example for Imagemagick, so download & install XQuartz: http://xquartz.macosforge.org/trac/wiki

I also had to add this:
export CC=/usr/bin/gcc-4.2
in order to make the Apple command line tools work with the rvm. Without this I had repeated llvm issues:
The provided CC(gcc) is LLVM based, it is not yet fully supported by ruby and gems, please read rvm requirements.

I had to add
export CPPFLAGS=-I/opt/X11/include
as well as
export CC=/usr/local/bin/gcc-4.2
I was still getting compilation errors due to readline (things like readline.c: In function ‘readline_s_vi_editing_mode_p’: in the make.log file), and the RVM readline page didn't seem to help, so I ran
brew install readline
followed by
rvm install 1.9.3 -C --with-readline-dir=/usr/local/Cellar/readline/6.2.4

Related

Updating Ruby Mac OS 10.6.8 Snow Leopard

I'm trying to install a more recent version of Ruby on Snow Leopard so I can install Jekyll. When trying to install any version of Jekyll I get an error saying that it requires liquid, which requires ruby v2+.
If I try upgrade via rbenv I get the following when trying all versions:
error: failed to download ruby-2.1.1.tar.bz2
BUILD FAILED (OS X 10.6.8 using ruby-build 20181019)
I've also installed Ruby manually from source but this isn't recognised by the system and I can't switch versions.
If i run rbenv global it only recognises the System version of Ruby.
When I try brew upgrade ruby I get the following error:
ruby 2.5.3_1 already installed
If I try link to the new version with brew I get the following error:
brew link --force --overwrite ruby#2.5.3_1
Error: No such keg: /usr/local/Cellar/ruby#2.5.3_1
RVM doesn't install so I'm not sure what to do next. Below are the details of the packages I have installed.
Xcode 3.2.2 (I cant get an installer working for any higher versions of Xcode). The more recent versions hosted by Apple for Snow Leopard are corrupt when downloaded.
rbenv 1.1.1
brew 1.8.4
ruby 1.8.7 (System)
You have (or had) a path issue. Before you did your follow up steps, if you had run which ruby you'd probably see it pointing to /usr/bin/ruby which is system ruby, not your homebrew ruby in /usr/local/bin/ruby.
You still need to, if you haven't already, add your export command to your ~/.bash_profile file to ensure your PATH gets updated for every terminal window you open.
I'm not sure what actually fixed this but I ran the following commands after reading other posts and now have Jekyll 3.8.3 installed and ruby 2.5.3p105.
sudo chown -R "$USER":admin /usr/local
export PATH=/usr/local/bin:$PATH
brew link --overwrite ruby --force
gem install jekyll

Ruby on Rails install trouble on OSX with dependencies

I'm trying to install RoR on Mountain Lion. I have the following installed:
Xcode from the App Store with command line tools
RVM
homebrew
In terminal I verified that gcc is installed.
When I type in "rvm requirements" I get a message saying that I'm missing a number of dependencies including OpenSSL, autoconf, automake, libxslt and many more. RVM also says to install these with brew. So I do and rvm no longer complains about the missing dependencies.
But when I try to install ruby 1.9.3 via "rvm install 1.9.3", at the end of the compile I receive a message "ruby was built using clang -but it's not (fully) supported, expect errors."
I'm stumped at this point. I'm trying to figure out:
Why are dependencies missing when I've installed Xcode command line tools?
Why am I still getting a compile error after using brew to install the dependencies?
Help please. :)
Try using gcc compiler instead i.e
rvm install 1.9.3 --with-gcc-4.2
Reference: https://github.com/wayneeseguin/rvm/issues/1480
So here's the order I usually go through before installing any Rubies.
1st thing: Install XCode and the Command Line Tools for Mountain Lion (you can also install these from the Preferences > Downloads window).
2nd: Make sure you have Homebrew installed.
3rd: Once that's set up, run brew tap homebrew/dupes
4th: Then brew install openssl autoconf apple-gcc42 automake
I had issues with RVM and have long since switched to RBenv/Ruby-Build. There are various differences, but really running through the above steps should fix any issues you had, and lots of people use one or the other. Both are great.
Then, just try to install Ruby however you choose to.

Install Ruby with Mountain Lion, Xcode 4.5, and RVM?

rvm install 1.9.3 --with-gcc=clang (as suggested by Can't install Ruby under Lion with RVM – GCC issues) doesn't work because neither Mac OS X 10.8.2 (Mountain Lion) nor Xcode 4.5 comes with clang.
Is it possible to compile Ruby with llvm?
According to Matthias Schmidt's "How to install Ruby 1.9.3 on Mac OS X with LLVM and rbenv", Ruby is now fully compatible with LLVM.
But, I still get: error: C compiler cannot create executables
UPDATE:
Actually, I found clang here /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang (thanks to the Node.js Installation Wiki). I just didn't have clang in my path.
So, if I add clang to my path, is rvm install 1.9.3 --with-gcc=clang sufficient?
From RVM notes:
Homebrew:
If you are using Homebrew, you can install the apple-gcc42 and required libraries from homebrew/dupes:
brew update
brew tap homebrew/dupes
brew install autoconf automake apple-gcc42
rvm pkg install openssl
This can live side by side with an existing Xcode 4.2+ install or Command Line Tools for Xcode.
osx-gcc-installer:
If you don't use Homebrew, you can download and install osx-gcc-installer:
https://github.com/kennethreitz/osx-gcc-installer.
Hope it will help you.
no, ruby is not fully compatible with llvm, there is at least one issue with Fibers and other issues might occur if version of llvm changes.
Ruby works best with gcc-4.2, rvm provides information how to get it (+other important stuff):
rvm requirements
I used this: http://railsinstaller.org/mac - and it was a BREEZE. Also I like the sublime text editor, found that through this resource... Maybe I'll say goodbye to macvim! Imagine that.

Error compiling ruby 1.9.3 using rvm, homebrew, or macports

I've tried installing ruby 1.9.3 using rvm, using homebrew, and using macports and all seem to fail part way through the compile. I'm using Lion OSX.
Here is the log file of my most recent attempt using rvm
http://pastebin.com/AEiJbGzD
Any help would be appreciated. It all started when I started getting openssl errors so tried uninstalling openssl and re-installing it. Openssl installed with no issue but then I couldn't get ruby re-installed.
Thanks
I was able to install Ruby 1.9.3 on Lion and Xcode 4.2 using rvm with the --with-gcc=clang flag:
$ rvm install 1.9.3 --with-gcc=clang
You should install OSX GCC installer:
GitHub - OSX GCC Installer
After installation you run:
CC=/usr/bin/gcc-4.2 rvm install 1.9.3
And it should work.
Or you can change permanently:
export CC=/usr/bin/gcc-4.2
rvm install 1.9.3
Xcode 4.2 doesn't install non-LLVM gcc anymore.
I have had this problem after reinstall mountain lion (clean install) and after install XCode 5 DP... I have followed the steps and installed Command Line Tools from Xcode/Preferences... and had having the same problem.
I have been checking https://developer.apple.com/downloads/index.action?=command%20line%20tools and installed "Command Line Tools (OS X Mountain Lion) for Xcode - April 2013" after that, everything works fine.
Regards

Can't install Ruby Enterprise Edition with RVM on OSX Lion

Here is what I have done so far.
Clean install of OS X Lion
Downloaded and installed latest version of Xcode from the App Store.
Installed Git
Installed Homebrew
Installed RVM
I am now trying to install Ruby Enterprise Edition for a project with rvm install ree and receive the following error:
$ rvm install ree
ree-1.8.7-2011.03 - #installing
ERROR: Error running './installer -a /Users/FaraazKhan/.rvm/rubies/ree-1.8.7-2011.03
--no-tcmalloc --dont-install-useful-gems ', please read
/Users/FaraazKhan/.rvm/log/ree-1.8.7-2011.03/install.log
ERROR: There has been an error while trying to run the ree installer. Halting
the installation.
I have already tried CC=/usr/bin/gcc-4.2 rvm install ree and with the same result.
I was able to duplicate your error, just now. This solved it for me:
$ rvm remove ree
$ export CC=/usr/bin/gcc-4.2
$ rvm install --force ree
Using MacPorts you can install Ruby Enterprise Edition, as well as Ruby 1.9.2 for the local user in OS X Lion while having Xcode 4.2 installed by using "Apple's version of gcc 4.2."
Prerequisites:
OS X Lion (tested in 10.7.2)
Xcode 4.2
rvm 1.9.1
MacPorts 2.0.3
Execute the following commands:
$ sudo port install apple-gcc42
$ export CC=/opt/local/bin/gcc-apple-42
then
$ rvm install ree
$ rvm use ree
or
$ rvm install 1.9.2
$ rvm use 1.9.2
optionally
$ rvm use ree --default
or
$ rvm use 1.9.2 --default
I hope this helps.
-Joe
No need to install MacPorts or downgrade to 4.1 to get GCC, I used the installer package at https://github.com/kennethreitz/osx-gcc-installer with xCode 4.2 already installed, and had no problem installing 1.9.2-head and 1.9.2-p290.
I did something similar to what jbg advised. Only I didn't use MacPorts. I just used the latest GCC package for Lion here.
This was after spending about a day and a half trying all of the other suggestions, downgrading to Xcode 4.1, etc. to no avail.
By the way, the direct link to Xcode 4.1 at Apple's site gave me an invalid checksum error, all three times I downloaded it. I saw a Twitter post from someone else who had the same problem.
At the risk of redundancy, I'll post my answer as well, since I tried everything on this page (and many others) and ended up with a hybrid of some of them which seemed the most likely to work. Note that some of these steps may not have been explicitly necessary but they were sufficient (i.e., I didn't go back and remove potentially unnecessary steps to get the simplest path to success).
Environment: Mac OS Lion 10.7.3, Homebrew components, rvm 1.10.2, ree 1.8.7-2012.01, Xcode 4.2.1 with legacy gcc-4.2 available.
Steps:
Ensure that a stable Ruby is current. Used 1.9.2 (rvm use 1.9.2) as 1.9.3 was a potential problem.
rm -fr $rvm_path/usr
rvm pkg install ree_dependencies
rvm remove ree
export CC=/usr/bin/gcc-4.2
rvm install ree \
--with-openssl-dir=$rvm_path/usr \
--with-readline-dir=$rvm_path/usr \
--with-iconv-dir=$rvm_path/usr \
--with-zlib-dir=$rvm_path/usr
I had previously tried the brew-specific solutions but those didn't work for me. Hope this helps someone!
Please do NOT use sudo with RVM, nor do you need to use rvmsudo EXCEPT for when upgrading RVM itself. Please see and read https://rvm.io/support/faq/ (Do I need to use sudo with gems? entry) and https://rvm.io/support/troubleshooting/ (Multi-User Installs - Using the sudo command entry)
Please remove your current installation and start over as using sudo will definitely mess up the permission structure for RVM. Please see the very bottom of https://rvm.io/support/troubleshooting/ (How do I completely clean out all traces of RVM from my system, including for system wide installs? entry)
Then begin again strictly following the Multi-User installation segment of https://rvm.io/rvm/install/
Thank you.
If you are on Lion 10.7.2, and have installed XCode 4.2, you need to downgrade XCode to 4.1
Here's how I did it (it was more complicated than you might think):
Download XCode 4.1 from Apple Dev Center (you'll need to login with your dev centre creds)
uninstall XCode 4.2
$ sudo /Developer/Library/uninstall-devtools --mode=all
remove the XCode installer from your /Applications directory
run the XCode 4.1 package you downloaded, this will install a new XCode installer into /Applications
run the XCode installer in /Applications
When it stops, asking you to quit iTunes, you need to quit iTunes, and also use Activity Monitor to force quit the iTunes Helper
Wait for XCode 4.1 to install
Use the steps outlined above to install ree
Cheers,
Ian
This is how i did to install it. May be previous answers are already solve your problem. My step may be help people who experience same as me.
Frist, Install MacPort latest version
>rvm uninstall ree
>sudo port install apple-gcc42
>export CC=/opt/local/bin/gcc-apple-4.2
>rvm pkg install zlib openssl readline
>rvm install --force ree
Result is:
IronB:~ ...$ rvm install --force ree
Installing Ruby Enterprise Edition from source to: /Users/.../.rvm/rubies/ree-1.8.7-2011.03
ree-1.8.7-2011.03 - #fetching (ruby-enterprise-1.8.7-2011.03)
ree-1.8.7-2011.03 - #extracting ruby-enterprise-1.8.7-2011.03 to /Users/.../.rvm/src/ree-1.8.7-2011.03
Applying patch 'tcmalloc' (located at /Users/.../.rvm/patches/ree/1.8.7/tcmalloc.patch)
Applying patch 'stdout-rouge-fix' (located at /Users/.../.rvm/patches/ree/1.8.7/stdout-rouge-fix.patch)
Applying patch 'no_sslv2' (located at /Users/.../.rvm/patches/ree/1.8.7/no_sslv2.diff)
ree-1.8.7-2011.03 - #installing
Removing old Rubygems files...
Installing rubygems-1.8.10 for ree-1.8.7-2011.03 ...
Installation of rubygems completed successfully.
ree-1.8.7-2011.03 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ree-1.8.7-2011.03 - #importing default gemsets (/Users/.../.rvm/gemsets/)
I'm also put this to my ~/.rvmrc for next time
# Make this work with OS X Lion... for now...
if [[ `uname -v` =~ "Darwin Kernel Version 11" ]] ; then
export CC=/opt/local/bin/gcc-apple-4.2
fi

Resources