Which Linux distribution has the most active/recent Ruby support? - ruby

I have installed Ubuntu 11.04 and tried to install Ruby as apt-get install ruby. The default version in repositories was 1.8.7, okay, install 1.9.2 manually. Then I'm going for rubygems, download tar file, install rubygems, try to install something with them, zlib-mistake appeared. Found the solution with rvm, didn't help. Now I'm stuck with broken gem command and useless rvm installed.
The question is - which Linux distribution is the most friendly for a Ruby beginner?

The distribution shouldn't matter at all, if you're using RVM (strongly suggested). Otherwise, if you want to have the latest up-to-date packages (including ruby) you could turn to rolling release distros (such as Archlinux or Gentoo). You can always add other repositories to any distro, and get more updated packages this way, as others suggested for Ubuntu.
Update: It's been years since my original reply. Nowadays, with Docker, Podman and toolbx, the distro itself is even less relevant. With containers, one can set up an isolated Ruby environment and ensure developer-production parity.

Why don't you
sudo apt-get install ruby1.9.1
out of the box? Of course, you can also use a community ppa to get 1.9.2 and some common bindings out-of-the-box (so you can work easily with, say, Rails 3.0):
http://www.humbug.in/2010/launchpad-ppa-for-ruby-1-9-2-and-some-ruby-bindings/

Many ruby developers use Ubuntu with rvm. The benefit is that you can install multiple versions and switching them is easy.
Furthermore there are many tutorials and help on errors for rvm.
I would suggest to install a VM and copy it, then and try rvm. If you cripple your system just use the copy again until you setup your system correctly.
Once you know your way around you can install ruby on your system or just stick with the VM like many other do.
On the other hand many server use Debian, wich is slightly different than Ubuntu as it uses older stable packages.

Related

Ruby, Versions, Gems, Versions and more, Oh My

Apologies for the topic title, couldn't resist.
Basically, For no reason whatsoever apart from trying out different things. I want to implode RVM and try out rbenv. Nothing against RVM, just want to try different peoples software and try different things out.
I can get rid of RVM and install rbenv no problem. Could you guys confirm a few things for me.
Firstly, if I do the above, and then install a few different ruby versions. I know I can place a .ruby-version file in a projects root directory to specify a specific ruby version but then when I say gem install <gemname> I take it that is installed globally for that ruby version.
If I then use bundler per project to manage what gems are used and I specify a gem version, what happens if the version specified in the lock file is different to the currently installed version and what happens if it's vice versa?
I just need a bit of clarification on what's doing what in regards to ruby, versions, gems and their versions.
One of the (many) lovely things about rbenv is that you can so easily look right at your ruby installation to see what's going on. For example, on my machine I can open ~/.rbenv and there's versions containing my ruby installations, such as 1.9.3-p327. Opening that, I can keep drilling down to see my gems installed for that version of ruby (in ~/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems). It is then trivial to run gem list or gem install somegem and confirm that what's being affected is this very collection of gems - if this is the current ruby (set in rbenv global and starred in rbenv versions).
In short, everything about your system thinks that ruby means this version of ruby and that its library is this library.
For Bundler, you'll need to install rbenv-bundler. A nice tutorial (easily found with Google) is here: http://dan.carley.co/blog/2012/02/07/rbenv-and-bundler/

What are the advantages of RVM on linux?

Please understand that I'm not trying to bash RVM. I would just like to understand why it's so popular in the Ruby community.
There appears to be two main reasons to use RVM - to manage/switch between different versions of Ruby, and to manage a specific gemset per project. However there seem to be much cleaner ways of achieving the same thing on linux:
I can install different ruby versions
from the repositories through the
regular package manager, or build
from source and install as a package.
I can switch between versions using
update-alternatives (on Debian, Ubuntu, Fedora at least).
I can use Bundler to manage sets of
gems for different projects, as
outlined in this blog post.
Given the above, I'm confused as to why I would want to use RVM to manage Ruby versions and gems. The idea of using a bash script to install software on my system outside the package manager feels very hackish, a feeling backed up by this blog post.
Not being a Mac user I am totally guessing here, but I thought it might be that OS X is very popular in the Ruby community. If there is no system like update-alternatives for switching ruby versions on OS X, RVM might be the best solution and this idea has carried over to linux too.. like I said, this is just a guess.
So why is RVM so popular, and why should I prefer it over the regular package manager + Bundler on Debian or Ubuntu?
If you need to manage many project with diferent versions of Ruby and special Rails like me (I have 3 project to manage wich uses Rails 2.3.5, Rails 3.0.5 and Rails 3.1 rc1) do RVM is nessesary solution. As you may know Rails 2.3.x has no bundler support and uses old gems so version managing is the way to make developing easier. I hope I helped you alittle.
RVM is portable
update-alternatives works globally, RVM works in shell/script context - I suppose it is modyfying env paths. Now imagine having two apps on one server: one 1.8.7 and another 1.9.2
Usage of Ruby EE requires manual installation - with RVM it is matter of one command to install it.
I had too much problems with mixed gem dirs with 1.8.7 only or 1.9.2 only gems in Debian.
Easy backup - just copy .rvm dir.
Consistent clustering (same platform) - just share one .rvm dir.

