60

After update to Mountain Lion, I tried install 1.8.7, and I got error. X11 file not found, I installed Xquarkz, but nothing changed. Whats wrong?

Fail to find [tclConfig.sh, tkConfig.sh]
Use MacOS X Frameworks.

Find Tcl/Tk libraries. Make tcltklib.so which is required by Ruby/Tk.
clang -I. -I../.. -I../../. -I../.././ext/tk -DHAVE_RB_SAFE_LEVEL -DHAVE_RB_HASH_LOOKUP -DHAVE_RB_PROC_NEW -DHAVE_RB_OBJ_TAINT -DHAVE_ST_PTR -DHAVE_ST_LEN -DRUBY_VERSION=\"1.8.7\" -DRUBY_RELEASE_DATE=\"2012-06-29\"  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -DWITH_TCL_ENABLE_THREAD=0 -fno-common -g -O2  -fno-common -pipe -fno-common   -c stubs.c
In file included from stubs.c:10:
/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
#       include <X11/Xlib.h>
                ^
1 error generated.
make[1]: *** [stubs.o] Error 1
make: *** [all] Error 1
three
  • 8,262
  • 3
  • 35
  • 39
user1344853
  • 689
  • 1
  • 7
  • 8
  • possible duplicate of [Install ree-1.8.7 with RVM on Mountain Lion](http://stackoverflow.com/questions/11660673/install-ree-1-8-7-with-rvm-on-mountain-lion) – JJJ Jul 26 '12 at 09:53
  • See comment by @mat below if you don't need `tcl` or `tk` and you don't want to install X11 as @MatteoAlessani suggests – Jared Beck Oct 26 '12 at 22:20

5 Answers5

142

Try to install X11 via http://xquartz.macosforge.org/landing/ set the correct path to the X11 library for the compiler with:

export CPPFLAGS=-I/opt/X11/include

then try to reinstall ruby, passing to the compiler where gcc-4.2 is:

CC=/usr/local/bin/gcc-4.2 rvm reinstall 1.8.7

Without CC I got a lot of segmentation faults.

Matteo Alessani
  • 10,264
  • 4
  • 40
  • 57
  • Yep, exports was the one. Didn't need to do the second command as I am using rbenv. :) – kkampen Oct 01 '12 at 10:34
  • I got "You requested building with '/usr/local/bin/gcc-4.2' but it is not in your path." when doing this with the latest Mountain Lion, Command Line Tools and XQartz. Is this a new problem with the latest? – Chris Butler Oct 16 '12 at 03:25
  • 1
    Have you tried to install gcc with brew? The command is `brew install apple-gcc42` – Matteo Alessani Oct 16 '12 at 09:12
  • 1
    I get this: "Error: No available formula for apple-gcc42". I found something that said I should use "brew tap homebrew/dupes" first. After that this solution seemed to work! Thanks! – Chris Butler Oct 17 '12 at 04:36
  • 20
    Also, hum, as I will never need neither tcl nor tk : `rvm reinstall 1.8.7 --without-tcl --without-tk` – mat Oct 24 '12 at 08:21
  • 1
    @ZainZafar `-I` stands for Include, it adds to the compiler the following include dir – Matteo Alessani Nov 17 '12 at 11:31
  • If you have a newer version of XCode and don't have gcc-4.2 you can also follow this instruction but instead of `CC=/usr/local/bin/gcc-4.2` you can just run `rvm reinstall 1.8.7 --with-gcc=clang` – Tom Harrison Jan 17 '13 at 22:51
  • Tom, that rvm reinstall command returns `/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found` – Someone Somewhere Nov 08 '13 at 22:08
18

I managed to do following on OSX 10.8.2 without a problem:

rvm install 1.8.7 --with-gcc=clang --without-tcl --without-tk
Laurynas
  • 3,829
  • 2
  • 32
  • 22
  • I'm a Rails developer, so what do I need tk and tcl for? Aren't those GUI libraries? :) Thanks for the TIP - it WORKED! – Alex Kovshovik Mar 06 '13 at 22:26
  • Careful, ruby 1.8.7 is not fully compatible with clang. I got tons of segmentation faults on OSX 10.8.4 when trying to use bundler & rails with this method until I went back and installed GCC 4.2 first, then reinstalled 1.8.7. [This approach worked best for me](http://stackoverflow.com/a/12927221/406797), similar to the answer from @matteo-allesani – jzn Jul 31 '13 at 16:04
  • Thanks! installing ruby 1.8.7 on OSX 10.9 worked with that command ! – Someone Somewhere Nov 08 '13 at 22:14
5

If you don't need tcl or tk and are using rbenv, this should work:

brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb

CC=/usr/local/bin/gcc-4.2 CONFIGURE_OPTS="--without-tcl --without-tk" rbenv install 1.8.7-p358
Neal
  • 4,468
  • 36
  • 33
3

Even after the X11 fix I was getting this compile error.

compiling stubs.c
In file included from stubs.c:16:
/usr/include/tk.h:23:3: error: #error Tk 8.5 must be compiled with tcl.h from Tcl 8.5
make[2]: *** [stubs.o] Error 1
make[1]: *** [ext/tk/all] Error 2
make: *** [build-ext] Error 2

After much head scratching I noticed this line in the make output.

Use ActiveTcl libraries (if available).

Turns out I had ActiveTcl 8.4 installed installed years ago, but it was picking up tk.h from /usr/include which is version 8.5.

I couldn't figure out how to safely uninstall ActiveTcl and the ActiveTcl uninstall instructions weren't correct, but I did install ActiveTcl 8.5 and that worked around the issue. ActiveTcl Download here.

Frustrating. Anyway hope this helps someone else.

bgebhardt
  • 31
  • 1
0

Here's my .rvmrc bootstrap file for now, hope it helps:

if (uname -a | grep '12.0.0 Darwin' >/dev/null); then
    CC=/usr/local/bin/gcc-4.2 CPPFLAGS=-I/opt/X11/include rvm --install --create --disable-tcl --disable-tk use ree@gemset_name
else
    rvm --install --create --disable-tcl --disable-tk use ree@gemset_name
fi

if ! which bundle >/dev/null; then
    gem install bundler --pre --no-ri --no-rdoc && bundle install
fi


if ! bundle check >/dev/null; then
    bundle install
fi
Riku Räisänen
  • 158
  • 1
  • 4