Install any version of ruby with RVM on mavericks - ruby

I've just upgraded to osx mavericks, and I want to install ruby 2.0, but I'm getting configure: error: cannot run C compiled programs. errors.
I update rvm with rvm get stable and then type rvm install 2.0.0 and get an error directing me to a log file. The log file contains:
configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... x86_64-apple-darwin13.0.0
checking host system type... x86_64-apple-darwin13.0.0
checking target system type... x86_64-apple-darwin13.0.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/Users/mattroberts/.rvm/src/ruby-2.0.0-p247':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
So, I tried listing the versions I do have. It tells me i have 1.9.3-p392 so I uninstall that one and re-install to see if that works - same error.
Do I need to re-install / update xcode, or is there another solution?
Thanks!

If you haven't upgraded Xcode after upgrading to Mavericks you should do so
After that, open a command prompt and type:
xcode-select --install
This will install xcode command tools that have been deleted by OSX update.
After that it should work okay.

The suggested solutions did not solve my issue (XCode at newest version, command line tools installed). I used rvm install ruby-1.9.3 --with-gcc=clang and that worked.
I thought rvm used to use clang for OSX by default. Not sure if I remember that wrong or something changed / this is no longer the best thing to do. Nevertheless it made the install work for me.
After Edu's comment, the github rvm issues page he referenced warns:
#marksands please be sure you know what you are duing, ruby 1.9.3
compiled with clang is not "safe", it can segfault, thread related
issues to be expected, consider reinstalling ruby --with-gcc=gcc42 or
just let rvm install gcc 4.6, only ruby 2.0.0 is fully compatible with
clang
This issue points out issue with gcc46 on Mavericks:
The gem in question uses different language - not C/C++, it uses
Objective-C - so it's not the compiler fault, you can build gcc-4.6
with support for Objective-C - it's just not done by default.
You have two options now, both start with uninstallig gcc-4.6 and
then:
• Install apple-gcc42
• Install gcc-4.6 with --enable-objc

this is supposed to be fixed, run:
rvm get head
rvm remove 1.9.3
rvm install 1.9.3
do not use extra flags

What ended up working for me was installing XCode then RUNNING Xcode then trying to reinstall.

Running
rvm_configure_env=('LDFLAGS=-L/opt/sm/pkg/active/lib' 'CFLAGS=-I/opt/sm/pkg/active/include' 'CPATH=/opt/sm/pkg/active/include')
Corrected my compiler issue in Mavericks

Solution:
unset SDKROOT
This worked for me. I hope it would for you too.
I tried to reinstall xcode along with xcode developer tools. Didn’t work. The same error.
Try to run with env -i bash —noprofile —norc to see whether your env vars are causing the issue to further investigate.

Ran into the very same issue (on 10.8.5, all up to date). Ruby 2.0.0 installed fine, but not 1.9.3. This solution worked for me.
cd into the ruby path (found in config.log), then
issue .configure (with all options, as found in config.log)
make
make install
Then:
rvm use 1.9.3 --create

Related

Clang version 1.6 cannot be updated

