I can't use RVM, this is a server not just for me, so I can't have RVM attached only to my user. Is there a way to install RVM universally? or is there a command where I can specify the version of ruby I want?
The RVM Installation Guide covers a "Multi-User Install". It will walk you through installing RVM in /usr/local/rvm.
But... you may not need RVM...
If I recall correctly, Ubuntu's default Ruby is version 1.8.7. You can look in the Software Center or use Synaptic Package Manager for which Ruby version is available for install. If you want to see available Ruby packages from the command line then use sudo apt-cache search ruby. Once you determine the Ruby version is 1.8.7 then you can install it using your method of choice.
Usually only a very limited set of versions is available. You can see them with apt-cache policy <package>. If you see one you want, you can specify it with apt-cache install <package>=<version>.
More often, you would just build from source precisely the version you want. Downloading the deb file for a particular version and installing it with dpkg is also a possibility, but keep in mind that dpkg won't be able to download and install dependent packages.
Related
My ultimate goal is to install Sass.
To do this I need to install RubyGems
To do this I need to install Ruby.
I installed Ruby with yum.
I then tried to install gem with yum yum install rubygem
The response is "nothing to do" and yet when I write gem install sass I get:
gem: command not found
I decided to try to install rubygems 2.2.2 manually. After downloading it, I tried to run ruby setup.rb and in response I get:
Rubygems now requires Ruby 1.8.7 or later
But yum does not seem to be able to install anything later than 1.8.5.
So now I'm trying to do this manually.
I downloaded Ruby 1.9.2 to my home directory and followed these instructions: http://howboring.com/post/1226760251/centos-5-and-rails-3-and-ruby-1-9-2
This seems to work, but the problem is ruby1.9.2 is installed in my home directory (i.e. ~/ruby1.9.3 not system wide.
Thus in the directory where I installed ruby 1.9.2 ruby -v still gives 1.8.5 but ./ruby -v returns 1.9.2. And which ruby returns /usr/bin/ruby (I suppose I could replace this with a symlink that points to ~/ruby1.9.2/ruby but this doesn't seem like a "best practice")
So my main question is where should install ruby 1.9.2 with Root Permissions so that 1.8.5 is replaced with 1.9.2 system wide.
My corollary question is: is there any easier way to do this? (perhaps install sass without install rubygems??)
I then tried to install gem with yum yum install rubygem
You have a typo in the package name, it is actually named rubygems.
Can i suggest Wayne Seguins excellent rvm (ruby version manager). As the home page states:
"RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems".
Site has comprehensive installation instructions. I've posted a truncated Set of instructions for installing on POSIX systems below, but please refer to the projects' home page as:
"we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods."
Install RVM (development version):
\curl -sSL https://get.rvm.io | bash
Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command:
user$ source ~/.rvm/scripts/rvm
test the installation was successful:
user$ type rvm | head -n 1
this should output "rvm is a function"
List all known rubies:
rvm list known //this will output a large list of rubies shortened here
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1[.1]
[ruby-]2.1-head
ruby-head
...
install the version you want:
rvm install 1.9.2
You can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby:
rvm use 2.1 --default
You can also temporarily use another version of your ruby versions
rvm list known //lists system available rubies
Choose to use another ruby
rvm use 1.9.3
RVM is a great tool, well documented, and actively developed, it handles a wider scope of functionality than i can list here, and it's a tool I use everyday.
You can use rbenv to install ruby and rubygems that you need
https://gist.github.com/jpfuentes2/2002954
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 am new to Ruby and RoR. I have a clean Linode instance with an Ubuntu image, and I want to compile Ruby from source instead of using apt-get. I have googled for instructions of doing this, but after some tries I keep on getting errors regarding missing zlib and some other packages when I try to run some tutorials samples.
Can anyone please give me detailed instructions (or a link) that would teach me how to get the necessary prerequisite packages installed before I compile Ruby from source?
My intent is to compile latest stable release of Ruby, then install Rubygems and Rails. Thanks for any help in advance!!!
This blog post covers the necessary packages and install process to compile ruby from source; it references Ruby 1.9.1 but it should work just fine with Ruby 1.9.2 as well. The real useful bit from this post is:
sudo apt-get -y install libc6-dev libssl-dev libmysql++-dev libsqlite3-dev make build-essential libssl-dev libreadline6-dev zlib1g-dev libyaml-dev
It looks like to me that a few of these are not essential unless you want to go on to use MySQL or SQLite, but otherwise this list of packages will get what you need to compile Ruby.
After that, I wouldn't recommend actually installing Ruby from source manually; I would use RVM (Ruby Version Manager) so you can install any version of Ruby you wish, now and later. RVM compiles the different versions of Ruby by downloading and compiling the source code, and will also install Rubygems for you.
Once you have installed rvm, you can use rvm requirements to get the current list of required packages.
You can use apt-get install all the build dependencies for any package. Enable your source repository and then run.
sudo apt-get build-dep ruby1.9 rails
This will install all the packages you will need to compile the source for these two packages. Then you can go get the latest source, and follow the instructions.
N.B.: Packages names may be wrong, depends on which version of Ubuntu you're using.
I HIGHLY recommend using 'RVM' to install all your rubies, especially if you're doing it just for your own use. RVM will do all the compilation for you, puts everything in ~/.rvm including the gems, and makes it easy to install multiple versions of Ruby and gems for testing.
Installation and using gems will get you running. RVM's Gemsets are powerful, and RVM's ruby command makes it nice for performing some action across all the installed Rubies RVM manages.
RVM also supports system-wide installations offering RVM's flexibility if you need it, but it's a bit more complicated and is unnecessary if you're on a single-user machine.
Why not install zlib? sudo aptitude install libz-dev
I've compiled from source, and it's pretty good at warning you when you are missing a dependency.
The page http://www.ruby-lang.org/en/downloads/ only says 1.9.1 for Linux.
Right now I am using RVM to do an
rvm install 1.9.2
and it needs compilation. There is no apt-get install way to install it?
Is there a way to list all Ruby version apt-get can install?
To list available versions you can use the following command:
apt-cache search --names-only '^ruby1.*'
If you use Debian, 1.8, 1.9, 1.9.1 are availble on testing. 1.9.2 is only available on unstable.
in debian squeeze and sid the 1.9.1 package is in fact based on the 1.9.2 branch according to this search:
http://packages.debian.org/search?keywords=ruby1.9.1&searchon=names&suite=all§ion=all
and the changelog says that too:
http://packages.debian.org/changelogs/pool/main/r/ruby1.9.1/ruby1.9.1_1.9.2~svn28788-1/changelog
It's only been 3 weeks, give it some time :P
You can do it for ruby1.9.1
ruby1.9.1-dev
rvm now supports binary rubies, so there is no need to compile:
rvm get head # this change will be available in rvm 1.16
rvm list remote
rvm mount 1.9.3
only ruby 1.9.3 is good for installing in relative paths so do not expect earlier versions to be available (for other path then /usr/local/rvm).
if rvm list remote was empty then let me know what is your system rvm info, you can find me on irc mpapis at #rvm at freenode servers or open a ticket here: https://github.com/wayneeseguin/rvm/issues/new