Ruby-on-rails Rails 一直告诉我它当前没有安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7788946/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rails keeps telling me that it's not currently installed
提问by nil
I use rvmto manage different rubies and their gemsets. My shell is zsh with oh-my-zsh configured with basic settings. Enabled oh-my-zsh plugins are ruby, rails, osx, and git. Here's the command I used to install ruby-1.8.7 and rails-3.0.7.
我rvm用来管理不同的红宝石和它们的宝石。我的 shell 是 zsh,其中 oh-my-zsh 配置了基本设置。启用 oh-my-zsh 插件是 ruby、rails、osx 和 git。这是我用来安装 ruby-1.8.7 和 rails-3.0.7 的命令。
rvm install 1.8.7
rvm use 1.8.7
gem install rails -v=3.0.7
and then I typed railsand got:
然后我输入rails并得到:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
I've tried more thorough installs also, Like reinstall rubygemsafter switching to ruby-1.8.7, or create a completely new gemset, but with no luck.
我也尝试过更彻底的安装,比如rubygems切换到 ruby-1.8.7 后重新安装,或者创建一个全新的 gemset,但没有运气。
Here's the rvm info:
这是rvm信息:
ruby-1.8.7-p352@rails:
system:
uname: "Darwin yicai.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
rvm:
version: "rvm 1.8.6 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2011-06-30"
platform: "i686-darwin10.8.0"
patchlevel: "2011-06-30 patchlevel 352"
full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0]"
homes:
gem: "/Users/nil/.rvm/gems/ruby-1.8.7-p352@rails"
ruby: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352"
binaries:
ruby: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/ruby"
irb: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/irb"
gem: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin/gem"
rake: "/Users/nil/.rvm/bin/rake"
environment:
PATH: "/Users/nil/.rvm/gems/ruby-1.8.7-p352@rails/bin:/Users/nil/.rvm/gems/ruby-1.8.7-p352@global/bin:/Users/nil/.rvm/rubies/ruby-1.8.7-p352/bin:/Users/nil/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/sbin"
GEM_HOME: "/Users/nil/.rvm/gems/ruby-1.8.7-p352@rails"
GEM_PATH: "/Users/nil/.rvm/gems/ruby-1.8.7-p352@rails:/Users/nil/.rvm/gems/ruby-1.8.7-p352@global"
MY_RUBY_HOME: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352"
IRBRC: "/Users/nil/.rvm/rubies/ruby-1.8.7-p352/.irbrc"
RUBYOPT: ""
gemset: "rails"
and the gem version is 1.8.10, the latest.
并且 gem 版本是最新的 1.8.10。
回答by Kyle Clegg
If you're running a rails command immediately after installing rails, you will need to restart your terminal before your commands will be recognized.
如果您在安装 rails 后立即运行 rails 命令,则需要重新启动终端才能识别您的命令。
回答by asgeo1
I had this problem today. Not completely related to your question, but since this page is what comes up in Google when I search for "Rails is not currently installed on this system", I thought I would add my answer:
我今天遇到了这个问题。与您的问题不完全相关,但由于此页面是我搜索“Rails 当前未安装在此系统上”时出现在 Google 中的页面,我想我会添加我的答案:
What happened is that I was using ruby 1.9.2 with rails for a while, but then I needed to use ruby 1.8.7 to run some other script that I found.
发生的事情是我使用 ruby 1.9.2 和 rails 有一段时间,但后来我需要使用 ruby 1.8.7 来运行我发现的其他一些脚本。
Afterwards, I wanted to change by system back to using 1.9.2, and that's where the problem started:
之后,我想通过系统改回使用1.9.2,这就是问题开始的地方:
$ rvm list
=> ruby-1.8.7-p352 [ x86_64 ]
ruby-1.9.2-p290 [ x86_64 ]
$ rvm use 1.9.2
I thought that would do the trick. But no, that gives me the "Rails is not currently installed on this system"message.
我认为这会奏效。但是不,这给了我“此系统上当前未安装 Rails”消息。
What I had forgotten is that I had configured rails using an rvm gemset. So I needed to specify the correct gemset when I was selecting which ruby version to make active.
我忘记的是我已经使用 rvm gemset 配置了 rails。因此,当我选择要激活的 ruby 版本时,我需要指定正确的 gemset。
$ rvm gemset list_all
gemsets for ruby-1.8.7-p352 (found in /Users/asgeo1/.rvm/gems/ruby-1.8.7-p352)
global
gemsets for ruby-1.9.2-p290 (found in /Users/asgeo1/.rvm/gems/ruby-1.9.2-p290)
global
rails31
$ rvm use ruby-1.9.2-p290@rails31
That did the trick.
这就是诀窍。
回答by Dhaulagiri
I had the same issue and found that RVM was not showing as installed either if I tried the rvm command. All it took to fix both problems was running this command in the terminal
我遇到了同样的问题,发现如果我尝试 rvm 命令,RVM 也没有显示为已安装。解决这两个问题所需要的只是在终端中运行这个命令
$ source ~/.rvm/scripts/rvm
回答by Cameron Lowell Palmer
Mac OS X, rbenv, and rails
Mac OS X、rbenv 和 rails
I was getting the exact same issue but with rbenvrather than rvm. After verifying a correct .bash_profile.
我遇到了完全相同的问题,但rbenv不是rvm. 验证正确的 .bash_profile 后。
.bash_profile
.bash_profile
export PATH="$HOME/.rbenv/bin:/usr/local/bin:$PATH"
eval "$(rbenv init -)"
Restart the shell
重新启动外壳
exec $SHELL -l
Check the path
检查路径
echo $PATH
Finally
最后
I repeatedly installed and uninstalled rails but it was never placed in the .rbenv/bin directory after rbenv rehash. In the end I did a find . -name railsand uninstalled every gem that was returned and uninstalled rails. Then:
我反复安装和卸载了 rails,但在 rbenv rehash 之后它从未被放置在 .rbenv/bin 目录中。最后,我做了一个find . -name rails并卸载了所有返回的 gem 并卸载了 rails。然后:
$ gem install rails
$ rbenv rehash
$ which rails
/Users/palmerc/.rbenv/shims/rails
回答by Palermo Andre Deschamps
Restart your terminal and then re-run your rails command
重新启动您的终端,然后重新运行您的 rails 命令
回答by David Nehme
Rails is not reporting that it isn't installed. Your Debian system is telling you that rails isn't installed. One thing about rvm is that it relies on some complicated bash shell scripting and you sometimes need to start a fresh shell for changes to appear. You should also make sure that the correct rvm shell commands were added to your .zshrc file. Also check your path to make sure the ~/.rvm/gems/... path in included.
Rails 没有报告它没有安装。您的 Debian 系统告诉您没有安装 rails。关于 rvm 的一件事是它依赖于一些复杂的 bash shell 脚本,有时您需要启动一个新的 shell 才能显示更改。您还应该确保将正确的 rvm shell 命令添加到您的 .zshrc 文件中。还要检查您的路径以确保包含 ~/.rvm/gems/... 路径。
回答by Wilson
I ran into this issue using rbenv. Turns out gem install railsdid in fact install Rails but railswas not recognized as an executable. The fix for me was to run rbenv rehash.
我使用 rbenv 遇到了这个问题。事实证明gem install rails确实安装了 Rails,但rails未被识别为可执行文件。我的解决方法是运行rbenv rehash.
I found this fix and more details on setting up Rails 5 at https://gorails.com/setup/osx/10.11-el-capitan
我在https://gorails.com/setup/osx/10.11-el-capitan上找到了有关设置 Rails 5 的此修复程序和更多详细信息
回答by Yoonis
I had a similar issue, but with rbenv.
我有一个类似的问题,但使用 rbenv。
I originally installed ruby on bash. Then I played around with .bashrc in VIM, messed that file up, and reset it back to default. In doing so, I unknowingly removed the exported rbenv $PATH. Because of this, my terminal no longer recognized that I had ruby installed.
我最初在 bash 上安装了 ruby。然后我在 VIM 中使用了 .bashrc,弄乱了该文件,并将其重置为默认值。这样做时,我在不知不觉中删除了导出的 rbenv $PATH。因此,我的终端不再识别我安装了 ruby。
I revisited the ruby installation page (https://gorails.com/setup/ubuntu/15.04) and tried to set up my rbenv path again with this command:
我重新访问了 ruby 安装页面(https://gorails.com/setup/ubuntu/15.04)并尝试使用以下命令再次设置我的 rbenv 路径:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
It failed.
它失败了。
Luckily, I had already switched to zsh (with oh-my-zsh) between the time I messed up my .bashrc and the time I tried to access irb from my terminal.
幸运的是,在我搞砸 .bashrc 和尝试从终端访问 irb 之间,我已经切换到 zsh(使用 oh-my-zsh)。
My solution was to set up the rbenv path per the installation guide, but by replacing all instances of .bashrcwith .zshrclike so:
我的解决方案是建立在rbenv路径按照安装向导,而是通过替换的所有实例.bashrc与.zshrc像这样:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
Hope this helps!
希望这可以帮助!
回答by Connor Leech
add source ~/.rvm/scripts/rvmto your .bashrcfile if rails installs fine but then you get the error "rails is not currently installed". This frustrated me for a while but I found the answer here: http://www.codelearn.org/blog/how-to-install-ruby-rails-screencasts-linux-mac-windows
如果 rails 安装正常,则添加source ~/.rvm/scripts/rvm到您的.bashrc文件中,但是您会收到错误“rails 当前未安装”。这让我沮丧了一段时间,但我在这里找到了答案:http: //www.codelearn.org/blog/how-to-install-ruby-rails-screencasts-linux-mac-windows
回答by Rimian
I just reloaded my terminal
我刚刚重新加载了我的终端
source ~/.bashrc
See: How do I reload .bashrc without logging out and back in?

