I am attempting to install RVM on Xubuntu and am having no luck getting the OS/terminal to recognize rvm as something that it can call.
I have been following the instructions here: http://beginrescueend.com/rvm/install/
I first call:
sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
This seems to be executing correctly. I then run:
sudo echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
The text is appended to the end of the file.
Next I close out the terminal completely and reopen it. I try running:
type rvm | head -1
It responds:
bash: type: rvm: not found
If I try just calling rvm it responds:
The program 'rvm' is currently not installed. You can install it by typing: sudo apt-get install ruby-rvm
Clearly I am doing something wrong, I cannot seem to determine what that is. Thank you.
By using the sudo version of the install script, you have installed the multi user version of rvm, and then you ran the single user "sourcing" script with sudo...
When using the multi user version, rvm will not install into $HOME/.rvm, but in /usr/local/rvm.
Therefore you will have to use the multi user way to source the rvm script, and that is to add your user to the rvm group.
As shine already posted though, you probably didn't want to install system wide rvm to start with.
Don't do it with sudo. You have installed it for a root and you're not a root.
RVM should be installed in your home folder, you don't need superuser privileges for that.
Related
I've just setup an ubuntu server and need to deploy a small rails app. I'm using mina.
When I execute "mina setup", the following part of the code gives me a message(you can find it below the code) But the setup process finishes successfully.
deploy.rb
task :environment do
invoke :'rvm:use[ruby-2.2.2#default]'
end
-
$ rvm use "ruby-2.2.2#default" --create
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.
How can I get rid of this message?
I found a few similar topics but it didn't solve my problem.
here's how I installed rvm:
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ curl -sSL https://get.rvm.io | sudo bash -s stable
$ sudo usermod -a -G rvm `whoami`
ps
For the setup process I used info from the following articles:
Passenger library
Setting Up Ruby on Rails On Digital Ocean
I noticed that deploy.rb from second article has .bash_profile. I dont have this file( only .profile)
task :environment do
queue 'source ~/.bash_profile'
# For those using RVM, use this to load an RVM version#gemset.
invoke :'rvm:use[ruby-2.1.4]'
end
This is most probabaly because rvm is still not loaded to your bash. Load it using:
source ~/.rvm/scripts/rvm
followed by:
rvm use "ruby-2.2.2#default" --create
A permanent fix would be to add following line in your ~/.bashrc :
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I am trying to set versiĆ³n ruby version in the vagrant user with rvm using the following script into the vagrant file:
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get -y update
sudo apt-get -y install git ruby libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
nodejs
#Install ruby environment
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -L https://get.rvm.io | bash -s stable
sudo "source ~/.rvm/scripts/rvm"
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
sudo /usr/local/rvm/bin/rvm install 2.1.5
rvm 2.1.5 --default
sudo chown -R vagrant:vagrant /usr/local/rvm/gems/
gem install middleman
git clone XXXX
SHELL
END
Vagrant is returning me the following message:
/tmp/vagrant-shell: line 10: rvm: command not found
But if i run the command with the full path it returns me the following message:
/usr/local/rvm/bin/rvm 2.1.5 --default
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.
Is there anyway to execute the inline script in logging mode or other way to use rvm to set the default version?
Thanks :)
The alterations to the script provided would prevent the code above from exiting with an bad exit status.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provision "shell", inline: <<-SHELL
RUBY_VERSION="2.1.5"
sudo apt-get -y update
sudo apt-get -y install git nodejs
# Install ruby environment
if ! type rvm >/dev/null 2>&1; then
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -L https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
fi
if ! rvm list rubies ruby | grep ruby-${RUBY_VERSION}; then
rvm install ${RUBY_VERSION}
fi
rvm --default use ${RUBY_VERSION}
rvm all do gem install middleman
git clone <REPLACE_WITH_YOUR_REPO>
SHELL
end
Explanation of changes:
There is no need to source "~/.rvm/scripts/rvm". Firstly, it fails because it doesn't exist as mentioned previously due to vagrant running as a non-login shell. Secondly the installation of rvm creates startup files in /etc/profile.d/rvm.sh which handles this case for you. See https://rvm.io/integration/gnome-terminal. You will still see a warning (in red) in the vagrant's console output but the script doesn't fail because of a bad exit status. As a result we need to source /etc/profile.d/rvm.sh immediately after installing RVM because our current shell hasn't loaded rvm.sh yet. This was mentioned in the RVM installation output. An alternative is to break up the script into multiple parts to force trailing scripts to pick up the new path.
As vagrant is running as a non-login shell there is no need to change ownership of the /usr/local/rvm/gems/ folder. I think at some point vagrant did run scripts as the vagrant user but this has changed in more recent versions. Scripts will actually run as root; this occurs by default due to the privileged option on shell scripts; see Shell Provisioner. If you are uncertain which user is running you can do a whoami in the script. The script will run as the vagrant user if you de-escalate the privileges by setting privileged => false.
Added a conditional block around the rvm GPG key and installation. Unless you need rvm installed on every provision. An argument could be made that you might be trying to keep it up-to-date but that could potentially introduce unknowns and break the repeatable results from one day to the next.
Added a conditional block around the installation of the ruby version. This prevents the warning regarding the package is already installed, use reinstall.
Cleaned up the packages you were installing. You might re-look at this but the packages you were installing with apt-get will be automagically installed by the rvm installer and add extra fluff to your scripts.
Alternative and bit more flexible method
If you aren't stuck on using inline scripts. I would go the route as described in Using RVM with Vagrant. Some of the suggestions I made above I would re-apply to the general logical of the scripts in this article. One change that would be REQUIRED is in the install-rvm.sh script. Add the GPG key import; shown below:
#!/usr/bin/env bash
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s $1
Question is very simple:
I cannot install RVM (single-user installation), as if I follow the instructions on the RVM website, that is:
$ curl -L https://get.rvm.io | bash -s stable
I get a permission denied error at line 360 of the installation script file (the line that starts with echo):
# Perform the actual installation, first we obtain the source using whichever
# means was specified, if any. Defaults to head.
case "${version}" in
(head)
echo "${branch}" > "$rvm_path/RELEASE"
install_head ${branch:-master} || exit $?
;;
Here is the error message:
olivier#~$ curl -L https://get.rvm.io | bash -s stable
bash: line 360: /usr/local/rvm/RELEASE: Permission denied
If I add "sudo" before "bash" in the command above, it works fine, but it is then the multi-user install ...
Indeed, I solved this by uninstalling old versions of RVM: sudo rvm implode and then deleting the file /etc/rvmrc. Once done, I could install the single-user version and everything worked fine!
Sorry Remear, I wanted to edit your answer or complete it via my comment but I could not (comment can only be edited within 5 minutes...at least I upvoted...).
Once you have a system-wide install, you can't run a single-user install as it will detect your system-wide install first and try to update it.
But it is possible to have a root install & then user install by specifying the installation path :
curl -sSL https://get.rvm.io | bash -s stable --path $HOME/.rvm
You will also have to set the single-user install path in your user path manually as RVM does not create it when you already have a system-wide install (not really an intended use) :
# .bashrc
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
And also load your user rvm :
# .bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Are you setting rvm_path in ~/.rvmrc, or in /etc/rvmrc, or in one of your bash scripts? I'd recommend removing both of those files as well as ~/.rvm and then try installing rvm again WITHOUT sudo.
this work for me, first uninstall all versions and then as user (NO root) follow the next commands:
For example, I'm using Ruby 2.6.3 and Rails 5.2.2 and setting up helping a little in these web pages:
https://gorails.com/setup/ubuntu/20.04
https://rvm.io/rvm/install
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$ curl -sSL https://get.rvm.io | bash -s stable --ignore-dotfiles
$ source ~/.rvm/scripts/rvm
$ rvm install 2.6.3
$ rvm use 2.6.3 --default
$ ruby -v
$ gem install rails -v 5.2.2
$ rails -v
Check the paths:
$ which -a gem
$ which -a ruby
Now you can Add some gems (inside you app directory):
$ gem install faker
All works great for me, hope this helps!
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.
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.