Ruby, rubygems and rails conflict with stock Mac OS X Leopard files - ruby

Ok guys, so I've been trying to install ruby on my mac for the past two days. What seems to be happening is that there's a conflict between the stock ruby, rubygems and rails from Mac OS X Snow Leopard and the ones I'm trying to install.
I'm using rvm to get the files, therefore I'm running rvm install 1.9.2. Installation seems to go normally, but when I run ruby -v, it shows me the old version (1.8.7). Same goes for rubygems. While rvm should installs it, when I run gem -v, old version is shown (1.3.5). \
This screenshot shows what I'm saying: http://cl.ly/2a3m1v0u331i272z2J22
Thank you.

Once you've installed RVM, you also need to tell you system that you want to use that version of Ruby. This is usually done via:
rvm use 1.9.2
However, when you open a new shell, it will revert back to the system default. If you want to set 1.9.2 as your default ruby, use:
rvm --default use 1.9.2
I suggest you look through the documentation a bit more to help you get the most out of RVM:
Basics: https://rvm.beginrescueend.com/rvm/basics/
Best Practices: https://rvm.beginrescueend.com/rvm/best-practices/

Check your PATH variable.
echo $PATH
/usr/local/bin should be before /usr/bin.
If not so - change it in your /Users/Your_name/.bash_profile

Related

Can I upgrade to the current version of Ruby (2.2.3) on OS X v10.6.8?

I'm looking at "Install Ruby on Rails · Mac OS X Yosemite", and in the instructions it says to update your OS which I don't really want to do because my computer is getting old.
I also found "How to update Ruby to 1.9.x on Mac?". As far as I can tell, I don't have RVM and I'm afraid of yet another install, in case my system requirements still aren't good enough.
Ultimately, I'm trying to update Jekyll, but I need to update my system a little bit first. I need Ruby 1.9.3 or later. Will "How to update Ruby to 1.9.x on Mac?" work? I'm running Ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0]'.
EDIT: I did end up getting RVM installed. For those who find this page in the future, I ran into these issues/help pages:
How to resolve "gpg: command not found" error during RVM installation?
OS X Mavericks install rvm WARNING * WARNING: You have '~/.profile' file...
RVM installation missing $PATH * WARNING: Above files containsPATH=with no$PATHinside
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
This is what worked for me
\curl -sSL https://get.rvm.io | bash -s stable --ruby
For the most up-to-date info on how to do this, check this documentation.
You do not need the latest version of OSX to run an updated version of Ruby. Whether or not you need something more current than 10.6.8 to run 2.2.3 I cannot tell. But 1.9.3 should build just fine and 2.2.3 likely will as well.
Using rvm (or rbenv, or ruby-build, or whatever) is certainly an option if you are simply doing development. Then you can have multiple ruby versions at your command without having to disturb the system ruby. Be aware these are not a panacea. Each has its own complexities and egocentricities. Go to the project websites and read the documentation carefully or you can easily get betrayed by your assumptions about how things 'should' work.
All of ruby version managers should install on any version of OSX that supports the build tools required by the Ruby that you want to host. However, be aware you will need installed the OSX xcode application for your system (available free from the Apple App Store but you need an account) and you will need the optional command line tools for xcode as well (also from the App Store).
If you want to update the system ruby then take a look at either the homebrew or macports projects. These provide up to date versions of many, many linux projects for OSX, including Ruby (and git). You will need to meet the same xcode requirements. A build is a build wherever the binaries end up.
The system from which I am writing this answer once ran Snow Leopard and I had at least Ruby 1.9 dot something installed on it via Ports. I am currently paused at 10.9.5 and am running:
ruby --version
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin13]
Without any problems.
In case anyone bumps into the same error I did: “Requirements installation failed with status: 1.”, you need to install homebrew.
Use this:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

(Mac Terminal) "System" message when trying to install latest ruby with RVM

I'm a total newbie when it comes to using Terminal, so I don't really understand what's happening here when I try to upgrade my ruby version (1.8.7) with rvm on a Mac OS X 10.7.3.
When I input
rvm install current && rvm use current
I get this
system
system
What does this mean? And how can I proceed with the installation of the latest version?
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

