Error installing Rails on top of Ruby - ruby-on-rails

When trying to run bundle install with MySQL I received:
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
I tried running:
sudo gem update
sudo gem update --system
sudo gem install rails
And got:
ERROR: Error installing rails:
activesupport requires Ruby version >= 2.2.2
Then I tried:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash
\curl -sSL https://get.rvm.io | bash -s stable --ruby
\curl -sSL https://get.rvm.io | bash -s stable
And I got this:
pi#rpi:~ $ rvm use 2.3
Using /home/pi/.rvm/gems/ruby-2.3.0
pi#rpi:~ $ rvm use 2.3 --default
Using /home/pi/.rvm/gems/ruby-2.3.0
pi#rpi:~ $ sudo gem install rails
ERROR: Error installing rails:
activesupport requires Ruby version >= 2.2.2.
Why?

You used sudo with RVM. Don't do that if your RVM is installed in your user account, which yours appears to be.
When you use sudo you're running as the sysadmin, which doesn't know about Rubies in ~/.rvm, only the system-owned Ruby. That's why the version is wrong.
Search the RVM documentation on for "sudo" for more information. In particular this is important:
DO NOT use sudo...
to work with RVM gems. When you do sudo you are running commands as root, another user in another shell and hence all of the setup that RVM has done for you is ignored while the command runs under sudo (such things as GEM_HOME, etc...). So to reiterate, as soon as you 'sudo' you are running as the root system user which will clear out your environment as well as any files it creates are not able to be modified by your user and will result in strange things happening. (You will start to think that someone has a voodoo doll of your application...)
https://rvm.io/rubies/rubygems
In addition to the voodoo, you will have also installed and/or updated gems in the Ruby owned by the system, which can play havoc with other scripts which expect a certain behavior of a gem, which could have been changed by the update. That's an even worse situation because system tools or services can stop working, which will go unnoticed for a while.
So, don't use sudo with gem unless you're sure you know what you're doing.

Related

Cannot use specific version of bundler

I'm on Debian 9 and I'm trying to use the 1.16.3 version of bundler on a ruby on rails site. However for some reason the system insists on using the older version 1.13.6 both by default and when I explicitly specify it:
To resolve this I tried completely uninstalling the 1.13.6 version:
Now I'm starting to feel like I'm taking crazy pills. Is it physically possible to use the 1.16.3 version?
Edit in reply to matthewd: which -a bundler finds two hits:
/usr/local/bin/bundler
/usr/bin/bundler
If run with bundler -v both report to be version 1.13.6
Edit in reply to Kedarnag Mukanahallipatna: There is no .rvm directory in /home/manos/. Could this be somewhere else?
Bundler is pain in the a**
You can solve this by executing these set of commands. Keep in consideration your ruby version also.
before_install:
- rvm implode --force
- \curl -sSL https://get.rvm.io | bash -s 1.27.0
- rvm reload
- rvm install 2.2.3
- gem uninstall -i /home/travis/.rvm/gems/ruby-2.2.3 bundler -x
- gem install bundler -v 1.16.3
After a lot of back and forth I ended up uninstalling ruby and rails that were previously installed via apt. I then reinstalled ruby via apt and instead of getting rails via apt I got it with
gem install rails
Bundler is now at 1.16.3.
A disclaimer though... since this whole thing has been a side issue while I was dealing with other rails problems, I've also done a bunch of other reinstalling so there's a chance something there affected the bundler. So there's that.

bash: /home/XXX/.rvm/scripts/rvm: No such file or directory

