checking whether the C compiler works... no - ruby

I recently uninstalled Xcode 4.2 and re-installed Xcode 4.3.1. Installed Command Line Tools also. The error says 'C compiler doesn't work`. On searching for this error, it said that it happens when Xcode is not installed. What am I missing?
rvm install 1.9.3 --with-gcc=clang
Installing Ruby from source to: /Users/ava/.rvm/rubies/ruby-1.9.3-preview1, this may take a while depending on your cpu(s)...
ruby-1.9.3-preview1 - #fetching
ruby-1.9.3-preview1 - #extracting ruby-1.9.3-preview1 to /Users/ava/.rvm/src/ruby-1.9.3-preview1
ruby-1.9.3-preview1 - #extracted to /Users/ava/.rvm/src/ruby-1.9.3-preview1
Fetching yaml-0.1.4.tar.gz to /Users/ava/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/ava/.rvm/src
Configuring yaml in /Users/ava/.rvm/src/yaml-0.1.4.
ERROR: Error running ' ./configure --prefix="/Users/ava/.rvm/usr" --with-gcc=clang --build=x86_64-apple-darwin11.3.0 --host=x86_64-apple-darwin11.3.0 --build=x86_64-apple-darwin11.3.0 --host=x86_64-apple-darwin11.3.0 ', please read /Users/ava/.rvm/log/ruby-1.9.3-preview1/yaml/configure.log
Compiling yaml in /Users/ava/.rvm/src/yaml-0.1.4.
ERROR: Error running '/usr/bin/make ', please read /Users/ava/.rvm/log/ruby-1.9.3-preview1/yaml/make.log
Installing yaml to /Users/ava/.rvm/usr
ERROR: Error running '/usr/bin/make install', please read /Users/ava/.rvm/log/ruby-1.9.3-preview1/yaml/make.install.log
ruby-1.9.3-preview1 - #configuring
ERROR: Error running ' ./configure --prefix=/Users/ava/.rvm/rubies/ruby-1.9.3-preview1 --enable-shared --disable-install-doc --with-gcc=clang --build=x86_64-apple-darwin11.3.0 --host=x86_64-apple-darwin11.3.0 --build=x86_64-apple-darwin11.3.0 --host=x86_64-apple-darwin11.3.0 --with-libyaml-dir=/Users/ava/.rvm/usr ', please read /Users/ava/.rvm/log/ruby-1.9.3-preview1/configure.log
ERROR: There has been an error while running configure. Halting the installation.
➜ yaml git:(master) ✗ vi configure.log
[2012-03-18 21:03:00] ./configure --prefix="/Users/ava/.rvm/usr" --with-gcc=clang --build=x86_64-apple-darwin11.3.0 --host=x86_64-apple-darwin11.3.0 --build=x86_64-apple-darwin11.3.0 --host=x86_64-apple-darwin11.3.0
configure: WARNING: unrecognized options: --with-gcc
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for x86_64-apple-darwin11.3.0-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/ava/.rvm/src/yaml-0.1.4':
configure: error: C compiler cannot create executables
See `config.log' for more details
➜ ~ git:(master) ✗ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
➜ ~ git:(master) ✗ which gcc
/usr/bin/gcc

In the Terminal:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Also, in Xcode, make sure the Command Line Tools are installed. Choose Xcode > Preferences, click on Downloads, and if necessary, click the Install button next to "Command Line Tools".

you use old RVM which does not know about latest ruby pathclevel, update with rvm get head
Ruby is not yet fully ready for LLVM, your get best chances for compilation using osx-gcc-installer and --with-gcc=gcc-4.2

I fixed it by running :
rvm install <ruby-version> --with-gcc=clang
Replace < ruby-version> with version you want to use

For those out there running into the same problem,
System (in order of installation)
OSX 10.7.3
RVM
XCode 4.3
Developer Tools (through XCode Preferences > Downloads)
OSX-GCC-Installer-10.7
I had set LDFLAGS and CPPFLAGS to point to Homebrew installations, this resulted in errors. I "unlinked" LDFLAGS and CPPFLAGS, ran 'rvm install 1.9.2' and everything worked fine.
rvm install 1.9.2

Try ./configure --without-gcc to use clang.

I'm on Mavericks and the provided answers didn't work for me. However, updating my version of Xcode and making sure Command Line Tools are installed did the trick.

It is a lot easier to install by using the compiler the system knows about
1. rvm install ruby-1.9.3-p547 --with-gcc=`echo which gcc`