I have a very strange issue with clang. I'm running OSX 10.10.1 and have installed XCode 6.1.1 from here. For another project, I wanted to update Ruby from 2.1.2 to 2.2.0 via rbenv install 2.2.0. The command prints the following error:
Downloading ruby-2.2.0.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc
Installing ruby-2.2.0...
BUILD FAILED (OS X 10.10.1 using ruby-build 20141225)
Inspect or clean up the working tree at /var/folders/4z/s4lwbd314_lg3hprgp72qsqr0000gn/T/ruby-build.20150112115924.6502
Results logged to /var/folders/4z/s4lwbd314_lg3hprgp72qsqr0000gn/T/ruby-build.20150112115924.6502.log
Last 10 log lines:
Via: 1.1 2ce6276171358bf7d052aa190ed98f8d.cloudfront.net (CloudFront)
X-Amz-Cf-Id: 42q6Sa73ORpGbCgaHIpsBwTRP8ycUAhsdTolikEbyxqMrn9uePtfCA==
/var/folders/4z/s4lwbd314_lg3hprgp72qsqr0000gn/T/ruby-build.20150112115924.6502/ruby-2.2.0 /var/folders/4z/s4lwbd314_lg3hprgp72qsqr0000gn/T/ruby-build.20150112115924.6502 /usr/bin
checking build system type... x86_64-apple-darwin14.0.0
checking host system type... x86_64-apple-darwin14.0.0
checking target system type... x86_64-apple-darwin14.0.0
clang: error: invalid version number in '-mmacosx-version-min=10.10.0'
configure: error: clang version 3.0 or later is required
make: *** No targets specified and no makefile found. Stop.
Googled for invalid version number in '-mmacosx-version-min=10.10.0' but I did not find any helpful information. By running clang --version it turns out that my clang executable is version 1.6 (!):
Apple clang version 1.6 (tags/Apple/clang-70)
Target: x86_64-apple-darwin14
Thread model: posix
This seems very weird, because XCode is usually shipped with LLVM 6. I tried to (re)install the Command Line Tools (in which clang should be located), but XCode doesn't offer me the option to download/update them:
Trying to install them via xcode-select via the command line: xcode-select --install as suggested here results in showing the help message, indicating that the --install-command is unknown (xcode-select is version 895). I also tried to download and install it manually but it has absolutely no effect. The xcode-select-path is /Applications/Xcode.app/Contents/Developer but I also tried /Applications/Xcode.app.
I also tried to update clang via Homebrew:
$ brew install llvm --with-clang --with-asan
[...]
LLVM executables are installed in /usr/local/opt/llvm/bin.
Extra tools are installed in /usr/local/opt/llvm/share/llvm.
$ brew install llvm --with-clang --with-asan
Warning: llvm-3.5.0_2 already installed
but in none of the two paths is a clang executable.
So my question is: Is there a way to update clang? Or a workaround to install ruby 2.2.0 anyway? I'm stuck here for days, any help is greatly appreciated!
EDIT
I found out that newer XCode versions (I think from 5.0 upwards) come with LLVM/Clang inside the XCode.app-folder. A few months ago, I installed XCode 4.something for testing purposes - these versions overwrite system tools like clang and xcode-select. Reinstalling XCode 6 will not update them.
I fixed it by copying /usr/bin from another Mac, but there must be a way to fix it without this workaround.

Homebrew doesn't work on snow leopard

I have a fresh installation of OsX 10.6.8
Yesterday I installed XCode 3.x and then homebrew.
brew doctor << was ok
brew update << updated ok
brew install python << gave an error similar to this one:
==> ./configure --prefix=/usr/local/Cellar/readline/6.2.4 --mandir=/usr/local/Ce
checking for gcc... llvm-gcc
checking for C compiler default output file name...
configure: error: in `/private/tmp/readline-lGgV/readline-6.2':
configure: error: C compiler cannot create executables
See `config.log' for more details.
READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting
I thought was a problem due to my old XCode, so I uninstalled it and then loaded GCC-10.6.pkg but the error was the same.
I thought that also osx-gcc could be outdate so I managed to find a XCode 4.2 and I installed it, but the error doesn't change
I found out that there is no "Command Line Tools for Xcode" for osX 10.6.8 so now I'm out of options.
There is a newer version of XCode (4.3.2) that is compatible with 10.6.8 but I wasn't able to get it, and sincerely, now I don't think that that could be the problem.
So, now, I'm out of options.
I can't upgrade to Lion, because my laptop doesn't support it.
The sad thing is that yesterday I decided to format my hd and reinstall OsX just to have a new, fresh, clean installation of homebrew!!!!!
Please.....help!!!!

How do I get Ruby set up in OS X 10.6.8?

