Ruby Installation - ruby

Silly question. I went to http://rubyinstaller.org/downloads/ and installed Ruby 1.9.2, but when I pull up command prompt and type ruby -v it's not recognized as a command. Am I doing something wrong? I had version 1.8.6 installed, but I couldn't figure out how to upgrade my Ruby version so I uninstalled it and tried a fresh install.

You need to add Ruby to your path variable, regardless of your operating system.
Say you're using Windows, and Ruby is installed in C:\Program Files\ruby1.9.2\ You'll need to find out which folder the ruby executable is in (ruby.exe). Sometimes it'll be in the main folder, but usually for open source packages it'll be in the subfolder bin. To add ruby to your path, then, you'll need to use C:\Program Files\ruby1.9.1\bin
You can do this on the command line like so:
path = %PATH%;C:\Program Files\ruby1.9.2\bin
Note that %PATH% has a percent sign on either side, and that there's a semi-colon separating it from the new value. You'll have to type it in each time you start a new command line window, but it might be a good idea to try this the first time, because any mistakes in typing it in won't be permanent.
To change it permanently you can find it in Control Panel > System > Advanced System Settings. Switch to the Advanced tab, then click Environment Variables... Find path under System Variables, and add ;C:\Program Files\ruby1.9.2\bin to the end. Note that you still need a semi-colon to separate the new value from everything else, and that you don't need %PATH% this time (in face, the value you see is what %PATH% represents). Once you've done that, restart any command windows you had open, and you should be able to access things just fine!
These instructions will be different if you're using Linux or a Mac - try googling environment variables if you'd like to know more!

Did you add your bin Directory to the PATH?
Ok, when you install it, it will go in a directory:
ex: c:/program files/ruby1.9.x/
inside you will have a /bin directory which contains all the command for the command line.
To be able to use ruby in the command line, you must add it to your $PATH variable in the OS environment.
ex:
path=c:/program files/ruby1.9.x/bin;etc...

Install RVM with RUBY
sudo apt-get install curl
after install
install rvm also ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
if you face issue with the above line (Failed to connect to get.rvm.io port 443: Network is unreachable)
in browser go to https://get.rvm.io save the page in any location
make it executable file name rvm-installer
chmod +x rvm-installer
then do the following
bash rvm-installer stable --ruby
source /home/username/.rvm/scripts/rvm
then check rvm list
note the version of ruby listing on terminal
if you failed to install due to the dependency
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev
if the above steps not installed ruby latest version you can do it by
rvm install ruby-2.1.1
installation using rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.1
rvm use 2.1.1 --default ruby -v
**change terminal to login shell. open a new terminal **
then rvm use 2.1.1 => ( 2.1.1 version )
then its done!
pd#admin:~$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
programmers keep on coding with ruby.

Related

How to remove ruby completely from my linux system

