How can I install Ruby 1.9.3 in Mac OS X Lion?

后端 未结 11 496
南旧
南旧 2020-12-04 12:21

I am trying to install Ruby 1.9.3 but am having problems. I installed RVM, then typed:

rvm install 1.9.3

The output says:

         


        
相关标签:
11条回答
  • 2020-12-04 12:42
    1. Open Xcode
    2. Open Xcode preferences
    3. Open Downloads tab
    4. Check Command Line Tools

    Xcode screenshot

    0 讨论(0)
  • 2020-12-04 12:42

    With the new Feb 2012 Command Line Tools for Xcode, using RVM 1.10.3 (and JweleryBox for Mac) Ruby 1.9.3-p125 compiles fine, without "Use clang" and with shared linking and 64 bit architecture. More over, the "gem install rails" command works flawlessly without the warning about libyaml support.

    0 讨论(0)
  • 2020-12-04 12:46

    If you want to merely install and keep up to date the latest version of Ruby (as opposed to switching between different versions of ruby), you can install ruby via homebrew:

    brew install ruby
    
    0 讨论(0)
  • 2020-12-04 12:47

    Using rvm, ruby 1.9.3, and attempting to use gcc, I couldn't get Ruby to build cleanly with yaml. While there are a variety of hacks to get yaml compilation to work, none of them seemed to work with rvm. I was troubleshooting late at night and I didn't retain my errors, so I'm working from memory here -- I would appreciate if someone else with a clean environment could test these steps.

    Using the --with-gcc=clang solution produced the mildly infamous error about the yaml parser:

    It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. 
    

    Since I need yaml for what I'm going to be doing, and libyaml compiled fine when not being run by rvm, and I even had it installed in /usr/lib after building it by hand, I can't understand why rvm couldn't find and use that version of libyaml, even with the --shared-libs option.

    Using CC=/usr/bin/gcc rvm install 1.9.3 produced errors. In the .rvm/log/ruby-1.9.3-p385/configure.log, I found the following:

    configure: error: C compiler cannot create executables
    See `config.log' for more details
    

    That error was also present in .rvm/log/libyaml-0.14/configure.log.

    The solution for me ended up being to run the rvm command with sudo. Running a compile as root seems to remove Apple's GCC toolchain's disapproval of users doing anything as dirty as compiling software.

    So sudo CC=/usr/bin/gcc rvm install 1.9.3 --disable-binary gave me a clean compile of ruby+yaml in the rvm folder. I then needed to sudo chown -R username ~/.rvm && sudo chgrp -R staff ~/.rvm to get things back in my user and running with my permissions.

    I do not recommend compiling things as root, as I see it as a security risk (especially with the vulnerabilities found in the ruby stack and rubygems.org recently) -- but this produced a clean installation of ruby under rvm and might help someone with more talent or time figure out the root cause of the issue with Apple's gcc.

    0 讨论(0)
  • 2020-12-04 12:51

    Try using the clang compiler instead of the default:

    rvm install 1.9.3 --with-gcc=clang
    
    0 讨论(0)
提交回复
热议问题