I just walk-through with the installation of Ruby on Rails on Ubuntu using RVM.
First I have logged in as the root user.
Then I started with the following commands.
\curl -sSL https://get.rvm.io | bash -s stable --rails
It has been installed without any error.
source ~/.rvm/scripts/rvm
When I run this command. It showing the error as bash: /home/XXX/.rvm/scripts/rvm: No such file or directory
I added the [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" command in my .bashr file.
Install RVM:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
Now you will get a success message. Then, run this command:
\curl -sSL https://get.rvm.io | bash -s stable
See http://rvm.io/ for more info.
I think they may have moved some files around fixed with:
source /usr/share/rvm/scripts/rvm
After installing rvm, try:
source ~/.rvm/scripts/rvm
If the above command throws some issue, try this command:
source /usr/local/rvm/scripts/rvm
Firstly no need to go for sudo access while installing rvm, just follow the very basic commands below
$\curl -sSL https://get.rvm.io | bash -s stable
This will install rvm.
$ rvm list known
# 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
Install a version of ruby as required.
$ rvm install 2.0.0-p353
Now you can use the version of ruby for which you need to install rails as a gem.
$ rvm use 2.0.0
Also you can make it default if you want so
$ rvm use 2.0 --default
Next you can install rails as a gem.
$ gem install rails
gems should never be installed with sudo access as they change from project to project. rvm helps in managing the different versions of ruby in one m/c. You can also use gemsets to isolate gems and specific versions from one application to another.
just create ~/.rvm/scripts/rvm directories, then try to install rvm but make sure you are not logged in as root.
This source /usr/share/rvm/scripts/rvm works for me on ubuntu 20.04.
I changed the local in /usr/local/rvm/scripts/rvm to share
I assume that you have installed the rvm.
Is generally not recommend to install RVM as a root user because of umask security risk. Try running these commands as a user.
Downloading RVM (Do not sudo this command)
\curl -sSL https://get.rvm.io | bash -s stable --rails
Then you'll need to add the location to sources(You'll probably need to reload your bash for rvm to work)
source ~/.rvm/scripts/rvm
You can install your desired version like so(replace ruby_version with one you would like to install, eg 2.1.4)
rvm install ruby_version
To list the available version on your machine
rvm list
To use a version of ruby run
rvm use ruby_version
If you have any trouble refere to the RVM website
As root, you traditionally don't have a /home folder. Root's home is different than a normal user.
You very likely don't want to install RVM as root.
Please do read the information at http://rvm.io specifically the installation notes.
Can you use sudo find to locate the correct path of the rvm directory? If you find the path, you should be able to rerun the source ~/.rvm/scripts/rvm command with the correct path.
Also, I fully agree with the previous answers about not creating it as root. DigitalOcean was a pretty good tutorial on adding users https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-14-04
Alright so when you get a failure message "No such file or directory",
type
\curl -L https://get.rvm.io | bash -s stable
in your terminal.
There will be a GPG signature verification failure.
Bellow that failure there would be a link for github and a key something like this
gpg2 --recv-keys 409B6B...
So download a tar file from the github link and run this code to install GPG:
sudo apt install gnupg2
and run that key :
gpg2 --recv-keys 409B6B...
next run the code:
\curl -L https://get.rvm.io | bash -s stable
it will show you installing the rvm
and then you can run:
source ~/.rvm/scripts/rvm
thats it you are good to go
If you install rvm via apt-get you can add the following line into ~/.zshrc or ~/.bashrc
source /etc/profile.d/rvm.sh
For me all the above methods didn't workout.
After the installation and updates, still the terminal shows this "error bash: /root/.rvm/scripts/rvm: No such file or directory"
The simple method which helps me to solve this error is :
Show Hidden Files
Go to the Home (where the bash scripts are stored)
Edit the .bashrc
At the bottom you can find some lines about rvm
just clear the rvm lines and save the file.
Open terminal and check it.
Your surest bet is to use home brew. Funny part is if you try brew upgrade ruby, you will have an error if brew wasn't used to install ruby in the first instance so use:
$ brew install ruby
Then afterwards use
$ brew upgrade ruby
You may need to close and reopen your terminal to see the effect of the upgrade by typing
$ ruby -v

ruby/rails setup on ubuntu