I broke ruby in my system by doing this:
mkdir /tmp/ruby && cd /tmp/ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar xfvz ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327
./configure
make
sudo make install
The problem occurs in many different circumstances:
Trying to acess IRB:
$ irb
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
Trying to install gems:
$ gem install rubygems-update
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
I tried to use synaptic to remove all ruby related packages, and reinstalled it, but it didn't solve my problem. I didn't install ruby through rvm, I used rbenv:
rbenv uninstall 2.2.3
rbenv install 2.2.3
I also tried the purge command. I don't know what's happening. I'm very desperate looking for a solution. The directory /tmp/Ruby had been deleted by me... I deleted it using thunar.
Someone please help me.
If you still have that /tmp/ruby directory, than go there and run
$ sudo make uninstall
This command will uninstall all previously installed files from that ruby. It usually installs into /usr directory, so if you had a system ruby (installed from Synaptic or apt-get (it seems you're using Debian-based system such as Ubuntu) could also break your system ruby, you need to reinstall it too. You can find out it this way:
$ sudo apt-get install aptitude # install aptitude for easy searching
$ aptitude search ruby | grep ^i # find all installed packages, containing ruby in their titles
In contrast, rbenv or rvm don't use your system paths for installation, instead they use your home folder and install to a path like ~/.rbenv, but since you mess up your system folder rbenv may look to a different place (it's hard to say for sure what's going on right now).
After you've cleaned up your unwanted ruby installation, use ruby-build to install desired ruby with rbenv:
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build # install ruby-build
$ rbenv install -l # list available versions
$ rbenv install 2.2.3 # install desired version
I hope that helps.
First uninstall the compiled from source version you installed:
cd /tmp/ruby
sudo make uninstall
Then purge system ruby:
sudo apt-get purge
Then install RVM, close and reopen your terminal, and do rvm install 2.2.0

Installing RVM on existing ruby1.8 installation

I have a big problem with my Debian server configuration. Someone before me has made a big mess with ruby installation and now i can't manage to get it all working. What i'm trying to do now is to get back to environment, where ruby1.8 is installed and rails app is working correctly with apache+passenger. If it would be working on RVM it would be perfect. Here is the story:
There was ruby 1.8 installed on a server. The person has removed it with sudo apt-get remove ruby1.8 and then installed version 2.0.x manually using those commands:
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz
cd ruby-2.0.0-p247
./configure
make
sudo make install
Then, he has removed all the dirs listed by whereis ruby with rm command.
And here i came - i want to install RVM on this server. The problem is, no matter what i do, i get a lot of errors from all sides. Steps i've done:
# Install RVM
curl -L https://get.rvm.io | bash -s stable
# install 1.8.7 version
rvm install 1.8.7
# use 1.8.7
rvm use 1.8.7
# Install gems
bundle install
First thing (and that's just a tip of iceberg) is that i'm not able to start apache2 in cause of the following error:
apache2: Syntax error on line 203 of /etc/apache2/apache2.conf: Syntax
error on line 1 of /etc/apache2/mods-enabled/passenger.load: Cannot
load
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
into server:
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.5/libout/apache2/mod_passenger.so:
cannot open shared object file: No such file or directory Action
'configtest' failed.
Looks like there is even no /usr/lib/ruby/ dir on my system right now.
The question is: is there any way to reset all ruby-releated libraries on debian to the original state (debian without ruby installed) and install working RVM on top of that? Thanks in advance for any help.
Verify if, Is ruby installed correct by ruby -v
Install phusion passenger
$ sudo gem install passenger
$ sudo passenger-install-apache2-module
and then follow onscreen instructions

problems installing latest ruby version

I need some help here with RVM and installing the latest version of rails on a debian server. please note im not a linux programmer so you'll have to spell out everything for me.
basically i'm trying to upgrade to the newest version of ruby. I'm trying to install that on a debian server that I connect to via VPN. I'm trying to use RVM so far, but when i run the RVM install 1.9.3 from my debian bash prompt it says there are no binary available for that version, then proceeds to try and grab the source from online which fails (probably due to the firewall). basically when it grabs the source folder from online, it grabs a corrupted hunk of junk. I tried downloading the source package myself and if i click the link on the ruby site it blocks it. If i use wget it appears to download it, but the md5 doesnt match and i cant untar it the thing. it says gzip: stdin: the file is not in gzip format.
So! I neeeedddsss to help. What I was thinkin was getting the binary rubies for 1.9.3.. but I'm unsure how really.. I downloaded the tar.gz file on my windows and used winSCP to move it over, and then I can use untar the thing fine.. and then i have an unzipped folder that is the source from the site.. but im unsure where to go from there.. apt-get install doesnt seem to recognize the tar.gz or the untarred folder.. i tried rvm mount and specifying the path to ruby.exe file (ruby-1.9.3-p327/bin/ruby) but then it says unrecognized command line argument and i should see the usage..
Any advice out there? (preferably without 3rd party programs or stuff other the RVM)
thanks
Because you're a novice, I suggest skipping RVM unless you know you need it.
Debian has great way to install Ruby and make it available for all of the system users:
sudo apt-get install ruby1.9.3
You will use the root password to install it this way.
To verify it worked:
ruby -v
That should print out something like this:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
In case you want to install ruby using rvm: Just execute the commands in the same sequence..
$ sudo apt-get install curl git-core ruby
$ \curl -L https://get.rvm.io | bash -s stable
$ sudo apt-get install libssl-dev
$ source ~/.rvm/scripts/rvm
$ sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
$ rvm install 1.9.3
--give the password for sqlserver or you can just press enter.
$ gem install rails
You have ROR setup now!
Reading back on my questions, I remember now, it WAS the firewall. The firewall where I was working at the time didn't allow me to download ruby source properly. It was downloading, but not actual source, corrupted source. So, I did it at home and it worked fine.
Just thought I'd pop this in here in case anyone ever finds it when problems installing ruby.

install RVM offline completely

I am planning to create an installer for a ruby script but I want to be able to ensure that the machine has RVM installed. Is there a way to install RVM completely offline and unobtrusive as well(by unobtrusive, as in create a script that can do everything instead of ask users to add something to their bash_profile or bashrc)
I am not asking for the script itself, just a quick pointer as to how to go about this route(if it is even possible). We have also looked into this question which was helpful enough:
RVM - is there a way for simple offline install?
but a bit misleading as the answer only shows us how to install a ruby in RVM offline. We need to be able to install RVM itself offline, and looking at the script
https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer
do I just include this whole script and change the rvm_releases_url into something else? And is it safe to just append the rvm path to a user's bash_profile, or bashrc instead of asking them to do it?
As per the suggestion given editing this comment. :-)
Installing RVM offline :
- Download the rvm tarball:
curl -sSL https://github.com/rvm/rvm/tarball/stable -o rvm-stable.tar.gz
- Create and enter rvm directory:
mkdir rvm && cd rvm
- Unpack the tar file :
tar --strip-components=1 -xzf ../rvm-stable.tar.gz
- Install rvm:
./install --auto-dotfiles
use --help to get the options
- Load rvm:
source ~/.rvm/scripts/rvm
Download Ruby, rubygems and yaml :
- Download ruby
o Find tar.bz2 version at:
https://ftp.ruby-lang.org/pub/ruby/ (check sub-directories)
o Download with curl: :
curl -sSL https://ftp.ruby-lang.org/pub/ruby/ruby-2.2.0.tar.bz2 -o ruby-2.2.0.tar.bz2
o Make sure you are downloading with the extension " .tar.bz2 "
- Download rubygems
o Find version at:
https://github.com/rubygems/rubygems/tags
o Download with curl:
curl -sSL http://production.cf.rubygems.org/rubygems/rubygems-2.4.6.tgz -o rubygems-2.4.6.tgz
Install dependencies :
- Disable automatic dependencies ("requirements") fetching using the following command.
rvm autolibs read-fail
- Manually download and install dependencies
o Get the list of dependencies using
rvm requirements
Installing Ruby :
Clean default gems:
echo "" > ~/.rvm/gemsets/default.gems
Clean global gems:
echo "" > ~/.rvm/gemsets/global.gems
Install Ruby:
rvm install 2.2.0 --rubygems 2.4.6 (this may require sudo password for autolibs)
Install any other Ruby versions you want similarly
Set default Ruby version: rvm use 2.2.0 --default
NOTE : The ruby and other packages should be placed in the " $rvm_path/archives/ " directory.
Installing gems :
There are multiple ways to install gems, we can download the gem files,
but the best way seems to be Bundler: http://bundler.io/bundle_package.html
Example installing rails gem:
Offline
--------
Create a directory:
mkdir gems; cd gems
Unpack gems:
tar xzf gems.tgz
Install bundler:
gem install bundler-1.8.3.gem
[ This needs internet, to avoid internet connection you need to install bundler gem using --local option with the bundler.x.x.gem file ]
Install gems:
bundle install --local
UNINSTALL rvm :
rvm implode --force
Then remove rvm from following locations:
rm -rf /usr/local/rvm
sudo rm /etc/profile.d/rvm.sh
sudo rm /etc/rvmrc
sudo rm ~/.rvmrc
Check the following files and remove or comment out references to rvm
~/.bashrc
~/.bash_profile
~/.profile
~/.zshrc
~/.zlogin
Comment-out / Remove the following lines from /etc/profile
source /etc/profile.d/sm.sh
source /etc/profile.d/rvm.sh
/etc/profile is a readonly file so use
sudo vim /etc/profile
You can find the installation method here also...
Reference : https://github.com/rvm/rvm-site/blob/master/content/rvm/offline.md
Update: Finally finally finally!!! We have it!
https://rvm.io/rvm/offline/
Full instructions for offline installation!
It should be enough to get copy of the sources and run:
./install
in the root of it,
for installing ruby you will need to get archives of ruby and rubygems to rvm/archives and set rubygems_version=1.8.24 in rvm/user/db
There is also another project I'm involved that will embed RVM and allow offline installation: https://github.com/railsinstaller/railsinstaller-nix

Installing Rubies in system wide RVM 1.5.2 install problem

Following this advice for installing RVM 1.5.2, I used these commands to install RVM 1.5.2 system wide (into /usr/local/rvm):
curl http://rvm.beginrescueend.com/releases/rvm-install-head > rvm-install-head
sudo bash rvm-install-head
That, in itself, worked. I added the appropriate source statements in my .bashrc file:
[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm"
and proceeded to attempt to install Ruby 1.9.2 with this command:
sudo rvm install 1.9.2-head
However, I get "rvm: command not found". If I try it without sudo, I don't have appropriate permissions to create the necessary directories and so forth, as would be expected. The problem seems to be that the shell function rvm is defined for my user, but when running sudo, it doesn't seem to be available.
My question: What is the correct way to install rubies in a system wide RVM 1.5.2 install?
I'm running Ubuntu 10.04.
If you have existing provisioning scripts that depend on the old system-wide install script, then staying at RVM version 1.3.0 is another option to consider.
(See RVM system-wide install script url broken -- what is replacement?)
It appears that the install scripts have been updated to correct this, so it doesn't appear to be an issue anymore.

Resources