1

I am attempting to install Ruby 1.9.3 using clang. I tried the following and it didn't work:

rvm install 1.9.3-p125 --with-gcc=clang

rvm install 1.9.3 --with-gcc=clang --with-readline-dir=$rvm_path/usr

The error I get is the readline related error in the make log:

readline.c:1499:9: error: use of undeclared identifier 'username_completion_function'; did you mean 'rl_username_completion_function'?
                                    rl_username_completion_function);
                                    ^
readline.c:69:42: note: expanded from macro 'rl_username_completion_function'
# define rl_username_completion_function username_completion_function
                                         ^
/usr/local/include/readline/readline.h:443:14: note: 'rl_username_completion_function' declared here
extern char *rl_username_completion_function PARAMS((const char *, int));
             ^
1 error generated.
make[2]: *** [readline.o] Error 1
make[1]: *** [ext/readline/all] Error 2
make: *** [build-ext] Error 2

as well as this clang error for the first attempt: (rvm install 1.9.3-p125 --with-gcc=clang)

clang: error: unsupported option '--with-libyaml'
clang: error: unsupported option '--with-libyaml'

and for the second attempt: (rvm install 1.9.3 --with-gcc=clang --with-readline-dir=$rvm_path/usr)

clang: error: unsupported option '--with-readline'
clang: error: unsupported option '--with-opt-dir=/Users/andrewjl/.rvm/usr'
clang: error: unsupported option '--with-readline'
clang: error: unsupported option '--with-opt-dir=/Users/andrewjl/.rvm/usr'

Given what I learned here, my guess is that clang is not recognizing my command line arguments to use specific gcc and/or specific readline directory.

My RVM is: rvm 1.14.3 (master)

My Clang is:

Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix

Here is my GCC:

andrewjl$ /usr/bin/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)

I tried the method here and it didn't work for me. Specifically I installed Xcode 4.1 with command line tools and made sure to get openssl and readline updated. Does anybody know anything else I can try?

Community
  • 1
  • 1
Andrew Lauer Barinov
  • 5,694
  • 10
  • 59
  • 83
  • possible duplicate of [Installing Ruby 1.9.3 Troubles with Clang](http://stackoverflow.com/questions/11236654/installing-ruby-1-9-3-troubles-with-clang) - Ruby Clang support is limited and should be avoided! – mpapis Jun 29 '12 at 00:16
  • Ok, can I go with gcc 4.2? I believe that's what I used previously and it worked well. I'm trying to use the gcc that comes with Xcode 4.3 CL in order to install Ruby and having trouble finding / setting it during the rvm install process. – Andrew Lauer Barinov Jun 29 '12 at 01:52

2 Answers2

2

Your "GCC" is still LLVM-based. When installing ruby-1.9.3-p125, you shouldn't need to and probably shouldn't at all set --with-gcc=clang as RVM will automatically figure it out now.

Have you already tried installing that ruby without that option? If you're still having trouble, please tell me what exact Xcode version you have installed and we can proceed from there. gcc version 4.2.1 could be anywhere from 4.2.x to 4.5 DP2. Consider stopping by #rvm in Freenode IRC (http://webchat.freenode.net/?channels=rvm) and I (Remear) or mpapis can assist you further.

Some clarifying information:

All Xcode versions up to about 4.1 shipped with the standard GCC-based compiler. Starting with Xcode 4.2.x, Apple introduced the LLVM-based compiler and started to phase out the GCC-based one. Xcode 4.3 comes with only the LLVM compiler, no GCC. Ruby 1.8.x require GCC for compilation. Ruby 1.9.3-p0 had slight support for LLVM but you were lucky to get it installed. Ruby 1.9.3-p125 or newer has improved compatibility with the LLVM compiler.

So here's the breakdown of what you need to install pretty much any ruby:

Ruby 1.8.x, Ruby 1.9.3-p0

Xcode 4.1 or osx-gcc-installer

Ruby 1.9.3-p125 or newer

Xcode 4.1 or osx-gcc-installer

or

Xcode 4.2.x or newer with Xcode Command Line Tools installed (this gives you back GCC in addition to LLVM)

Remear
  • 1,927
  • 12
  • 19
  • Hey, thanks for the response. I'd like to go with the 3rd method (have Xcode 4.3.3 plus CL tools both installed now), still getting errors when running plain old `rvm install 1.9.3`. I'm andrewjl88 on IRC, pinged you earlier ago so welcome to reply anytime. Thanks again. – Andrew Lauer Barinov Jun 28 '12 at 21:53
  • Sorry I missed you. I'm on more during the night MST but try to leave at least one machine on for messages. Ping me when you're around again and keep at it until we connect up. – Remear Jul 03 '12 at 16:34
  • No worries, I actually fixed everything myself. Turns out the command line syntax changed and that's what was tripping me up. Serves me right for not RTFM :) – Andrew Lauer Barinov Jul 03 '12 at 18:54
1

Seems like RVM changed something on the command line, the following (changed) format works for me:

rvm pkg install readline

followed by:

rvm install 1.9.3 -C "--with-readline-dir=$HOME/.rvm/usr"
Andrew Lauer Barinov
  • 5,694
  • 10
  • 59
  • 83
  • I checked with mpapis, the current maintainer of RVM, and he said it shouldn't need -C. If it indeed does, it's a bug. If you weren't able to get it to work without -C, please file an issue at https://github.com/wayneeseguin/rvm/issues so he can look into it. – Remear Jul 04 '12 at 00:36