Can I upgrade to the current version of Ruby (2.2.3) on OS X v10.6.8?
I suggest that you use RVM to install Ruby.
curl -sSL https://get.rvm.io | bash -s stable --ruby
You need to restart the terminal in order to run rvm:
rvm install 2.2
rvm use 2.2 --default
How can I update Ruby version 2.0.0 to the latest version in Mac OS X v10.10 (Yosemite)?
Open your terminal and run
curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s stable
When this is complete, you need to restart your terminal for the rvm
command to work.
Now, run rvm list known
This shows the list of versions of the Ruby interpreter.
Now, run rvm install ruby@latest
to get the latest Ruby version.
If you type ruby -v
in the terminal, you should see ruby X.X.X
.
If it still shows you ruby 2.0.
, run rvm use ruby-X.X.X --default
.
Prerequisites for Windows 10:
- C compiler. You can use http://www.mingw.org/
make
command available otherwise it will complain that "bash: make: command not found". You can install it by runningmingw-get install msys-make
- Add "C:\MinGW\msys\1.0\bin" and "C:\MinGW\bin" to your path environment variable
How to update Ruby to 1.9.x on Mac?
I'll make a strong suggestion for rvm.
It's a great way to manage multiple Rubies and gems sets without colliding with the system version.
I'll add that now (4/2/2013), I use rbenv a lot, because my needs are simple. RVM is great, but it's got a lot of capability I never need, so I have it on some machines and rbenv on my desktop and laptop. It's worth checking out both and seeing which works best for your needs.
I want to change my OS X ruby version to 1.9 without using RVM
You can install it with homebrew
$ brew install ruby
But I don't really think that it's a good idea. RVM is perfect tool for managing ruby installations and gemsets.
(Mac Terminal) System message when trying to install latest ruby with RVM
The current
rvm command outputs the name of the currently active installation of Ruby; in this case, it's using your system's pre-installed Ruby (1.8.7).
Try this:
rvm install 2.0 # (or whatever version you need)
rvm use 2.0 --default # this sets the default to the 2.0 install
Best way to update Ruby to the latest 1.9 version on OS X?
Most people use RVM to install Ruby on the mac. Basically it allows you to have multiple versions of ruby installed on the same machine and to switch between them at will. You can also install gems on a project by project basis rather than installing them all globally using sudo like you probably do now.
You can install RVM by running
bash < <(curl -s https://rvm.ioinstall/rvm)
in terminal (assuming you have git installed). Full installation instructions can be found on the RVM site.
Here is a tutorial which I personally found invaluable when getting used to using RVM in my workflow at the start. It will probably help you too.
UNIX `system` command using different version of Ruby
There a few environment variables that Ruby will check when it is launched that you can use to control things like the load path and to set options.
Bundler is “infectious”, in that when you use it it adds some of these environment variables so that another Ruby process executed as a child will automatically try to use Bundler with the same Gemfile
.
Compare the output of ruby -e "puts ENV.inspect"
with bundle exec ruby -e "puts ENV.inspect"
inside a project using Bundler.
This is normally what you want to happen, so that you are always using the versions of Gems and Ruby defined in your Gemfile
.
The heroku
command includes its own installation of Ruby (it’s in /usr/local/heroku/ruby
on my machine) which it uses rather than your normal version. This is quite an old version of Ruby, mine is 1.9.3p194.
So when you use system
to run the heroku
command, the Ruby process that is created checks the environment variables and loads Bundler (using the Gem from the version of Ruby you’re using) and then tries to setup everything according to your Gemfile
. This is where the Ruby version mismatch happens.
To fix this, you need to tell Bundler not to include the various environment variables when launching a subprocess. There are a few methods that deal with this, in your case you want to use Bundler.clean_system
instead of plain system
:
Bundler.clean_system "heroku pg:psql DATABASE -c 'DELETE FROM <table name>' -a <heroku app name>"
This will allow the Heroku client to run without interference from Bundler and your Gemfile
.
Related Topics
Why Word 'Translate' Is Messing Irb
Rmagick Installation: Can't Find Magickwand.H
Stop Rails Console from Printing Out the Object at the End of a Loop
Solutions to the Annoying "Warning: Already Initialized Constant" Message
Ruby: How to Concatenate Array of Arrays into One
Rails 4 Error R14 on Heroku (Memory Quota Exceeded)
How to Write a Web Scraper in Ruby
How to Take Screenshots of Web Pages Using Ruby and a Unix Server
How to Run Selenium (Used Through Capybara) at a Lower Speed
How to Convert Nokogiri Document Object into JSON
How to Submit Polymorphic Comments on Feed? [Error]
How to Step Out of a Loop with Ruby Pry
Ruby: Most Concise Way to Use an Env Variable If It Exists, Otherwise Use Default Value
Attr_Accessor on Class Variables
Ruby/Rails - Models Named with Two Words (Naming Convention Issues)