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
Related
I'm using ubuntu, zshrc, and after installing rails, using
gem rvm all do gem install rails
and getting a successful install, i'm getting a
zsh: command not found: rails
I'm guessing this has to do with my ~/.zshrc file
I have this at the end of it:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
I'm a noob at understanding how paths work, any idea how to get terminal to recognize rails commands?
My system was fine, but today, after installing MySQL server, I can't use the terminal to program my Rails application.
When I open a terminal session, I see:
Last login: Sun Dec 8 13:31:06 on console
-bash: [: missing `]'
-bash: rt: command not found
I tried searching for this error but can't find a solution.
I am running Mac 10.7 OS X.
No commands pertaining to Ruby on Rails are found.
I built an application and installed Rails, but when I run a Rails command I get:
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.
How do I fix this?
My bashrc file contains only one line:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
My bash profile contains following:
export PATH=$PATH:/usr/local/mysql/bin
[ [-s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
rt PATH=$PATH:/usr/local/mysql/bin
I checked history and this is what I ran
vi .bash_profile
vi .bash_profile
user#computer:$ mysql -u root
mysql -u root
vi .bash_profile
mysql -u root
/usr/local/mysql-5.6.15-osx10.7-x86_64/bin/mysqld_safe ; exit;
mysql
What else can I show to help with this problem?
Your .bash_profile is messed up. Modify what looks like this:
[ [-s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
rt PATH=$PATH:/usr/local/mysql/bin
To look like this:
[[-s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=$PATH:/usr/local/mysql/bin
As #TinMan pointed out, you'll want to remove the export PATH line from your .bashrc file.
I had a similar problem (although I'm running Ubuntu). When I opened a new terminal and navigated to my project root, I was surprised to find that Rails was not recognized as a program. I checked the version of Ruby and noted that there was a discrepancy between the two terminals I had open. When I tried to switch Ruby versions with RVM, I was told
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
so I ran /bin/bash --login. Then, I was able to switch to Ruby 2.1.1 with RVM use ruby-2.1.1 and all my rails commands worked again.
Basically what happened is that RVM only installs gems locally for each Ruby verison. Unless you select the version of Ruby that you were using when you installed the gem, you won't be able to use the gem unless you reinstall it.
I came to this page after receiving this error with a slightly different cause. While the CDub's answer is directly applicable to OP's question, I would generally recommend users of Mac OS X Terminal who have this error to do the following:
Open ~/.bash_profile in a text editor.
Look for any instances of "rt" at the beginning of a line.
Change all instances to "export".
It looks like some packages out there are writing a command into ~/.bash_profile that Mac OS X does not like, and we need to manually correct this.
For reference, I am on OS 10.10.2.
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.
I installed RVM, Ruby 1.9.2 and Rails 3.0.9 on Lion which works fine. Only problem is, after I close the terminal I need to execute this:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
for it to pick up RVM.I then need to make RVM use Ruby 1.9.2 first before I can do Rails stuff again.
How can I make this permanent?
After you first execute
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
you shouldn't need to do it again. That line appends the necessary file inclusion information RVM into your .bash_profile. If you are using bash (as opposed to zsh, ksh, csh, tcsh or any other shell), then RVM will be accessible each time you open a new session. If you are using a different shell, that line may need to be in a different startup file. For example, if you are using zsh, then you'll probably want to append it to your ~/.zshrc file.
Having done this, simply running rvm --default use ruby-1.9.2 once should ensure that you have the desired version of Ruby by default. Note, you should not need to add this line to your .bash_profile or similar.
try this
rvm --default use ruby-1.9.2
In order to make Terminal (e.g. bash) enable RVM every time you open it, edit ~/.profile and add the following line to it:
[[ -s "/Users/foo/.rvm/scripts/rvm" ]] && source "/Users/foo/.rvm/scripts/rvm" # This loads RVM into a shell session.
Then to make the RVM's version of ruby default, as fl00r has mentioned, run:
rvm --default use ruby-1.9.2
Alternatively, you can add an .rvmrc file to the root folder of your app that uses Rails 3.0.9 and specify which version of Ruby you want to use with that project there:
rvm ruby-1.9.2
Even better, you should create a gemset by running rvm gemset create rails-3.0.9 and update you .rvmrc file to become like this:
rvm ruby-1.9.2#rails-3.0.9
Then run cd into the project once again (you must cd into it once again), and run bundle install.
This way your project will have its own isolated gemset.
this also work for me
rvm --default use 1.9.2
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