Related

I am not able to install ruby via rvm

My Config log file is -
./configure
current path: /home/username/.rvm/src/ruby-2.1.6
PATH=/usr/local/jdk/bin:/home/username/perl5/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home/username/.rvm/bin:/home/username/bin:/home/username/.rvm/bin
command(4): ./configure --prefix=/home/username/.rvm/rubies/ruby-2.1.6 --disable-install-doc --enable-shared
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/username/.rvm/src/ruby-2.1.6':
configure: error: C compiler cannot create executables
See `config.log' for more details
gcc already installed -
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)
I guess you do not have the required packages (dependencies) to install ruby via rvm.
Following steps should help you out:
yum install gcc-c++ patch readline readline-devel zlib zlib-devel
yum install libyaml-devel libffi-devel openssl-devel make
yum install bzip2 autoconf automake libtool bison iconv-devel
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 2.1.2
rvm use 2.1.2 --default
Now check your ruby version:
ruby --version
Check out http://tecadmin.net/install-ruby-2-1-on-centos-rhel/ for more details
There must be some problem with your host compiler GCC.
Another issue may be binutils.
At any rate, you should first try to see if you can compile other C-based programs.
I also recommend you wget ftp://ftp.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.xz extract it and have a look what happens if you compile it (you can compile into an /opt prefix for now; you can use rvm lateron anyway; ./configure --prefix=/opt/ruby/2.2.2; make; make install)
This may possibly fail, have a look at config.log then. Often, but not always, config.log will have the specific error.
I assume that your compile toolchain is not complete.

brew install gcc46 fails with Clang/xcrun error

I'm trying to use RVM to install ruby 1.9.2 and 1.9.3. It fails because one of the dependencies seems to be gcc46, and rvm uses brew to install it.
rbanerjee:~ $ sudo brew install gcc46
==> Installing dependencies for gcc46: gmp4, mpfr2, libmpc08, ppl011, cloog-ppl015
==> Installing gcc46 dependency: gmp4
==> Downloading ftp://ftp.gmplib.org/pub/gmp-4.3.2/gmp-4.3.2.tar.bz2
Already downloaded: /Library/Caches/Homebrew/gmp4-4.3.2.tar.bz2
==> Patching
==> ./configure --prefix=/usr/local/Cellar/gmp4/4.3.2 --enable-cxx --build=x86_64-apple-darwin
checking ABI=64
checking compiler clang ... no
checking ABI=32
checking compiler clang ... no
configure: error: could not find a working compiler, see config.log for details
but clang is there and working:
rbanerjee:~ $ which clang
/usr/bin/clang
rbanerjee:~ $ clang -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
Weird that the version is 4.2, since I have Xcode 4.6.3 and command line tools 4.6.3 installed. xcrun seems to be a problem too. Digging through the gcc46 logs leads to a failure to install gmp4:
in ~/Library/Logs/Homebrew/gmp4/config.log
/usr/local/Library/ENV/4.3/clang:338:in `exec': No such file or directory - xcrun (Errno::ENOENT)
from /usr/local/Library/ENV/4.3/clang:338
Any ideas? Thanks in advance. OSX Lion. Here's all my system info:
https://gist.github.com/anonymous/9e2cdb6c0d0ca0b29eba

Errors installing Ruby 1.9.3 using RVM

I'm trying to install Ruby 1.9.3-p385 on my work machine using Mountain Lion.
I've installed RVM and run
rvm install 1.9.3
But I get this error...
Error running 'env LDFLAGS=-L/opt/sm/pkg/active/lib CFLAGS=-I/opt/sm/pkg/active/include CPATH=/opt/sm/pkg/active/include ./configure --disable-install-doc --prefix=/usr/local/rvm/rubies/ruby-1.9.3-p385 --with-opt-dir=/usr/local/rvm/usr --disable-shared', please read /usr/local/rvm/log/ruby-1.9.3-p385/configure.log
There has been an error while running configure. Halting the installation.
This is the contents of configure.log that the error points to...
[2013-02-18 10:10:50] ./configure
checking build system type... x86_64-apple-darwin12.2.1
checking host system type... x86_64-apple-darwin12.2.1
checking target system type... x86_64-apple-darwin12.2.1
checking whether the C compiler works... no
configure: error: in `/usr/local/rvm/src/ruby-1.9.3-p385':
configure: error: C compiler cannot create executables
See `config.log' for more details
It's all a bit cryptic to me. If anyone can help it would be appreciated.
This is problem with railsinstaller default settings, check this answer https://stackoverflow.com/a/12929017/497756
See this question and my answer.
To sum up, install MacPorts and run:
sudo port selfupdate
sudo port install gcc-apple42
CC=/opt/local/bin/gcc-apple-4.2 rvm install ruby-1.9.3-p194 --enable-shared --without-tk --without-tcl