How to update system Ruby to 1.9.2 on Mac?

I saw an answer saying I should use RVM. But I don't know how even after:
$ rvm system
$ rvm current
system
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
The title of the question, "How to update system Ruby to 1.9.2 on Mac" makes me wonder if you are trying to upgrade Apple's installation of Ruby 1.8.7 to 1.9.2. If that is true, STOP and do NOT try that. The Ruby installed by Apple is for their use, and apps installed by Apple use it.
find /usr -name '*.rb'
will list the reasons why.
RVM and other apps allow you to install Ruby safely, so unless you have very good knowledge of how Unix and the Mac work I strongly recommend you stick to them.
A very common problem we see is that the installation wasn't completed. Read the "Installation" section in the RVM installation page to double-check you've completed everything.
To install Ruby 1.9.2 do:
rvm notes
and read and install the needed dependencies. Then do:
rvm install 1.9.2
rvm use 1.9.2 --default
will tell RVM to always use 1.9.2 as a default. You can switch to the system version installed by Apple using:
rvm use system
and switch back using
rvm default
If you don't want an RVM-based solution:
Download and install Apple's Xcode developer tools so you get GCC et al, the ability to build your own software. (This is 4.25GB, but you only need to download it once.)
Download and extract the Ruby Source Code. (10.6MB)
Open a Terminal window and change into the directory of the source code.
Run the command ./configure && make; get a cup of tea while you wait
Run the command sudo make install to install this Ruby; you'll need to supply your administrator password
Modify your PATH environment variable to put /usr/local/bin in front of /usr/bin (so that your new Ruby is found before the system Ruby). You can do this by creating or editing a .profile file in your home directory to have the line:
export PATH="/usr/local/bin::$PATH"
If you're running TextMate, you'll also want to go to TextMate ▸ Preferences ▸ Advanced ▸ Shell Variables
and add or edit a PATH variable like this:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
After this, rvm use system will use your 1.9.2p180 (the current version as of this post) install.
I'm assuming you're not sure how to install a new version of ruby with RVM - try:
rvm install 1.9.2
To then make it the default version to use:
rvm use 1.9.2 --default
Consider also: "for OS X try using RailsInstaller for OS X or try the official RVM GUI JewelryBox" -- Quoted from from the 4rd or 5th screen the RVM install page found here http://rvm.io/rvm/install
Whatever you do do not touch or mess with the system default Ruby that ships with your Mac I did that to see what would and my system was out of whack. If you would like to use a different version of Ruby use rvm.

How to update Ruby to 1.9.x on Mac?

