How can I install Ruby on Rails 3 on OSX?

后端 未结 7 909
死守一世寂寞
死守一世寂寞 2020-12-24 03:26

I got a White Macbook and I have to go to a conference in 10 hours but I\'m having a lot of problems.

First, I wanted to have Rails 3, so I used MacPorts to install

相关标签:
7条回答
  • 2020-12-24 04:00

    I would strongly recommend using RVM (Ruby Version Manager) to keep your Rails 3 separate from your Rails 2. (One example of Rails 2 conflicting with Rails 3: when you go to the command line to generate a Rails app, will it generate a Rails 2 app or a Rails 3 app? RVM allows you to keep them separate.)

    Also, the latest Ruby 1.8.7 will probably not work with Rails 3, so you have to use an earlier patchlevel (248 works for me). Details are here: http://techiferous.com/2010/02/installing-rails-3-beta-with-rvm-and-ruby-1-8-7/

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

    To easily setup Rails 3 on osx machine the only thing you need to do is follow this brilliant (as always) Railscast, here for the transcription

    You can also see comments to check for problems and eventually solutions.

    0 讨论(0)
  • 2020-12-24 04:05

    You should indeed use rvm, but as no one explained to you how to do this without rvm, here you go:

    sudo gem install tzinfo builder memcache-client rack rack-test rack-mount \
      abstract erubis activesupport mime-types mail text-hyphen text-format   \
      thor i18n rake bundler arel railties rails --prerelease --force
    
    0 讨论(0)
  • 2020-12-24 04:07

    First you need to install RVM, then the latest version of Ruby. Next you'll set that version of Ruby as the default. Finally, you'll install Rails b3.

    Install RVM (http://rvm.beginrescueend.com/rvm/install/):

    bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
    

    Install the latest Ruby (http://rvm.beginrescueend.com/rubies/installing/):

    rvm install ruby-head
    

    You can check which versions you now have installed with:

    rvm list
    

    Set the latest version of Ruby as default (replace 'ruby-1.9.2-head' with desired version):

    rvm ruby-1.9.2-head --default
    

    Make sure things are up to day, then install the Rails beta:

    gem update --system
    gem install rails --pre
    

    You may have to install some gem dependencies before Rails will install.

    0 讨论(0)
  • 2020-12-24 04:11

    You may have two different versions of Ruby installed. Try "gem env" or "sudo gem env" and see which version of Ruby it says you have.

    Remove the older one if you have two installed. If all else fails, upgrade to 1.9.x, I believe it is recommended for Rails 3 anyway.

    0 讨论(0)
  • 2020-12-24 04:15

    You should use rvm as others have said to manage multiple installations of Ruby and Ruby gems. (If you go that way, take the time to read rvm's documentation carefully.)

    However, you should also get comfortable figuring out what version of Ruby your shell is seeing as the default and why. It sounds to me like your $PATH variable may not be properly updated. The $PATH variable is what determines which Ruby interpreter or gem command is the first seen, if you have more than one installed (as you now do). MacPorts will install new binaries into /opt/local/bin by default, and it should also alter your $PATH so that /opt/local/bin precedes /usr/bin (which is where Apple's out of the box Ruby lives).

    I suspect that when you did sudo gem install, you were using /usr/bin/gem (which is the gem installer for /usr/bin/ruby rather than /opt/local/bin/gem (which would be the installer for MacPort's Ruby).

    Check the output of echo $PATH, which ruby and which gem to see what's going on.

    0 讨论(0)
提交回复
热议问题