I created a new VM using virtualbox and ubuntu 14. I then installed rvm using the following...
\curl -sSL https://get.rvm.io | bash -s stable --ruby
I'm still quite new to ubuntu/linux so I'm trying to get a handle on the terminal commands. So, I think that I first did a
sudo su -
thinking that this would allow me to specify my password once and then remember it for each command. But now I'm thinking that it instead changed me to the root account instead of my own? The reason I suspect this is because when I first open a terminal under my account and type in ruby -v, I get..
The program 'ruby' can be found in the following packages:
* ruby
* ruby 1.8
Try: sudo apt-get install <selected package>
If I then do a sudo su - and follow it with ruby -v, I get
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
So, I'm not sure if I've done something wrong with the rvm installation or if there's some way to get my own account to use the same version of ruby as root? Thanks.
From the comments, you seem to have installed RVM as root. Doing that will make RVM and its rubies only "visible" to the root user. (Actually installing RVM for any user only makes it visible to that specific user AFAIK).
To fix that, first remove the root RVM installation, run sudo su - to become root (if you aren't already - to check what user you are you can run whoami). Then run the following:
rvm implode
This removes RVM altogether.
Next exit to become a normal user (again, check with whoami, if you're stuck just open a new terminal window) and run the RVM installation command:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
This should get you out of your problem.

Install Ruby on Rails using rvm on Ubuntu 12.04

I am trying to install Ruby on Rails using rvm on ubuntu 12.04. I am following the steps given in https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm , but I am unable to install Rails successfully. When I run gem install rails, it does nothing.
Previously, by using the above link, I have successfully installed it several times. But this time, i couldn't.
Output of
gem install rails -V:
HEAD https //rubygems.org/specs.4.8.gz 302 Moved Temporarily
HEAD https //s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz
200 OK
GET https //rubygems.org/specs.4.8.gz
302 Moved Temporarily ...
GET https //rubygems.org/quick/Marshal.4.8/rack-1.4.5.gemspec.rz
302 Moved Temporarily
It always stops at this point. Need some guidance to successfully install it.
Step One — Install Ruby with RVM
Before we do anything else, we should run a quick update to make sure that all of the packages we download to our VPS are up to date:
sudo apt-get update
Once that's done, we can start installin
g RVM, Ruby Version Manager. This is a great program that lets you use several versions of Ruby on one server; however, in this case, we will just use it to install the latest version of Ruby on the droplet.
If you do not have curl on your system, you can start by installing it:
sudo apt-get install curl
To install RVM, open terminal and type in this command:
\curl -L https://get.rvm.io | bash -s stable
After it is done installing, load RVM. You may first need to exit out of your shell session and start up a new one.
source ~/.rvm/scripts/rvm
In order to work, RVM has some of its own dependancies that need to be installed. To automatically install them:
rvm requirements
You may need to enter your root password to allow the installation of these dependencies.
On occasion the zlib package may be reported as missing. The RVM page describes the issue and the solution in greater detail here.
Step Two — Install Ruby
Once you are using RVM, installing Ruby is easy.
rvm install ruby
The latest ruby is now installed. However, since we accessed it through a program that has a variety of Ruby versions, we need to tell the system to use the version we just installed by default.
rvm use ruby --default
Step Three — Install RubyGems
The next step makes sure that we have all the required components of Ruby on Rails. We can continue to use RVM to install gems; type this line into terminal.
rvm rubygems current
Step Four — Install Rails
Once everything is set up, it is time to install Rails. To start, open terminal and type in:
gem install rails
This process may take a while, be patient with it. Once it finishes you will have Ruby on Rails installed on your droplet.
i did this:
sudo apt-get install git
sudo apt-get install curl
curl -L https://get.rvm.io | bash -s stable --ruby
sudo apt-get install git-core
source ~/.rvm/scripts/rvm
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
rvm autolibs enable
rvm reload
rvm requirements
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
rvm install ruby-2.0
curl -L https://get.rvm.io | bash -s stable --rails
Hope, it helps.
Refer Installing rvm wih stable ruby, use this command
\curl -L https://get.rvm.io | bash -s stable --ruby
After successful installation of ruby, install rails as a gem.
gem install rails
The most basic Vagrant box you can find to get Rails on Ubuntu. (This uses Ubuntu 14, but you can just change the box, should work roughly the same).
https://github.com/joelgerard/rails-vagrant
Also, checkout the bootstrap.sh if you want straight forward BASH.

Did I install Ruby 1.9.3 correctly on RHEL?

Before you say yum -y install ruby193... I did that.
Please note that I am not a Ruby developer, but need this program as part of another developer's work via web services. (He is not available.) Any help would be greatly appreciated.
I attempted to install a library per instructions and got:
[root#ctbroker console]# gem install json -v '1.8.0'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension. /opt/rh/ruby193/root/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /opt/rh/ruby193/root/usr/share/include/ruby.h
Gem files will remain installed in /opt/rh/ruby193/root/usr/local/share/gems/gems/json-1.8.0 for inspection.
Results logged to /opt/rh/ruby193/root/usr/local/share/gems/gems/json-1.8.0/ext/json/ext/generator/gem_make.out
I noticed that ruby.h is only on the machine at /usr/lib64/ruby/1.8/x86_64-linux/ruby.h.
What am I missing?
I was able to to fix this problem on my system by running:
sudo yum install ruby193-ruby-devel.x86_64
RHELyum install scl-utils scl-utils-build
CENTOSyum install centos-release-SCL -y
yum install ruby193 ruby193-ruby-devel augeas-devel libxml2-devel -y
scl enable ruby193 "ruby -v"
scl enable ruby193 "bash"
gem install json -v '1.8.0'
Step 1: Run below command on your terminal:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
Step 2: Install RVM Development version on your system:
\curl -sSL https://get.rvm.io | bash
For Latest version of Ruby i.e. 2.2.1 follow below steps:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
After this step you should see a message like:
To start using RVM you need to run source /home/user_name/.rvm/scripts/rvm in all your open shell windows, in rare cases you need to reopen all shell windows.
Step 3: Activate ruby using the message
Source /home/user_name/.rvm/scripts/rvm
Step 4: Check Ruby version
ruby --version
Step 5: Say thanks if it works ;)
You may need to install following packages first:
yum install ruby-devel.x86_64 libxslt-devel libxml2-devel

Resources