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

60,412

Solution 1

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

Solution 2

If you're running a rails command immediately after installing rails, you will need to restart your terminal before your commands will be recognized.

Solution 3

Just had the same issue just put the following in your .bashrc

PATH="${PATH}:/var/lib/gems/1.8/bin/"

Solution 4

Assuming ruby-2.0.0-p247 is installed, rails is located at following location.

prayag@prayag$ ls -l ~/.rvm/gems/ruby-2.0.0-p247/bin/
total 60
-rwxr-xr-x 1 prayag prayag 484 Oct  2 00:20 cap
-rwxr-xr-x 1 prayag prayag 487 Oct  2 00:20 capify
-rwxr-xr-x 1 prayag prayag 475 Oct  1 21:13 erubis
-rwxr-xr-x 1 prayag prayag 469 Oct  1 21:13 rackup
-rwxr-xr-x 1 prayag prayag 480 Oct  1 21:18 rails
-rwxr-xr-x 1 prayag prayag 494 Oct  2 00:27 restclient
-rwxrwxr-x 1 prayag prayag 368 Oct  1 21:10 ruby_executable_hooks
-rwxr-xr-x 1 prayag prayag 467 Oct  2 00:27 sass
-rwxr-xr-x 1 prayag prayag 475 Oct  2 00:27 sass-convert
-rwxr-xr-x 1 prayag prayag 467 Oct  2 00:27 scss
-rwxr-xr-x 1 prayag prayag 487 Oct  1 21:20 sprockets
-rwxr-xr-x 1 prayag prayag 483 Oct  2 00:29 stripe-console
-rwxr-xr-x 1 prayag prayag 467 Oct  1 21:17 thor
-rwxr-xr-x 1 prayag prayag 467 Oct  1 21:20 tilt
-rwxr-xr-x 1 prayag prayag 474 Oct  1 21:16 tt

[1] .bash_profile should already be containing following line, if not add.

 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

[2] Add following line to the end of .bashrc.

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
PATH="${PATH}:${HOME}/.rvm/gems/ruby-2.0.0-p247/bin/"

[3] Reload ~/.bashrc

$ source ~/.bashrc

And, it should work.

Solution 5

If you’re running rbenv you’ll need to run rbenv rehash go get access to the rails-api command.

Share:
60,412
rgoytacaz
Author by

rgoytacaz

Updated on September 29, 2020

Comments

  • rgoytacaz
    rgoytacaz over 3 years

    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?

  • rgoytacaz
    rgoytacaz over 14 years
    The problem isnt with ruby, ruby works great. But when running rails it says its not installed, although if I do gem list, it will properly show to me, rails 2.3.5
  • rgoytacaz
    rgoytacaz over 14 years
    it isnt a problem of putting the path there, it seems rails it not installed at all, how do I check if its really installed? whats its executable? where does it lives?
  • Priyank
    Priyank over 14 years
    I looked up the bin folder of my ruby installation. It has a "rails" file. If i rename that to anything else and try to run rails; it doesn't scaffold or create projects..instead says that rails is not installed do sudo apt-get install to install rails. But if I rename it back to rails; then it starts working. So I am pretty sure that as long as rails is installed properly and you have it in bin folder it should run. Maybe I haven't installed it as a gem plus I am using JRuby.
  • TK.
    TK. over 14 years
    Run gem environment and you'll find EXECUTABLE DIRECTORY.
  • rgoytacaz
    rgoytacaz over 14 years
    You ARE GREAT! THANKS TK! Thats exactly what I needed. It turns out that installing it through gem doesnt create a symlink. I created it and points it to the executable directory. working great
  • john-jones
    john-jones over 12 years
    PATH="${PATH}:/var/lib/gems/1.8/bin/"
  • Hlung
    Hlung over 11 years
    @rgoytacaz how do you create a symlink?
  • Kev
    Kev over 11 years
    Be careful when posting copy and paste boilerplate/verbatim answers to multiple questions, these tend to be flagged as "spammy" by the community. If you're doing this then it usually means the questions are duplicates so flag them as such instead: stackoverflow.com/a/13149543/419
  • Kyle Clegg
    Kyle Clegg over 11 years
    Flagged. I'll be more careful about that. The answer may helpful to those that come across either post (like me), which is why I shared it.
  • Pijusn
    Pijusn almost 11 years
    @Hlung Use sudo ln -s /usr/local/bin/rails /usr/bin/rails or change it accordingly.