How do I install Ruby 1.9.3 on Ubuntu without RVM? - ruby-on-rails

I want to install ruby 1.9.3 on Ubuntu without rvm
I run
sudo apt-get install ruby
It's taking ruby 1.8 and ruby 1.9.1.
And if I do
sudo apt-get install ruby 1.9.3 -p XXXX
I am still not able to install ruby. How can I install ruby on Ubuntu?

On Ubuntu 12.04 LTS, I got it to work with the following:
sudo apt-get install ruby 1.9.3
cd /etc/alternatives
sudo ln -sf /usr/bin/ruby1.9.3 ruby

Use the brightbox packages for 1.9.3. You will have to add their repo though but to keep it short here just use their help pages: http://blog.brightbox.co.uk/posts/next-generation-ruby-packages-for-ubuntu

1st approach
Source
http://lenni.info/blog/2012/05/installing-ruby-1-9-3-on-ubuntu-12-04-precise-pengolin/
The new Ubuntu release has just rolled around and with it a slew of new packages. Personally, I'm tracking the development of Ruby quite closely but the default Ruby on Ubuntu ist still the 1.8 series which I can't recommend. Ruby 1.9 has some performance improvements and 1.9.3 in particular a lot of them compared to 1.9.2.
However, as I have elaborated in a previous post getting the Ruby 1.9 series on Ubuntu without using RVM instead of 1.8 isn't all that easy. Please read the post if you are interested in the details.
The short version is: You can get Ruby 1.9.3-p0 by installing the ruby-1.9.1 package. (The package is called 1.9.1 because that is the ABI version.)
If you want to make Ruby 1.9 the default do the following:
sudo apt-get update
sudo apt-get install ruby1.9.1 ruby1.9.1-dev \
rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \ build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1
# choose your interpreter
# changes symlinks for /usr/bin/ruby , /usr/bin/gem
# /usr/bin/irb, /usr/bin/ri and man (1) ruby
sudo update-alternatives --config ruby
sudo update-alternatives --config gem
# now try
ruby --version
If you want to make this your exclusive Ruby and get rid of Ruby 1.8 follow the uninstallation instructions.
Edit: I found out today that there also is a package called ruby1.9.3 however that is just a proxy package that doesn't have any files itself and only depends on ruby1.9.1. Aptitude confirms this:
Ruby uses two parallel versioning schemes: the `Ruby library compatibility version' (1.9.1 for this package), which is similar to a library SONAME, and the 'Ruby version' (1.9.3 for this package). Ruby packages in Debian are named using the Ruby library compatibility version, which is sometimes confusing for users who do not follow Ruby development closely. This package depends on the ruby1.9.1 package, and provides compatibility symbolic links from 1.9.3 executables and manual pages to their 1.9.1 counterparts.
There doesn't seem to be a rubygems1.9.3.
2nd approach
Also This link i found useful its very simple and effective.
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

Compiling from Source is the standard way.
Download source code from Here, Use README file to get instruction.
Another method is apt package manager system.
$ sudo apt-get install ruby1.9.1
Yes, this will install Ruby 1.9.2. It has a ‘library compatibility version’ of 1.9.1, hence the name.
If you install the ‘ruby’ package, you’ll get the older Ruby 1.8.

In my cluster this is really the only solution that worked:
#!/usr/bin/env bash
# -- this really is the only solution that worked for me on snap :/
ruby -v
if ! command -v ruby &> /dev/null
then
echo "Going to try to install ruby (ideally 3.1.2)"
# - install rebenv (following ruby-build really is needed eventhough it doesn't look like it)
mkdir -p ~/.rbenv
cd ~/.rbenv
git clone https://github.com/rbenv/rbenv.git .
# if $HOME/.rbenv/bin not in path append it, otherwise don't change it
echo $PATH | tr ':' '\n' | awk '{print " " $0}';
if [[ ":$PATH:" != *":$HOME/.rbenv/bin:"* ]]; then
echo "might want to put $HOME/.rbenv/bin in your path"
export PATH="$HOME/.rbenv/bin:$PATH"
# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc.lfs
fi
eval "$(rbenv init -)"
rbenv -v
# - install ruby-build, odd, this really is needed for ruby to install despite it not looking like ruby build is need at the bottom
mkdir -p ~/.ruby-build
cd ~/.ruby-build
git clone https://github.com/rbenv/ruby-build.git .
# if $HOME/.ruby-build/bin not in path append it, otherwise don't change it
echo $PATH | tr ':' '\n' | awk '{print " " $0}';
if [[ $PATH != *"$HOME/.ruby-build/bin"* ]]; then
echo "might want to put $HOME/.ruby-build/bin in your path"
export PATH="$HOME/.ruby-build/bin:$PATH"
# echo 'export PATH="$HOME/.ruby-build/bin:$PATH"' >> ~/.bashrc.lfs
fi
ruby-build --version
# - install ruby without sudo -- using rbenv
mkdir -p ~/.local
# ruby-build 3.1.2 ~/.local/
rbenv install 3.1.2
rbenv global 3.1.2
fi
ruby -v
# - Original Prover doesn't work on SNAP
# Proverbot's way to install ruby
# # First, install Ruby, as that is for some reason required to build the "system" project
# git clone https://github.com/rbenv/ruby-build.git ~/ruby-build
# mkdir -p ~/.local
# PREFIX=~/.local ./ruby-build/install.sh
# ~/.local/ruby-build 3.1.2 ~/.local/
# ref: https://superuser.com/questions/340490/how-to-install-and-use-different-versions-of-ruby/1756372#1756372

Related

How to install a specific version of ruby-dev on termux

I'm trying to setup ruby on rails environment on termux on android. I want to use 2.1.10 ruby. All I found was apt install ruby-dev or pkg install ruby-dev which installs the latest version of ruby. any suggestions?
You can install rvm.
0. Recomendation: install tmux and zsh, and change zsh as default shell. Oh my Zsh worked. Powerline fonts too (by install termux-style script)
Let's install rvm:
1. Install gawk, curl and tar packages:
apt install curl gawk tar
2. Go to rvm.io site and just copy 'Install RVM' command, look' like:
curl -sSL https://get.rvm.io | bash -s stable
3. Add this line [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" to your ~/.bashrc or ~/.zshrc file
4. Now your shell must writing a syntax PS problem, just open rvm script and edit it:
vi ~/.rvm/scripts/rvm
Now you must found a block like:
case "`uname` in
(CYGWIN*|MINGW*)
... etc ...
Just replace the 3 initialization variable __shell_name strings with this:
__shell_name="gawk 'BEGIN{RS=\"\"}; NR==1{print; exit
}' /proc/$$/cmdline | tr - '\0'" ;;
Restart shell
Now you can install ruby from rvm. Usage at rvm.io
P.s.: jruby not supported while you don't found solution for install jdk and jre from Termux).
P.s.: sorry for bad English.
apt install ruby-dev installs ruby 2.5.1-1
And that's the latest version, I think.

Sudo rvm, command not found. Rvmsudo doesn't work either. (Ubuntu 13.10)

I've got this problem with ruby versions. I've been looking for a solution, but none of the solutions I've found worked for me.
System is Ubuntu 13.10.
If I type
ruby -v
Then I got
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
But if I type
sudo ruby -v
Then I got
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
If I'm trying to change the version using sudo rvm use I'm getting:
sudo: rvm: command not found
Rvmsudo get's me this:
Warning: can not check /etc/sudoers for secure_path, falling back to call via /usr/bin/env, this breaks rules from /etc/sudoers. Run:
export rvmsudo_secure_path=1
to avoid the warning, put it in shell initialization file to make it >persistent.
In case there is no secure_path in /etc/sudoers. Run:
export rvmsudo_secure_path=0
to avoid the warning, put it in shell initialization file to make it persistent.
I've tried to type in those exports, but it didn't change anything. Typing them with "sudo", gives back "export:command not found".
I've already tried reinstaling everything, didn't help. It's a 6 hours now, that I can't find an answer.
I suspect that you do not have rvm correctly installed. To install rvm, please do as follows:
$ curl -L https://get.rvm.io | (sudo) bash -s stable --ruby -s stable --rails
$ curl -L https://get-git.rvm.io | bash
Single-User Install Location: ~/.rvm/
Multi-User Install Location: /usr/local/rvm
Then in Linux, try vim ~/.bashrc and at the end of it add below settings:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
This loads RVM into a shell session.
Then, reload to take effect:
$ source ~/.rvm/scripts/rvm
$ source ~/.bashrc # in Linux
$ source ~/.bash_profile # in MacOS
$ type rvm |head -1
if it shows rvm is a function then you have rvm installed successfully.

Rails install fails on Ubuntu 10.10

I'm trying to install rails on Ubuntu 10.10, but get File not found: lib every time. Ruby and Rubygems have been installed correctly. I've seen this problem posted all over the web but no solutions work for me. I reinstalled rdoc and I still get the same result.
$ sudo gem install rails
...
Successfully installed rails-3.0.1
24 gems installed
...
Installing ri documentation for builder-2.1.2...
ERROR: While generating documentation for builder-2.1.2
... MESSAGE: Unhandled special: Special: type=17, text="<!-- HI -->"
... RDOC args: --ri --op /var/lib/gems/1.8/doc/builder-2.1.2/ri --title Builder -- Easy XML Building --main README --line-numbers --quiet lib CHANGES Rakefile README doc/releases/builder-1.2.4.rdoc doc/releases/builder-2.0.0.rdoc doc/releases/builder-2.1.1.rdoc --title builder-2.1.2 Documentation
(continuing with the rest of the installation)
...
Installing ri documentation for rails-3.0.1...
File not found: lib
$ rails -v
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I wrote a detailed how-to guide on installing Ruby and Rails on Ubuntu 10.10 that will help you with this.
Guaranteed, or your money back!
You should avoid the packaged version of Ruby (i.e., avoid the version of Ruby that comes from apt-get install ruby). The Debian packaging system (which Ubuntu uses) conflicts with what Ruby expects.
Instead, you should install Ruby from source.
There's a nice tool called RVM to help you do this.
# Install prerequisites
$ sudo apt-get install git curl wget
# Download and install RVM
$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-latest )
# Install RVM into your .bash_profile
$ cat >> ~/.bash_profile <<-PROFILE
> [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
> PROFILE
# Load RVM into the current shell
$ rvm reload
# Install prerequisites
$ rvm notes
$ sudo apt-get install \
> build-essential bison openssl libreadline6 libreadline6-dev curl \
> git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 \
> libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev \
> ncurses-dev
# Install Ruby
$ rvm install ruby-1.9.2-p180 # latest version as of now
$ rvm use ruby-1.9.2-p180 --default
# Check it
$ ruby -v
$ which ruby
$ gem install rails

Install RoR on debian Squeeze

is there any way to install Ruby 1.9.2 or 1.8.7 + Rails 3 on my debian squeeze?
You probably don't want to use RVM on a production machine. Its $PATH magic will break in non-obvious places (e.g. cron jobs), and you'll be up a creek.
You could simply build from sources and use checkinstall to create a .deb for yourself. Here's a tutorial for Ubuntu that should translate pretty well into debian.
First install rubygems, I think it's the only Debian package. Then (as Ruby gems):
rvm (install with it ruby 1.9.2, or Ruby version you want)
bundler
rails
And then you can manage application gems with Bundler.
Have you looked at railsready-debian-lenny (it is claimed to work on Squeeze too)? Don't forget to install dependencies pointed in readme.md
The steps below outlines installing Ruby On Rails as a normal user.
Check first if the user has sudo rights. To do this try executing a simple command
$sudo ls -a
[sudo] password for unlimit:
unlimit is not in the sudoers file. This incident will be reported.
If you see a message like above, you will need to add the user to the sudoer file, this can be done by
$echo 'unlimit ALL=(ALL) ALL' >> /etc/sudoers
Check if you have ruby installed. Execute the command below
$ruby -v
-[bash]: ruby:command not found
If you see something like this, this means ruby is not installed. Install it
$sudo apt-get install ruby
Install additional libraries
$sudo apt-get install build-essential
$sudo apt-get install curl
$sudo apt-get install libssl-dev
Install rvm
$curl -L get.rvm.io | bash -s stable
Set the rvm path
$source $HOME/.rvm/scripts/rvm
You should add this to the .bashrc file.
Fetch the latest rvm and reload it
$rvm get head && rvm reload
Install ruby 1.9.3
$rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm.usr
I needed to install the readline lib
$sudo apt-get install libreadline-dev
Get the rails gem
$gem install rails -v 3.2.3
Check if you have rails
$rails -v
Rails 3.2.3
Get the readline package
$rvm pkg install readline
Get sqlite3
$sudo apt-get install sqlite3 libsqlite3-dev
You are all set to create your first rails app
$rails new app HelloWorld
You can find more info http://unlimit.in/installing-ruby-on-rails-on-debian.html
The best way to install Ruby and any Gems you like is with RVM. It will compile the latest version of Ruby for you and give you tools to manage gemsets.
Relying on the distribution's packages is usually a bad idea, because they are typically out-of-date.

How can I uninstall Ruby on ubuntu?

How can I uninstall Ruby 1.9.2dev (2010-07-02) [i486-linux]
on ubuntu?
Need to reinstall - please help
Run the following command from your terminal:
sudo apt-get purge ruby
Usually works well for me.
(caution: this can delete essential system files related to GRUB and other components)
This command should do the trick (provided that you installed it using a dpkg-based packet manager):
aptitude purge ruby
At first find out where ruby is?
then
rm -rf /usr/local/lib/ruby
rm -rf /usr/lib/ruby
rm -f /usr/local/bin/ruby
rm -f /usr/bin/ruby
rm -f /usr/local/bin/irb
rm -f /usr/bin/irb
rm -f /usr/local/bin/gem
rm -f /usr/bin/gem
I have tried many include sudo apt-get purge ruby , sudo apt-get remove ruby and sudo aptitude purge ruby, both with and without '*' at the end. But none of them worked, it may be I've installed more than one version of ruby.
Finally, when I tried sudo apt-get purge ruby1.9(with the version), then it works.
Run the following command on the terminal:
sudo apt-get autoremove ruby
Here is what sudo apt-get purge ruby* removed relating to GRUB for me:
grub-pc
grub-gfxpayload-lists
grub2-common
grub-pc-bin
grub-common
On Lubuntu, I just tried apt-get purge ruby* and as well as removing ruby, it looks like this command tried to remove various things to do with GRUB, which is a bit worrying for next time I want to reboot my computer. I can't yet say if any damage has really been done.
If you used rbenv to install it, you can use
rbenv versions
to see which versions you have installed.
Then, use the uninstall command:
rbenv uninstall [-f|--force] <version>
for example:
rbenv uninstall 2.4.0 # Uninstall Ruby 2.4.0
If you installed Rails, it will be removed, too.
Why you are removing old version of the ruby?
rvm install 2.4.2 // version of ruby u need to insatll
rvm use 2.4.2 --default // set ruby version you want use by default
Using rvm you can install multiple ruby version in the system
Please follow below steps install ruby using rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.4.2
rvm use 2.4.2 --default
ruby -v
The installation step will change for different Ubuntu version
For more info,
https://gorails.com/setup/ubuntu/14.04
You can use sudo apt remove ruby
Uninstall the make install software when make uninstall invalid.
make install will create file '.installed.list'
Choose to clean up the files described in .installed.list (need to be careful if you have multiple versions)
Case: ruby2.4 switch to ruby2.3, thinking directly delete all ruby software, and then re-make install 2.3, see: Ruby # Installation Guide
make install -> .installed.list
see .installed.list file, delete all install files.
‌
rm -rf /usr/local/include/ruby-*
rm -rf /usr/local/lib/ruby
rm /usr/local/bin/erb /usr/local/bin/gem /usr/local/bin/irb /usr/local/bin/rdoc /usr/local/bin/ri /usr/local/bin/ruby
rm /usr/local/share/man/man1/erb.1 /usr/local/share/man/man1/irb.1 /usr/local/share/man/man1/ri.1 /usr/local/share/man/man1/ruby.1
rm /usr/local/lib/libruby-static.a
rm -rf /usr/local/lib/pkgconfig/ruby-*
which ruby
pkg-config --list-all|grep ruby

Resources