Can't install Ruby 1.9.3 on Mountain Lion with rvm; Homebrew can't find libksba library

I can't get rvm to install Ruby 1.9.3; it keeps on asking for the Homebrew library 'libksba' even though it is already downloaded and installed. When I run the 'brew list' command it shows clearly.
I also have Xcode 4.5 installed.
Is this an environmental variables configuration issue, and I need to configure the path so that they can see each other? If it is, how do I configure it?
How do Homebrew and rvm work together? I'm not clear about this.
Thank you.
rvm install 1.9.3
Ruby (and needed base gems) for your selection will be installed shortly.
Before it happens, please read and execute the instructions below.
Please use a separate terminal to execute any additional commands.
Notes for Mac OS X 10.8.2, Xcode 4.5.2.
For JRuby: Install the JDK. See http://developer.apple.com/java/download/ # Current Java version "1.6.0_26"
For IronRuby: Install Mono >= 2.6
For Ruby 1.9.3: Install libksba # If using Homebrew, 'brew install libksba'
For Opal: Install Nodejs with NPM. See http://nodejs.org/download/
To use an RVM installed Ruby as default, instead of the system ruby:
rvm install 1.8.7 # installs patch 357: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.8.7
And reopen your terminal windows.
Xcode and gcc:
:
'brew list' command output
brew list
apple-gcc42 automake libgpg-error libxml2
autoconf git libksba libxslt
Most recent session:
brew upgrade libksba
Error: libksba-1.2.0 already installed
$ brew update
Updated Homebrew from 5909e2c6 to 0e0ef31f.
==> New Formulae
globus-toolkit postgres-xc
==> Updated Formulae
casperjs cunit dxflib mysql-cluster smake
cdrtools dvdrtools ivy shmcat webalizer
==> Deleted Formulae
transcode
unknown7cd1c3e98b07:~ pdenlinger$ rvm install 1.9.3
Ruby (and needed base gems) for your selection will be installed shortly.
Before it happens, please read and execute the instructions below.
Please use a separate terminal to execute any additional commands.
Notes for Mac OS X 10.8.2, Xcode 4.5.2.
For JRuby: Install the JDK. See http://developer.apple.com/java/download/ # Current Java version "1.6.0_26"
For IronRuby: Install Mono >= 2.6
For Ruby 1.9.3: Install libksba # If using Homebrew, 'brew install libksba'
For Opal: Install Nodejs with NPM. See http://nodejs.org/download/
To use an RVM installed Ruby as default, instead of the system ruby:
rvm install 1.8.7 # installs patch 357: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.8.7
And reopen your terminal windows.
Xcode and gcc:
:
Added C compiler error:
rvm install 1.9.3
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-1.9.3-p362.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-1.9.3-p362, this may take a while depending on your cpu(s)...
ruby-1.9.3-p362 - #downloading ruby-1.9.3-p362, this may take a while depending on your connection...
ruby-1.9.3-p362 - #extracted to /usr/local/rvm/src/ruby-1.9.3-p362 (already extracted)
ruby-1.9.3-p362 - #configuring
Error running 'env LDFLAGS=-L/opt/sm/pkg/active/lib CFLAGS=-I/opt/sm/pkg/active/include CPATH=/opt/sm/pkg/active/include ./configure --enable-shared --disable-install-doc --prefix=/usr/local/rvm/rubies/ruby-1.9.3-p362 --with-opt-dir=/usr/local/rvm/usr', please read /usr/local/rvm/log/ruby-1.9.3-p362/configure.log
There has been an error while running configure. Halting the installation.
$ cat /usr/local/rvm/log/ruby-1.9.3-p362/configure.log
[2013-01-01 20:20:35] env LDFLAGS=-L/opt/sm/pkg/active/lib CFLAGS=-I/opt/sm/pkg/active/include CPATH=/opt/sm/pkg/active/include ./configure --enable-shared --disable-install-doc --prefix=/usr/local/rvm/rubies/ruby-1.9.3-p362 --with-opt-dir=/usr/local/rvm/usr
checking build system type... x86_64-apple-darwin12.2.1
checking host system type... x86_64-apple-darwin12.2.1
checking target system type... x86_64-apple-darwin12.2.1
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
Environmental variable flags:
$ brew update
Already up-to-date.
$ brew tap homebrew/dupes
Error: Already tapped!
$ brew install autoconf automake apple-gcc42
Error: autoconf-2.69 already installed
Error: automake-1.12.6 already installed
Error: apple-gcc42-4.2.1-5666.3 already installed
$ rvm pkg install openssl
Fetching openssl-1.0.1c.tar.gz to /usr/local/rvm/archives
Extracting openssl to /usr/local/rvm/src/openssl-1.0.1c
Configuring openssl in /usr/local/rvm/src/openssl-1.0.1c.
Compiling openssl in /usr/local/rvm/src/openssl-1.0.1c.
Installing openssl to /usr/local/rvm/usr
Please note that it's required to reinstall all rubies:
rvm reinstall all --force
Updating openssl certificates
$ rvm reinstall all --force
$ rvm install 1.9.3
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-1.9.3-p362.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-1.9.3-p362, this may take a while depending on your cpu(s)...
ruby-1.9.3-p362 - #downloading ruby-1.9.3-p362, this may take a while depending on your connection...
ruby-1.9.3-p362 - #extracted to /usr/local/rvm/src/ruby-1.9.3-p362 (already extracted)
ruby-1.9.3-p362 - #configuring
Error running 'env LDFLAGS=-L/opt/sm/pkg/active/lib CFLAGS=-I/opt/sm/pkg/active/include CPATH=/opt/sm/pkg/active/include ./configure --enable-shared --disable-install-doc --prefix=/usr/local/rvm/rubies/ruby-1.9.3-p362 --with-opt-dir=/usr/local/rvm/usr', please read /usr/local/rvm/log/ruby-1.9.3-p362/configure.log
There has been an error while running configure. Halting the installation.
unknown7cd1c3e98b07:~ pdenlinger$ cat /usr/local/rvm/log/ruby-1.9.3-p362/configure.log
[2013-01-02 09:58:08] env LDFLAGS=-L/opt/sm/pkg/active/lib CFLAGS=-I/opt/sm/pkg/active/include CPATH=/opt/sm/pkg/active/include ./configure --enable-shared --disable-install-doc --prefix=/usr/local/rvm/rubies/ruby-1.9.3-p362 --with-opt-dir=/usr/local/rvm/usr
checking build system type... x86_64-apple-darwin12.2.1
checking host system type... x86_64-apple-darwin12.2.1
checking target system type... x86_64-apple-darwin12.2.1
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
$ cat config.log
cat: config.log: No such file or directory
$
What you see is output of rvm requirements it is show using less => use up/down arrows to navigate and q to quit less and continue installation.
The requirements are shown only first time you install ruby.
It was a bug and the broken code is already fixed https://github.com/wayneeseguin/rvm/commit/848ef50f1b32c87e853f21e801f167a39e8c9c66

