Installed Rails but the rails command says it's not installed

Viewed 61609

I'm using Ubuntu 9.10 Karmic Koala and Ruby 1.9.1.

I installed Rails using sudo gem install rails, which installed all the libraries for me.

When I type rails in the terminal it says.

The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails rails: command not found

I can find rake, which is under rake1.9.1, but Rails is nowhere to be found, can someone point me in the right direction?

Edit: path to ruby isn't the problem, the problem is where is rails? how do I execute it? rails just doesn't work, where does the exectuable lives?

12 Answers

As others say, this may very well be a PATH variable issue on your bashrc/bash_profile file.

You can learn how to change PATH..

You can get the current PATH variable by typing echo $PATH

gem should have placed the rails executable script in the same location as ruby's. I'd look in there and make sure the permissions are set correctly and it is executable.

If you are using rbenv don't forget add

eval "$(rbenv init -)"

into your .bash_profile or other start up scripts. run rbenv rehash is also needed.

I am using macOS and in my case, I needed to add this line to ~/.zshrc:

export PATH="/usr/local/lib/ruby/gems/3.1.0/gems/railties-7.0.2.3/exe:$PATH"

It can be done like this:

echo 'export PATH="/usr/local/lib/ruby/gems/3.1.0/gems/railties-7.0.2.3/exe:$PATH"' >> ~/.zshrc

My ruby was installed by brew.

You may want to include the path of Ruby/Jruby folder in your bashrc file. That would ensure that you are able to run it from anywhere. Don't forget to restart terminal or "source .bashrc" to reload variables in terminals.

Related