Best way to update Ruby to the latest 1.9 version on OS X?

Does Mac OS X support ruby version 1.9.+? Is it recommended to update to 1.9 or should I wait?
The reason I ask is because I'm trying to use some plugins that only support Ruby 1.9+
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.
I wouldn't try to update the system Ruby, since OS X uses it for some stuff (I think). Instead, use RVM.
I won't recommend a "preferred" method, but just outline the possibilities:
Install ruby 1.9 from ports using port install ruby19 +nosuffix
Install using RVM as others suggested
Check out the stable version with svn, then
./configure --prefix=/opt/ruby --enable-shared
make && sudo make install
I prefer the third way, as it gives the most flexibility, and the latest stable version. Don't forget to add /opt/ruby/bin to path before everything else if you choose this path (no pun intended).
And as others said - don't touch the system ruby, Mac OS X depends on it.
You can install MacRuby.
It can be installed along with regular Ruby as the commands of MacRuby begins with "mac", so, irb is macirb and ruby is macruby.
Having both installed, you can choose which one use in each moment by prefixing the "mac" string or not
I'd leave the system Ruby alone. Most people would just use RVM to install 1.9, but Homebrew also has Ruby 1.9.2 available.
I'd recommend using Homebrew to install it (into /usr/local).

Using RVM, how to ensure gems and non-gems see the same version of ruby?

I'm trying to install bdb on Ubuntu as a gem as follows,
gem install bdb
I'm not using sudo, since I am installing with rvm. The ruby version on my system is 1.9.1 but the version I'm using for this installation is 1.8.7 (I'm installing rbot, you see). The problem I've encountered is:
checking for db_version() in -ldb-4.something... no
I assume this means that rubygems is not finding ldb4.something in the places it is looking. Is this because I installed libdb-4.something (7, actually) using sudo, and my system's ruby version is different from the ruby version I'm using for bdb? Using rvm, how should I manage this sort of situation? Maybe I'm doing things wrong, but it seems to me that my problem is that not everything I'm using is a gem, and the stuff that isn't gems is seeing the wrong version of ruby.
(if it turns out that my problem is something completely unrelated: I am still interested in the question. How do things I've installed on my system with a particular version of ruby get along with gems installed using rvm under different versions of ruby?)
"How do things I've installed on my system with a particular version of ruby get along with gems installed using RVM under different versions of ruby?"
They don't, and that is the point. RVM is for managing different versions of Ruby so that they are isolated from each other.
This means that the Ruby versions that you use for system (when you do sudo gem install that would be installing to system) have nothing to do with the current environment (when properly set up.)
When you are in a RVM environment, each version of Ruby installed is an isolated environment.
What I would recommend is this:
Go to the RVM Website and check it out.
At the end of the page, continue with your reading about how to use gemsets.
go to your project directory
rvm use 1.8.7#your_project_environment
create your .rvrmc file so that you will automatically be using this environment in your project on the future visits to this project, this file can contain "rvm use 1.8.7#your_project_environment" which will achieve this.
install all required gems
If you have additional questions, feel free to visit Wayne E. Seguin and a ton of other users of RVM and we will be happy to help you out. Of course, the first search for answers is the documentation on the web site.

Upgrade from ruby 1.8.6 to 1.8.7 in Ubuntu 9.10?

Our server has ruby 1.8.7 and i have 1.8.6 locally. I want to upgrade my local machine (which has ubuntu 9.10) to ruby 1.8.7 - NOT to 1.9 or any later versions. I tried sudo apt-get install ruby1.8.7 but there's no package for that.
Have you tried RVM? There is also a system-wide installation available for servers.
http://rvm.io/
http://rvm.io/deployment/system-wide/
I would highly recommend using RVM.
RVM is a system wide or user wide service (depending on your preference) that allows you to install multiple versions of Ruby without causing problems. Installation is very easy to get started with and since it allows for different versions of Ruby to be installed, you could easily continue programming in 1.8.6 for one project and seamlessly switch to 1.8.7 to program for the server you are working with. You can even set different users to have different versions of Ruby set as their default if you go the user-wide way.
Make sure you have git and curl installed.
https://rvm.io
https://rvm.io/rvm/install/
It does take a little getting used to but it is a very powerful tool for developing with different versions of Ruby and even different versions of the Rails Gem. This is great too, you can have multiple Gemsets as well. So, for instance, if you need to test a new Gem or version of a Gem without mucking up a stable one you already have installed, you can create a separate Gemset and play around with it and switch back at your convenience.
Has saved me from having a lot of headaches in the past.

Resources