rvm command not found - ruby-on-rails

I installed rvm with rails, from the official website of RVM, I specified the command suggested by the tutorial.
When the installation my system has rails 4.0.0, rvm 01/23/12, ruby 2.0.0, bundler gem 1.3.5 and 2.0.3
But I need to install ruby 1.9 to practice with a course that I am currently doing. "Rails for Zombies 2"
I try to execute the instruction rvm install 1.9.3 and the console returns this message:
rvm: command not found

Possible duplicate of: Ubuntu rvm setup issue
Your problem is that RVM is not loaded when you open a new terminal.
To solve this, run this command line: (if using login-shell)
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Or this (if using non-login shell):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
Or if you are using zsh (and/or oh-my-zsh):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.zshrc
This will add the path to RVM to load at each Terminal instantiation. You must either close and reopen your terminals or simply call source ~/.bashrc (or ~/.bash_profile or ~/.zshrc).

I had this problem after installing zsh. I'm a domain user so my $PATH and $HOME are not as straight-forward. What worked for me was
echo "source /usr/share/rvm/scripts/rvm" >> ~/.zshrc

The latest installation needs the users to be added to the Group rvm and then need to login again.
Please note that closing the terminal and reopening is not enough; the user has to logout and log back to take the Group addition in effect.
Adding the user to the Group can be done by:
sudo usermod -a -G rvm <user>
The binaries can also be at different locations based on the method you followed during the installation.
I had them at /usr/share/rvm/
You can also look at /usr/local/rvm/scripts/rvm
Then you add this line to the end of ~/.bashrc
[[ -s /usr/share/rvm/scripts/rvm ]] && source /usr/share/rvm/scripts/rvm
Note: If you are using a shell other than bash you may need to add the path accordingly.
For instance, if you using zsh shell add the above lines to the ~/.zshrc file.

Related

Sublime text when building .rb file it fails and give me "bash: ruby: command not found"

I have a file called "solutions.rb" and I'm trying to build it and see the output using sublime text.
the content of solutions.rb
puts "Hello world"
after pressing ctrl+B to build the file I got this error
bash: ruby: command not found
[Finished in 0.0s with exit code 127]
[shell_cmd: ruby "/home/elta3lab/Desktop/solution.rb"]
[dir: /home/elta3lab/Desktop]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]
knowing that I tried some solutions from answers I foudn on stackoverflow, but they never work, and I didn't understand every command I wrote because I'm not that good with linux.
Looks like ruby is not installed on your system.
Open the terminal, them run the following commands:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.5.1
rbenv global 2.5.1
ruby -v
Them try compiling it again.
Maybe they are already installed but it's not found so maybe it's not in the default path. On a shell console try this (it's already suggested in a previous answer to your question):
export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Then issue a which ruby. See if it returns anything. Try also a ruby -v and see if it prints the ruby version.
If you have installed ruby using rbenv please double check if you installed it system wide or for a specific user. If you installed it as root let's say, when you're running sublime as a regular user, it won't find ruby. Either install it using rbenv for that specific user you're trying to run Sublime or install it system wide using a package manager so ruby will be available for all the users of that linux system.

RVM not working on Vagrant

No command 'rvm' found, but there are 21 similar ones rvm: command not found. Comes up when I'm in Vagrant on linux ubuntu 14.04.
Installed Vagrant and VirtualBox.
Found over at rvm command not found
Your problem is that RVM is not loaded when you open a new terminal.
To solve this, run this command line: (if using login-shell)
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Or this (if using non-login shell):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
This will add the path to RVM to load at each Terminal instanciation (close & re-open a terminal after you did this).
You could also try, if you're sshd into your box, running sudo apt-get update and then installing it?
I had this problem as well. I found that I had to add the full path for rvm in the provisioning script. The path is added to the environmental $PATH variable but not known to Vagrant during the provisioning.
/usr/local/rvm/bin/rvm install ruby-2.4.0
After provisioning:
[vagrant#Ruby ~]$ echo $PATH
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin: \
/usr/local/rvm/bin:/home/vagrant/.local/bin:/home/vagrant/bin
[vagrant#Ruby ~]$ which rvm
/usr/local/rvm/bin/rvm
Another option might be to source /etc/profile before executing an rvm, but I have not tried that yet.

Ubuntu rvm setup issue

I followed this tutorial below:
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
This worked perfectly for me; however, I have one small problem?
Each time I open a new terminal I have to run this command in order for rails to work:
source ~/.rvm/scripts/rvm
What is the problem and why is rvm not recognized
This is what I see after I open a new terminal and verify rails:
robert#rob:~$ rails -v
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Thanks
I highly recommend you to use the official website to install RVM: https://rvm.io/rvm/install
Your problem is that RVM is not loaded when you open a new terminal, this is why you have to manually add the source at each instance of the Terminal.
To solve this, run this command line: (if using login-shell)
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Or this (if using non-login shell):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
This will add the path to RVM to load at each Terminal instanciation (close & re-open a terminal after you did this).
Take a look at #mpapis comments

Rails on Linux Mint 11

I have installed ruby via rvm on Mint 11 no problem. Installed gems, ditto. Installed rails via gem install rails, and when I type rails -v it returns the correct version. Until I close that terminal and reopen a terminal. When I do that and type rails -v I get the message
The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails
If I then type
rvm use 1.9.2-p180 --default
and then type rails -v I again get the correct version...until I close the terminal.
I should add that I have added a path statement to my .bashrc pointing to the 1.9.2-p180 directory in my .rvm directory.
Typing ruby -v always returns the correct version.
Create .bashrc file and add .rvm command
$ sudo touch ~/.bashrc
$ sudo gedit ~/.bashrc
(Add line to .bashrc file)
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
Logout and Login OR just update user profile from .bashrc with following command
$ . ~/.bashrc
Try adding this command to your .profile and reopening your shell:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
Use project rvmrc files. You can see how to set this up here http://beginrescueend.com/rvm/best-practices/
That way you keep all your gems seperate for each project and it's dead simple to set up
Try which rails. Maybe there is a link to a stub that gives you the note.
If that is the case calling the full path might help, e.g. /usr/local/bin/rails

RVM Command: source ~/.rvm/scripts/rvm

I'm going through the rails by example tutorial series. I'm trying my best to find solutions prior to asking questions, so if I have missed anything I apologise.
Every time I need to boot up RVM from the command line in terminal I need to punch a command so that RVM initialises: source ~/.rvm/scripts/rvm
Is this normal? It seems that I cant get the RVM commands to work unless I punch in this code prior. Note I only have to enter the command once, not every time I need to enter an RVM command.
Many thanks for your help.
Put this in your ~/.profile or ~/.bashrc:
# This loads RVM into a shell session.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
So you don't have to manually type it for every session.
Further Tip
If you want to use gnome terminal (comes as standard in Ubuntu) with rvm, you can do the following:
Edit the default profile. Check the following setting:
"Run command as a login shell"
This will stop loading the standard .bashrc by default. Fix this by making a soft link of .rvmrc pointing at .bashrc in your home directory
cd
ln -s .bashrc .rvmrc
Try closing terminal and then re-opening it to install a specific version of Ruby as seen in this video at 2:32.
For example, I typed curl -L https://get.rvm.io | bash -s stable --ruby
Then I quit and reopened the terminal, typed rvm install 2.2.3 and it worked.
If your rvm command is not found:
(to check, enter the command rvm list, which gives:)
/bin/bash: rvm: command not found
To solve it, follow these steps:
Install rvm
whereis rvm
rvm: /home/username/.rvm/bin/rvm
source ~/.rvm/bin/rvm
now test your rvm again
rvm list

Resources