Error building gems in Mountain Lion

I just bought a new MacBook Pro (obviously w/ML). First thing I'm doing is installing development tools. I installed Ruby with rvm and I've also got Homebrew installed. I had to download the XCode command line tools.
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
I was able to install the mongo gem fine, but when I try to install nokogiri, I get the following errors:
$ gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/johnsmith/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
checking for libxml/parser.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
After that message, it lists a whole bunch of configuration options, and then says:
/Users/johnsmith/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:369:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
It seems that I have the development tools, so I can't figure out the problem. Any thoughts?
I had to look around a while, but I found the solution at github:
https://github.com/sparklemotion/nokogiri/issues/442#issuecomment-7978408
libxml2 is missing.
I found one extra step was required to solve the above for Homebrew
0.9 on Mac OS X 10.8 Mountain Lion and that is to create a "/usr/bin/gcc-4.2" link:
brew install libxml2 libxslt
brew link libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar xvfz libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/Cellar/libiconv/1.13.1
make
sudo make install
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
In this case, you need the development headers for libxml which are not provided as part of the compiler tools. Usually you will need to install one of Homebrew or MacPorts to help install these dependencies.
The hint here is somewhat hard to spot in the noise if you're not familiar, but is:
checking for libxml/parser.h... *** extconf.rb failed ***
The .h files are provided with the development packages and are necessary to compile extensions against those libraries.

Resources