I have created a new user account on my mac and I am trying to update to the current version of ruby on it (1.9.2) from the snow leopard default of 1.8.7. Can somebody point me to tutorial or explain the best method to update Ruby on my mac from 1.8 to 1.9.2? Thanks
As The Tin Man suggests (above) RVM (Ruby Version Manager) is the Standard for upgrading your Ruby installation on OSX: https://rvm.io
To get started, open a Terminal Window and issue the following command:
\curl -L https://get.rvm.io | bash -s stable --ruby
( you will need to trust the RVM Dev Team that the command is not malicious - if you're a paranoid penguin like me, you can always go read the source: https://github.com/wayneeseguin/rvm ) When it's complete you need to restart the terminal to get the rvm command working.
rvm list known
( shows you the latest available versions of Ruby )
rvm install ruby-2.3.1
For a specific version, followed by
rvm use ruby-2.3.1
or if you just want the latest (current) version:
rvm install current && rvm use current
( installs the current stable release - at time of writing ruby-2.3.1 - please update this wiki when new versions released )
Note on Compiling Ruby: In my case I also had to install Homebrew Link to get the gems I needed (RSpec) which in turn forces you to install Xcode (if you haven't already) https://itunes.apple.com/us/app/xcode/id497799835 AND/OR install the GCC package from: https://github.com/kennethreitz/osx-gcc-installer to avoid errors running "make".
Edit: As of Mavericks you can choose to install only the Xcode command line tools instead of the whole Xcode package, which comes with gcc and lots of other things you might need for building packages. It can be installed by running xcode-select --install and following the on-screen prompt.
Examples: https://rvm.io/workflow/examples/
Screencast: http://screencasts.org/episodes/how-to-use-rvm
Note on erros: if you get the error "RVM is not a function" while trying this command,
visit: How do I change my Ruby version using RVM? for the solution.
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.
With brew this is a one-liner:
(assuming that you have tapped homebrew/versions, which can be done by running brew tap homebrew/versions)
brew install ruby193
Worked out of the box for me on OS X 10.8.4. Or if you want 2.0, you just brew install ruby
More generally, brew search ruby shows you the different repos available, and if you want to get really specific you can use brew versions ruby and checkout a specific version instead.
I know it's an older post, but i wanna add some extra informations about that.
Firstly, i think that rvm does great BUT it wasn't updating ruby from my system (MAC OS Yosemite).
What rvmwas doing : installing to another location and setting up the path there to my environment variable ... And i was kinda bored, because i had two ruby now on my system.
So to fix that, i uninstalled the rvm, then used the Homebrew package manager available here and installed ruby throw terminal command by doing brew install ruby.
And then, everything was working perfectly !
The ruby from my system was updated !
Hope it will help for the next adventurers !
I'll disagree with The Tin Man here. I regard rbenv as preferable to RVM. rbenv doesn't interfere drastically with your shell the way RVM does, and it lets you add separate Ruby installations in ordinary folders that you can examine directly. It allows you to compile Ruby yourself. Good outline of the differences here: https://github.com/sstephenson/rbenv/wiki/Why-rbenv%3F
I provide instructions for compiling Ruby 1.9 for rbenv here. Further, more detailed information here. I have used this technique with easy success on Snow Leopard, Lion, and Mountain Lion.
Dan Benjamin's Hivelogic article Installing Ruby, RubyGems, and Rails on Snow Leopard is the recommended place to go although the article is for 1.8, so here's a Ruby 1.9-specific install on Snow Leopard. Watch out for the 64-bit thing... either go all 64-bit 'fat' (as is - for example - Apache on OS X, which can cause problems with 32-bit libraries) or check any gems you're likely to use to make sure they're okay for 64-bit.
This command actually works
\curl -L https://get.rvm.io | bash -s stable --ruby
As previously mentioned, the bundler version may be too high for your version of rails.
I ran into the same problem using Rails 3.0.1 which requires Bundler v1.0.0 - v1.0.22
Check your bundler version using: gem list bundler
If your bundler version is not within the appropriate range, I found this solution to work: rvm #global do gem uninstall bundler
Note: rvm is required for this solution... another case for why you should be using rvm in the first place.
There are several other version managers to consider, see for a few examples and one that's not listed there that I'll be giving a try soon is ch-ruby. I tried rbenv but had too many problems with it. RVM is my mainstay, though it sometimes has the odd problem (hence my wish to try ch-ruby when I get a chance). I wouldn't touch the system Ruby, as other things may rely on it.
I should add I've also compiled my own Ruby several times, and using the Hivelogic article (as Dave Everitt has suggested) is a good idea if you take that route.

update ruby to 1.8.7

I'm working on a project that i have to use ruby 1.8.7. I'm using today, ruby 1.8.6 + Mac OSX Darwin. This ruby 1.8.6 was installed with the OS, it's a developer package from Apple. My question is: how can i update this package? if i run ports, it dont find my current installed package and install a new ruby version, with different paths and as effect it breaks my rubygems (i know how to fix it, but it is always workarounds over workarounds).
There is a clean way to update the default ruby that comes with the OS or its better to remove it and just manage it by Port? Please answer like this one How to update to Ruby 1.8.7 don't helps me
Have you tried rvm gem? It manages Ruby versions installed, allow to compile most (if not all) actual (and archival) Ruby versions, sets proper environment variables pointing to actually used ruby version.
$ gem install rvm
$ rvm install 1.8.7
$ rvm use 1.8.7 --default
On my OS X machines I have several versions of Ruby installed.
I install then, from source, under /usr/local/ruby-1.X.X
Once you have multiple versions of Ruby installed you will need your environment to know which one to use.
I do this by setting the PATH, like so
export PATH="/usr/local/ruby-1.8.7/bin:$PATH";
See Hive Logic's article on installing Ruby

Resources