Cannot compile ruby 1.9.3

前端 未结 5 1880
别跟我提以往
别跟我提以往 2020-12-25 13:44

When I run

rvm install 1.9.3 --with-gcc=clang

on Mac OSX Lion, ruby does not compile, and I get the following error in (.rvm/log/ruby-1.9.3

相关标签:
5条回答
  • 2020-12-25 14:10

    you are using clang, according to this ticket http://bugs.ruby-lang.org/issues/5883 - it's not "fully" supported - you need to try using gcc-4.2, you get instructions for homebrew with running rvm requirements.

    here is RVM ticket for this problem https://github.com/wayneeseguin/rvm/issues/1480

    UPDATE: Ruby-2.0.0 actually compiles better with clang then with gcc-4.2, more details here: https://stackoverflow.com/a/15655034/497756

    0 讨论(0)
  • 2020-12-25 14:16

    If you are using rbenv and ruby-build instead of rvm, you have to define, which compiler should be used to build ruby:

    # this export must be done before every new ruby build
    export CC=gcc
    # use the version you wish to install
    rbenv install 1.9.3-p385
    

    If it doesn't work, you need to install Gnu C Compiler (gcc) first:

    brew update
    brew tap homebrew/dupes
    # install gcc, only once needed
    brew install gcc
    # You can view the installed GCC version, currently gcc-8
    brew info gcc
    # Maybe you have to tell, which gcc version must be used,
    # to get it working.
    export CC=gcc-8
    

    For older Systems or not up to date systems install old GCC 4.2 version:

    brew update
    brew tap homebrew/dupes
    # install apple-gcc, only once needed
    brew install apple-gcc42
    # Maybe you have to tell, which gcc version must be used,
    # to get it working on newer systems
    export CC=gcc-4.2
    

    Until the ruby folks build a clang compatible ruby version, you have to export the CC variable before every build of a new ruby version or simply add the export to your .bashrc oder .zshenv file.

    0 讨论(0)
  • 2020-12-25 14:30

    With Xcode 4.6 I was also getting this problem. I installed the command line tools which made gcc available in /usr/bin/gcc.

    I managed to get it to work using:

    rvm install 1.9.3 --with-gcc=gcc
    

    NB. I dont have homebrew installed.

    0 讨论(0)
  • 2020-12-25 14:31

    I solved this using Macports.

    I had problems compiling and were getting the error "Ruby 'ruby-1.9.3-p374' was built using clang - but it's not (fully) supported, expect errors."

    Github was also down for maintenance so I couldnt try compiling using brew as suggested in the previous answer... This is what I did, and it compiled fine on Mountain Lion 10.8.2:

    First install Macports

    http://www.macports.org/install.php

    Then run:

    sudo port selfupdate

    sudo port install apple-gcc42

    sudo rvm install ruby-1.9.3-p374 --with-gcc=gcc-apple-4.2

    0 讨论(0)
  • 2020-12-25 14:34

    If you don't have rvm already installed, rvm requirements won't work. Install gcc 4.2 with homebrew and restart the rvm installation. Worked for me.

    brew update
    brew tap homebrew/dupes
    brew install apple-gcc42
    
    0 讨论(0)
提交回复
热议问题