'Rails: Command not Found after successful install
So I installed ruby, gems and rails - however whenever I type rails I get the rails: Command not found. error.
I did a dump of my local gems, which I'll include below
*** LOCAL GEMS ***
actionmailer (3.2.7)
actionpack (3.2.7)
activemodel (3.2.7)
activerecord (3.2.7)
activeresource (3.2.7)
activesupport (3.2.7)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.0.0)
bundler (1.1.5)
daemon_controller (1.0.0)
erubis (2.7.0)
fastthread (1.0.7)
hike (1.2.1)
i18n (0.6.0)
io-console (0.3)
journey (1.0.4)
json (1.5.4)
mail (2.4.4)
mime-types (1.19)
minitest (2.5.1)
multi_json (1.3.6)
mysql (2.8.1)
passenger (3.0.14)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.7)
railties (3.2.7)
rake (0.9.2.2)
rdoc (3.12, 3.9.4)
sprockets (2.1.3)
thor (0.15.4)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
I also checked my gem environment setup (below)
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-freebsd8.1]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-freebsd-8
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
and echo'd my $PATH variable /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
I attempted to go into where the whereis command told me rails was installed
whereis rails
rails: /usr/local/bin/rails
and execute rails from there, again , I got rails: Command not found.
I am running FreeBSD on a VPS, and would like to learn some additional languages beyond PHP, but I can't seem to figure this one out for the life of me ... any help would be amazing.
Solution 1:[1]
If you installed Rails only via Bundler, then rails will only be accessible if you run bundle exec rails.
A "naked" rails command will only exist if you gem install rails directly without Bundler.
Solution 2:[2]
If you are using rbenv, it is possible you will need to run rbenv rehash after installing your dependencies for you rails application. ie. bundle install
From digitalocean:
Whenever you install a new version of Ruby or a gem that provides commands, you should run the rehash sub-command. This will install shims for all Ruby executables known to rbenv, which will allow you to use the executables:
Hope this helps!
Solution 3:[3]
If your app is running in production but can't find rails command on root then this might help:
run
script/rails c ENV
Instead of
rails c ENV
I had the same issue and resolved it this way. The app was running with nginx/passenger but wasn't able to run rails console/ rails server on production.
Solution 4:[4]
I just encountered this same problem under another scenario where I installed rails along with rvm on ubuntu-20.04.
I had to add the following line to my ~/.bashrc ( or `~/.profile')
# Where you installed rvm...
source ~/.rvm/scripts/rvm
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Grant Birchmeier |
| Solution 2 | domdambrogia |
| Solution 3 | arsaKasra |
| Solution 4 | Darren Hicks |
