[ACCEPTED]-Installed Rails but the rails command says it's not installed-gem
As others say, this may very well be a PATH 3 variable issue on your bashrc/bash_profile 2 file.
You can learn how to change PATH..
You can get the current PATH variable 1 by typing echo $PATH
If you're running a rails command immediately after 3 installing rails, you will need to restart 2 your terminal before your commands will 1 be recognized.
Just had the same issue just put the following 1 in your .bashrc
PATH="${PATH}:/var/lib/gems/1.8/bin/"
Assuming ruby-2.0.0-p247
is installed, rails
is located at following 3 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 2 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 1 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.
If you’re running rbenv you’ll need to run 2 rbenv rehash go get access to the rails-api 1 command.
gem
should have placed the rails executable 3 script in the same location as ruby's. I'd 2 look in there and make sure the permissions 1 are set correctly and it is executable.
I think this is not correct way to resolve 10 this problem. But What I have done is, I 9 have created a rails.rb file in my executable 8 directory because when I open that directory 7 file was not there and put the following 6 content.
#!/usr/bin/env ruby_noexec_wrapper
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'railties', version
load Gem.bin_path('railties', 'rails', version)
then I try to run rails s
in my project 5 and its works..
But before this make sure 4 that executable directory is in your path 3 like I have already in my machine :
/home/anand/.rvm/gems/ruby-1.9.3-p286/bin:/home/anand/.rvm/gems/ruby-1.9.3-p286@global/bin:/home/anand/.rvm/rubies/ruby-1.9.3-p286/bin:/home/anand/.rvm/bin
As per 2 TK said you can get the executable path 1 using gem environment
command
I added the following lines to my .bashrc 3 file and it worked.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source 2 "$HOME/.rvm/scripts/rvm" # Load RVM into 1 a shell session as a function
PATH="${PATH}:${HOME}/.rvm/gems/ruby-1.9.3-p327/bin/"
If you are using rbenv
don't forget add
eval "$(rbenv init -)"
into 2 your .bash_profile
or other start up scripts.
run rbenv rehash
is 1 also needed.
A possible solution is to not maintain two 6 different configuration files .bash_profile
and .bashrc
It's 5 suggested in this excellent post on the 4 difference between .bash_profile
and .bashrc
is to source .bashrc
from 3 your .bash_profile
file, then putting PATH and common 2 settings in .bashrc
.
Quoting,
add the following 1 lines to .bash_profile
:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
end quote
I am using macOS and in my case, I needed 2 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 1 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.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.