简体   繁体   English

成功安装后启动时出现Rails问题

[英]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. 我已经通过VM(RedHat Linux)在我的2台台式机上安装了rails,安装后没有任何问题,rails可以正常工作。 This time when I try installing in my Cent-OS server, followed same process but after installation, it is not working. 这次,当我尝试在Cent-OS服务器中进行安装时,遵循相同的过程,但是安装后却无法正常工作。

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

The above command throws -bash: rails: command not found . 上面的命令抛出-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. 几乎遍历了所有与此问题类似的帖子,我发现.bashrc或.bash_profile中的$ PATH似乎是最常见的问题,许多人已将其固定为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. 我在薄荷肉桂上遇到了与红宝石2.1.1p76和rails 4.0.4相同的问题。

After installation it worked first time but when i tried rails command after logging out. 安装后,它第一次工作,但是当我注销后尝试使用rails命令时。 It said rails is not installed. 它说没有安装滑轨。 Assuming you have rvm, ruby and rails installed, do 假设您已安装rvm,ruby和rails,请执行

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 现在,当您键入rails时,它将起作用

run: 跑:

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

Does ruby -v show any specific version number? ruby -v是否显示任何特定的版本号? If yes then go to the root of your rails app and do gem install rails . 如果是,则转到rails应用程序的根目录并执行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). 如果ruby -v没有显示任何特定版本,请执行rvm install 1.9.3 (代替1.9.3,您也可以使用2.0.0或任何其他较旧的版本)。 Then once the installation completes do rvm use 1.9.3 --default . 然后,一旦安装完成,请rvm use 1.9.3 --default

Note: Do not use sudo apt-get install rails , just the gem is enough. 注意:不要使用sudo apt-get install rails ,只要gem就足够了。

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. 我在gem / bin目录下没有找到Rails可执行文件。

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. 以前,我的gems / bin只有ruby_executable_hooks ,因为没有像rails这样的可执行文件(真的,我不知道这是否是真正的问题),但是我想从头开始重新安装rvm&rails。

RVM re-installation: 重新安装RVM:

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版本:

gem update --system 2.1.9 

Installing Rails: 安装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) 因此,这是我在gems / bin目录中之前和之后发现的* 之前的* (当PATH和其他东西很完美时Rails无法正常工作时)

[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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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