简体   繁体   中英

Rails issue on starting up after successful installation

I have already installed rails on my 2 desktop machine through VM's (RedHat Linux) and there was no issue after installation , rails worked perfectly. This time when I try installing in my Cent-OS server, followed same process but after installation, it is not working.

**rails -v** 
**rails s**

The above command throws -bash: rails: command not found . Had gone through almost al the posts similar about this issue and i found $PATH in .bashrc or .bash_profile seems to be the most commmon issue and many have fixed on making the PATH. I tried all those but still that doesn't fix my issue.

Any rails specialist here could help me out? Need to understand What is making the issue in my case.

sh-4.1$ ~]# gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.0
  - RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p484@rails_4
  - RUBY EXECUTABLE: /usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/rvm/gems/ruby-1.9.3-p484@rails_4/bin
  - SPEC CACHE DIRECTORY: /root/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/rvm/gems/ruby-1.9.3-p484@rails_4
     - /usr/local/rvm/gems/ruby-1.9.3-p484@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc --bindir /app/interpreters/ruby/1.9.3/bin/"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/rvm/gems/ruby-1.9.3-p484@rails_4/bin
     - /usr/local/rvm/gems/ruby-1.9.3-p484@global/bin
     - /usr/local/rvm/rubies/ruby-1.9.3-p484/bin
     - /usr/local/rvm/bin
     - /opt/res/ruby/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /sbin
     - /bin
     - /usr/sbin
     - /usr/bin
     - /root/bin
sh-4.1$ ~]# which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby
sh-4.1$ ~]# echo $PATH
/usr/local/rvm/gems/ruby-1.9.3-p484@rails_4/bin:/usr/local/rvm/gems/ruby-1.9.3-p484@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p484/bin:/usr/local/rvm/bin:/opt/res/ruby/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
sh-4.1$ ~]# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM function
sh-4.1$ ~]

    [sh-4.1$ ~]# pwd
/usr/local/rvm/gems/ruby-1.9.3-p484@rails_4/bin
sh-4.1$ ~]# ls
ruby_executable_hooks
[sh-4.1$ ~]# pwd
/usr/local/rvm/gems/ruby-1.9.3-p484@rails_4/gems
[sh-4.1$ ~]# ls
actionmailer-4.0.2  activerecord-deprecated_finders-1.0.3  builder-3.1.4  mail-2.5.4              polyglot-0.3.3   railties-4.0.2         thread_safe-0.1.3
actionpack-4.0.2    activesupport-4.0.2                    erubis-2.7.0   mime-types-1.25.1  rack-1.5.2       sprockets-2.10.1       tilt-1.4.1
activemodel-4.0.2   arel-4.0.1                             hike-1.2.3     minitest-4.7.5     rack-test-0.6.2  sprockets-rails-2.0.1  treetop-1.4.15
activerecord-4.0.2  atomic-1.1.14                          i18n-0.6.9     multi_json-1.8.2   rails-4.0.2      thor-0.18.1            tzinfo-0.3.38
[sh-4.1$ ~]# 


 [sh-4.1$ ~]# hash -r
 [sh-4.1$ ~]# echo $GEM_PATH
/usr/local/rvm/gems/ruby-1.9.3-p484:/usr/local/rvm/gems/ruby-1.9.3-p484@global
[sh-4.1$ ~]# echo $PATH
/usr/local/rvm/gems/ruby-1.9.3-p484/bin:/usr/local/rvm/gems/ruby-1.9.3-p484@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p484/bin:/usr/local/rvm/bin:/opt/res/ruby/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[sh-4.1$ ~]#

I had the same issue with ruby 2.1.1p76 and rails 4.0.4 on mint cinnamon.

After installation it worked first time but when i tried rails command after logging out. It said rails is not installed. Assuming you have rvm, ruby and rails installed, do

rvm use ruby --default

If it gives an error about ruby use .. do

/bin/bash --login

and try again

rvm use ruby --default

and now when you will type rails, it will work

run:

rvm use 1.9.3-p484@rails_4
gem install rails
rails -v

Does ruby -v show any specific version number? If yes then go to the root of your rails app and do gem install rails .

If ruby -v does not show any specific version then do rvm install 1.9.3 (instead of 1.9.3 you can also use 2.0.0 or any other older ones). Then once the installation completes do rvm use 1.9.3 --default .

Note: Do not use sudo apt-get install rails , just the gem is enough.

Finally i fixed the issue. As i thought, there was something messed up in the installation. I found no rails executable file under gem/bin dir.

Previously my gems/bin has only ruby_executable_hooks , since there was no executable file like rails (Really i don't know if this was really issue) but I thought to re install rvm & rails once again from scratch.

RVM re-installation:

rvm remove ... # take the output of rvm list and do rvm remove for each item in the list
rvm cleanup all
rvm install 2.0.0

Updated gem version:

gem update --system 2.1.9 

Installing Rails:

gem install rails --version 4.0.2
rails -v

So this was i found before and after in gems/bin dir * Before * (when rails was not working even though PATH and al other stuff's were perfect)

[sh-4.1$ ~]# pwd
/usr/local/rvm/gems/ruby-2.0.0-p353/bin
[sh-4.1$ ~]# ls
ruby_executable_hooks

** After re-installation **

[sh-4.1$ ~]# pwd
/usr/local/rvm/gems/ruby-2.0.0-p353/bin
[sh-4.1$ ~]# ls
erubis  rackup  rails  ruby_executable_hooks  sprockets  thor  tilt  tt  update_rubygems

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM