I am trying to install Ruby 1.9.2-p290 via macports. I just installed the port 'ruby', and I ended up with ruby 1.8.7. Any idea how to install a specific version of ruby?
I've heard the use of rvm, however, I dont seem to have rvm on my mac. Would it be better than macports? If yes, why and how can I get it? Would it be possible to get it via macports?
Thanks!
rvm may be an excellent answer if you're going to be working with ruby a lot, but that's not the actual answer for why MacPorts appears not to do the correct thing.
By default, the MacPorts ruby package installs the binary as /opt/local/bin/ruby19. If you run which ruby19 that should confirm it was indeed installed by MacPorts correctly.
This is not what anybody expects though, so it helps to know the poorly documented select command syntax. As of MacPorts v2.1.3, the proper way to make the MacPorts-installed ruby19 the "system default ruby" is: sudo port select --set ruby ruby19
In older versions the "proper" way to make ruby19 the default was to install the +nosuffix variant (which no longer exists) like this: sudo port install ruby +nosuffix.
If I remember correctly, ruby 1.8.7 is the stock ruby on OS X. If you install another Ruby version (with MacPorts for example) you will have to tell your OS to use it instead of the stock one. It can be very messy this way.
So I recommend hardly to use rvm. It will be better than Macports, because you will be able to install the Ruby version you want. You can even have multiple Ruby version and switch whenever you want.
Rvm is not installed by default on your Mac, but consider checking out this simple guide to get started.
Related
I am newbie to ubuntu and ROR. After installed latest ruby1.9.2 with apt-get, type "ruby -v" it still shows up old version ruby1.8.7. I tried to reinstall with rvm, nothing changed.
As mentioned in similar question, I tried to remove ruby, and reinstall ruby1.9.1-full... still the same thing...
What else I can do about this?
ubuntu uses a something called alternatives for chosing between two version of similar executable. Running
sudo update-alternatives --config ruby
and chosing the ruby you want should do the trick
I'm using RVM myself, but if I remember correctly, ruby1.8 and ruby1.9 can be installed side by side on Ubuntu. ruby is just a symbolic link which points to version 1.8 by default - which should be called ruby1.8 and stored in the same directory. 1.9 will be called ruby1.9.
So just find where ruby symbolic link is (whereis ruby) and change it so it points to ruby1.9.
sudo rm /path/ruby
sudo ln -s /path/ruby1.9 /path/ruby
Sounds like you are using rvm, but still referencing system ruby. To switch, you have to tell rvm what version to use.
rvm use 1.9.2
This will switch your current environment only. So ruby -v in your current shell will use the right version. (you should probably go with 1.9.3, FWIW) If you want to always use that ruby be default, you type:
rvm use 1.9.2 --default
If you want to switch back to system ruby, you can use:
rvm use system
I think it is because the package of Ruby version at apt-get repository is an old version.
I suggest use rbenv to install the latest version.
Here is a great tutorial using rbenv to install the latest Ruby version from Digital Ocean:
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04
sudo apt-get install ruby1.9
should do the trick.
You can find what libraries are available to install by
apt-cache search <your search term>
So I just did apt-cache search ruby | grep 9 to find it.
You'll probably need to invoke the new Ruby as ruby1.9, because Ubuntu will probably default to 1.8 if you just type ruby.
I am currently learning Ruby using Ruby 1.8.7 (pre-installed on OS X 10.6) but understand the latest version is 1.9.1?
Is it a requirement for me to 'upgrade' this to get the most out of the language? What are the differences between 1.8.7 and 1.9.1?
If an upgrade is advisable can anyone advise how I should go about upgrading my Ruby?
Currently the stable release is 1.9.2.
It's not mandatory to upgrade, although 1.9.2 offers better performance and some nifty features (e.g.: better Unicode support, Time and regex improvements, etc.).
Choosing to upgrade mostly depends on what you need to achieve, but I would suggest to install Ruby Version Manager, so that you can install all the versions you want and easily switch between them.
You can find all the info at https://rvm.io and a nice guide here: http://ruby.about.com/od/rubyversionmanager/ss/Installing-Ruby-On-Snow-Leopard-With-Rvm.htm
There is nothing like a requirement but it is strongly encouraged by the community
to use ruby 1.9.2.
The best way to give it a try is through RVM
RVM is cool. But probably later you will need another gnu software, not native in OS X. Therefore, i'm recommending to use macports.
go to www.macports.org
download the installation dmg
install it
open an new Terminal windows (or source ~/.profile )
Enter the following
sudo port selfupdate
sudo port install ruby19
port search rb19-
pick what you want and install them with port install command. (as above), for example
sudo port install rb19-rails
sudo port install rb19-rails_best_practices
sudo port install rb19-actionpack
and so on...
Note
everything will compile, so need Installed Apple Developer, and will take a long time.
you need to use /opt/local/bin/ruby and not /usr/bin/ruby
Everything will go into /opt/local tree - so does not interfere with your standard system binaries - your system remain untouched.
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.
I'm new to both Ruby and to Mac OSX, though I do have a fair amount of experience with Unix commands. I just installed Ruby 1.9 via a MacPorts command (port install ruby19). I then needed to do a find from root just to figure out where it went, which turned out to be: /opt/local/var/macports/software/ruby19/1.9.1-p376_0/opt/local/bin/ruby1.9.
The current version of Ruby (1.8.6) runs via /usr/bin/ruby, which is a symbolic link to /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby where Current is a symbolic link to a directory called 1.8.
I'd like to make Ruby 1.9 my default (along with related tools like irb), and while I can manage to do that, I'd like to know if there's a conventional way. Should I copy or link the MacPorts path to /System/Library/Frameworks/Ruby.framework/Versions/1.9 and then point Current to 1.9? (I'd also have rename or copy the executables: ruby1.9 to ruby, irb1.9 to irb, etc.) Or should I just blow away the /usr/bin/ruby link (and /usr/bin/irb, etc) and create new ones pointing to the MacPorts version?
You can easy to use port select command, under MacPorts 2.1.3
$sudo port select --set ruby ruby19
Install the nosuffix variant instead:
sudo port install ruby19 +nosuffix
Your newer ruby version should now take precedence over the preinstalled one.
My advice:
$ port uninstall ruby1.9
Then follow this: https://rvm.io/rvm/install/
Then:
$ rvm install 1.9.2
$ rvm --default 1.9.2
You might even rvm install macruby to toy with Cocoa.
In the lastest version of macports (2.1.3 or greater) you can use the port select command.
port select --list ruby
sudo port select --set ruby ruby19
For earlier versions of macports you can make a symbolic link to the numbered ruby version. This is the way that macports generally handles switching between different versions of packages.
cd /opt/local/bin
sudo ln -s ruby1.9 ruby
I would highly recommend RVM. It takes a bit of reading, but once you have it installed you can install a ruby with rvm install 1.9 (or jruby, ree, 1.8, etc), and switch between them with rvm 1.9. Each ruby version will also have its own, completely isolated set of rubygems.
The ruby1.9 binary should be installed in /opt/local/bin; if it's not, you may not have activated the port.
The easiest way to make Ruby 1.9 the default root is to create an alias for ruby to ruby1.9. If you're using Bash, you can do that by putting this in your Bash config file:
alias ruby='/opt/local/bin/ruby1.9'
Uninstall ruby version 1.8:
sudo port uninstall ruby
Install ruby version 1.9:
sudo port install ruby19
Reopen terminal
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