Ubuntu/Aptana/WEBrick Ruby/Rails version with and without sudo dont match - ruby-on-rails

I am using Ubuntu 14, Aptana Studio 3 and WEBrick 1.3.1 for Ruby on Rails (installed by https://gorails.com/setup/ubuntu/14.10)
I noticed that there is a difference between sudo and non-sudo ruby/rails.
$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [i686-linux]
$ rails -v
sRails 4.2.0
$ sudo ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
$ sudo rails -v
Rails 3.2.16
The problem is that Aptana is running WEBrick with the old sudo version of Rails which causes a number of issues. Can you please suggest how to either update the sudo Ruby (which might not be a good idea since it seems to be used somewhere in the system) or how to make WEBrick use correct updated version of Ruby and Rails or how to make Aptana start server without sudo?

How to update ruby see here How to install Ruby 2 on Ubuntu without RVM
I'm recommending to install ruby v >= 2.2.0
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://ftp.ruby-lang.org/pub/ruby/2.2/ruby-2.2.0.tar.gz
tar -xvzf ruby-2.2.0.tar.gz
cd ruby-2.2.0/
sudo ./configure --prefix=/usr/local
sudo make
sudo make install

You probably are loosing the environment variables when calling sudo
You can keep your environment variables with sudo by using the -E switch:
From the manual:
-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may
return an error if the user does not have permission to preserve the environment.
So try:
sudo -E ruby -v

Related

How To Remove Rails Installation From /usr/bin/rails

I'm trying to install Ruby on Rails on MacOS Mojave. Here's what I have so far:
ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
rails -v
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
which rails
usr/bin/rails
I've done some research on the issue and it looks like because I used sudo when I originally ran gem install rails, the rails executable got put in a location where it doesn't have access to the right libraries.
How do I fix this or remove the rails executable to start a fresh install from scratch?
Ignore the existing Rails installation in your system Ruby. Don't bother mucking about with any changes you've made to system Ruby and its gems. Just put it in the past and move on:
Install RVM with:
\curl -sSL https://get.rvm.io | bash -s stable
Restart your shell, then install Ruby with:
rvm install 2.6.5
Don't use system Ruby.
Then install Rails (without sudo, never use sudo with Ruby installed by RVM):
gem install rails

error in uninstalling Ruby from UBUNTU 14.0.4 LTS

I have made some mistake in installing Ruby and and now I'm trying to uninstall it (How to remove ruby from ubuntu) but it's giving the following error. I tried with sudo apt-get purge ruby but still couldn't uninstall. It shows ruby is not installed but I did check and confirm that it is installed in the location /usr/local/bin/ruby. please help me to uninstall Ruby and RVM from my machine.
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
$ sudo apt-get purge ruby 1.8.7
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libhdf5-mpich2-1.8.7' for regex '1.8.7'
Note, selecting 'libhdf5-1.8.7' for regex '1.8.7'
Note, selecting 'libghc-utility-ht-prof-0.0.5.1-87764' for regex '1.8.7'
Note, selecting 'libhdf5-openmpi-1.8.7' for regex '1.8.7'
Note, selecting 'libhdf5-serial-1.8.7' for regex '1.8.7'
Note, selecting 'libghc-utility-ht-dev-0.0.5.1-87764' for regex '1.8.7'
Note, selecting 'libghc-utility-ht-dev' instead of 'libghc-utility-ht-dev-0.0.5.1-87764'
Note, selecting 'libghc-utility-ht-prof' instead of 'libghc-utility-ht-prof-0.0.5.1-87764'
Package 'libhdf5-1.8.7' is not installed, so not removed
Package 'libhdf5-serial-1.8.7' is not installed, so not removed
Package 'libhdf5-mpich2-1.8.7' is not installed, so not removed
Package 'libhdf5-openmpi-1.8.7' is not installed, so not removed
Package 'ruby' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 567 not upgraded.
If you are using rvm, then you can uninstall ruby 1.8.7 using the command
rvm unistall 1.8.7
and then you uninstall the rvm using the command
rvm implode
if you want to remove ruby completely,
sudo apt-get purge ruby rubygems
Or you can follow this steps below,
Use this to find out what it is
$ readlink -f /usr/local/bin/ruby
/usr/local/bin/ruby1.8.7
Use this to find out what package is using:
$ dpkg -S /usr/local/bin/ruby1.8.7
ruby1.8: /usr/local/bin/ruby1.8.7
And use this to install,
$ apt-get purge ruby1.8.7
I have removed the ruby directory from home directory and followed the below steps...
$ whereis ruby
ruby: /usr/local/bin/ruby /usr/local/lib/ruby
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
$ sudo rm -rf /usr/local/bin/ruby
$ sudo rm -rf /usr/local/lib/ruby
$ ruby -v
bash: /usr/local/bin/ruby: No such file or directory
finally it got uninstalled !!
Thanks to Rick

Installing rails. Gem install rails stucks (for real!), and curl stucks

:)
I am trying to install ruby on rails on VirtualBox. I started with Fedora... without success, now I am giving Ubuntu a try, and still some problems occur. I wrote:
$ gem install rails
$ gem -V install rails
$ gem update --system
I waited... but nothing happend. Then i tried diffrent approach and I wanted to install RVM... but then
$ curl -L get.rvm.io | bash -s stable --ruby
stucked... It downloaded 1 file... and that was it.
Any hint?
oh... to install ruby on rails i followed this way:
$ sudo apt-get install ruby1.9.1
$ wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.24.tgz
$ tar zxvf rubygems-1.8.24.tgz
$ cd rubygems-1.8.24
$ sudo ruby setup.rb
$ sudo apt-get install ruby1.9.1-dev
$ gem install rails
And I can't go any further than this...
Try using rbenv instead of rvm, bit simpler for a start.
rbenv + ruby-build is a must ;)
rbenv install ruby
gem install bundler
gem install rails
Maybe your OS has already a ruby installed and its interfering...
try :
which ruby
to find out.
Can't tell you more without nknowing more. :s
Good luck !

How do I install Ruby 1.9.3 on Ubuntu without RVM?

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

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.

Resources