I've decided to start experimenting with Ruby to get out of my little Java box, and want to start with a little personal project taking some written addresses and geocodes them.
As a start, I got the Koans and started messing about with them from the command line, just using Ruby as installed in OS X (ruby -version returns 1.8.7). So far, so good. Then I used gem install geocoder, which worked nicely. But to work with some of it's objects, it needs json, so on to gem install json when...
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/sharakan/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Users/sharakan/.gem/ruby/1.8/gems/json-1.7.3 for inspection.
Results logged to /Users/sharakan/.gem/ruby/1.8/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
The gem_make.out file just has the same mkmf.rb error.
After doing a bit of searching, I found that people with similar sounding problems found resolution by installing XCode. I haven't seen my XCode DVD in a long time, and the version available from Apple now requires 10.7.
I also found some information that made RVM sound like it might solve the problem. But sadly that too failed with compilation problems:
[2012-06-11 20:50:00] ./configure --prefix=/Users/sharakan/.rvm/rubies/ruby-1.9.3-p194 --enable-shared --disable-install-doc --with-libyaml --with-opt-dir=/Users/sharakan/.rvm/usr
configure: WARNING: unrecognized options: --with-libyaml
checking build system type... i386-apple-darwin10.8.0
checking host system type... i386-apple-darwin10.8.0
checking target system type... i386-apple-darwin10.8.0
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/sharakan/.rvm/src/ruby-1.9.3-p194':
configure: error: C compiler cannot create executables
See `config.log' for more details
So where to go next? Do I really need to purchase Lion to get Ruby working on my machine?
If your issue that you don't have xcode installed, you really just need make, gcc, etc installed.
The easiest way to do this to just use OS X GCC Installer
Installing that should get you on your way.
You may be able to get a Snow Leopard version of Xcode/Developer Tools from the Apple developer site. You might also want to look into Xcode, GCC and Homebrew, from Kenneth Reitz: standalone GCC tools without Xcode. There is also an official Apple offshoot, although that may be Lion only.
You could try RailsInstaller for OSX which includes RVM, Ruby, Rails and most important libraries that are needed for ruby, you can download it here https://github.com/railsinstaller/railsinstaller-nix/downloads.
Use RVM to install ruby. I highly recommend using RVM, especially if you are going to possibly have multiple projects that may use different versions of Ruby (or even JRuby!)
https://rvm.io/rvm/install/

What's a proper way to install Ruby <1.9.3 on OS X Lion with Xcode 4.3?

Until recently I used to have Xcode 4.2 with the osx-gcc-installer installed on top of it, which worked quite well for older versions of Ruby.
The thing is, that now that I installed Xcode 4.3 with the command line tools (for homebrew), I found that I don't have gcc-4.2 on my system.
From what I was able to find, the usual way to install pre 1.9.3 is to either get an older version of Xcode, or using the osx-gcc-installer. I also found a warning saying that if I install osx-gcc-installer over Xcode 4.3, it will cause problems with node.js.
As I'm currently doing both iOS and node.js development alongside Ruby, I can't really do any of these things. Which means I can only work with 1.9.3, which is the only Ruby version that can be compiled with LLVM.
Is there a clean way to install any older version of Ruby without sacrificing Xcode 4.3? The solution that comes to my mind is having gcc-4.2 in some kind of non-system-wide sandbox and specify it's path when installing Ruby, but I'm not really sure how to do this properly.
Update:
See this link for the process required to get GCC-4.2 onto a machine with Xcode 4.3 without overwriting other components.
Xcode 4.3, Homebrew, and Ruby
It will obviate the need for the instructions below:
RVM should work if you set the default compiler for RVM to gcc. Place this in your .bashrc or .zshrc.
export CC=/usr/bin/gcc-4.2
RVM should then use GCC to compile.
If you don't want to have CC set permanently then you could try installing with:
CC=/usr/bin/gcc-4.2 rvm install 1.8.7

OSX Lion installation of ruby 1.8.7 (xcode command-line-tools): OpenSSL development headers... not found

I don't know exactly when, but assume with upgrade from Snow Leopard to Lion (10.7.3) my system configuration seems to be messed up. When trying to install ree-1.8.7 I am running into the same problem whatever way I try:
Checking for required software...
* Non-broken C compiler... found at /usr/bin/gcc-4.2
* Non-broken C++ compiler... found at /usr/bin/g++-4.2
* The 'make' tool... found at /usr/bin/make
* The 'patch' tool... found at /usr/bin/patch
* Zlib development headers... found
* OpenSSL development headers... not found
* GNU Readline development headers... found
Some required software is not installed.
This happens when using rvm, rbenv or running the ree installer (went through all options). Though openssl is installed and working:
openssl version
OpenSSL 0.9.8r 8 Feb 2011
I tried brewing openssl but that did not help either, so did remove it again.
I am quite desperate as I am not able to get it running. Any hints are appreciated.
EDIT: I missed the detail that I have only the xcode command-line tools installed instead of the full xcode package.
you need to tell the ./configure script where to find openssl headers
RVM forwards any --with* flags to configure, so you can pass --with-openssl-dir=... to rvm command -> https://rvm.beginrescueend.com/packages/openssl/
Using --with-openssl-dir=/usr should do the trick, but there are more options: --with-openssl-include-dir=/usr/include/openssl --with-openssl-lib-dir=/usr/lib (this might be nonstandard installation)
Also very important - ./configure will claim this flags are not recognized, it will be used in make command - check make.log in case of RVM.
Don't forget to install the proper libraries via https://github.com/kennethreitz/osx-gcc-installer. Obviously, the xcode-command-line tools that I used are missing the correct development headers.
With the answer of mpapis it should have been possible to tell the compiler the correct location, but it seems that these options are ignored in latest installer. See this forum thread (Point 3 in first post): http://discuss.joyent.com/viewtopic.php?id=25862

Resources