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.
Related
I need to install rvm on a new Ubuntu machine.
I would use rvm to switch to different ruby versions and gemsets required by different Ruby on Rails applications.
rvm suggests to use the Ubuntu package.
However Internet documentation on Rails on Ubuntu, such as at RailsApp, suggests to install rvm using instead the curl command with the --ruby or --rails options and the --autolibs=enable option for avoiding missing libraries:
$ \curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enable
I could not find information specific to the --rails option, so I do not understand what it does, install only the rails gem or install rails plus other gems useful for the rails environment, like bundler and json for instance. There is a bug however: RVM does not install Rails when invoked with curl.
Considering that I do not need the rails gem in the global gemset, supposing that the above bug will soon be fixed, what is in the end the best choice for installing rvm in Ubuntu: the Ubuntu package or the curl command with the (hopefully explained) --rails option plus the --autolibs=enable option?
It depends on your Ubuntu Version.
lsb_release -a
Then you can search for the instructions based on your Ubuntu Release.
For example I am using Linux Mint based on Ubuntu Xenial 16.
Ubuntu uses the apt package manager to install packages
To find packages type in your terminal
apt search rvm
it will return a list of packages. To learn more about apt use:
apt --help
apt <command> --help
man apt
To install RVM you need to always reference their official webpage or github page
For ubuntu RVM has an official Ubuntu Page which give you the following instructions:
https://github.com/rvm/ubuntu_rvm
Follow those instructions
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.
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.
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
I'm installing Ruby on Rails on Virtual Box/Ubuntu 13.10. Below are the steps
ruby -v
=> The program 'ruby' can be found in the following packages ... Try: sudo apt-get install
source /my account/...
==> Ok.
\curl -L https://get.rvm.io | bash
=> I've got a message thanking me for using RVM. In case of problems, I should consult their website or twitter.
rvm requirements
==> Requirments installation successful.
type rvm | head -n 1
==> rvm is a function
rvm list known
==> I get a list of ruby's versions
rvm install 2.0.0 -C --enable-shared, --with-openssl-dir=/usr/local
==> Install of ruby 2.0.0 complete. Please consider upgrading to ruby 2.1.0 ...
rvm list
==> rvm rubies
=* ruby-2.0.0-p353 [i686 ]
# => - current
# =* - current && default
# * - current
rvm use 2.0.0#railstutorial_rails_4_0 --create --default
==> ok.
rvm gemset list
==> gemsets for ruby-2.0.0-p353 ...
(default)
global
=> railstutorial_rails_4_0
gem -v
=> The program 'gem' can be found in the following packages:
ruby1.9.1
rubygems
try: sudo apt-get install
Why do I need to install ruby again? I thought I did so in step 7. I've gone over and over the same steps but I don't understand why it keeps telling me to install ruby again.
Thanks for helping
On your Terminal window go to Edit>Profile Preferences>Title and command, and check the box that says "Run command as a login shell". Restart your Terminal and try ruby -v and gem -v now. The versions should come up. If they don't then try re-installing them.
It sounds like the rvm ruby is not actually being used. If you run ruby -v, what do you get? I suspect it will be the message from the system about ruby being available in a package. Are you sure your $PATH is set correctly?
If you run /bin/bash --login and try again what happens?
check what rvm list returns.
I had multiple ruby versions installed but had not selected the ruby version to use.
I did rvm use <ruby_version> --default then ruby as well as gem command worked.