Rails:安装成功后找不到命令

时间:2021-10-05 11:38:39

So I installed ruby, gems and rails - however whenever I type rails I get the rails: Command not found. error.

所以我安装了ruby,gem和rails - 但是每当我输入rails时,我都会找到rails:找不到命令。错误。

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

并回显我的$ PATH变量/ 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安装的地方

whereis rails
rails: /usr/local/bin/rails

and execute rails from there, again , I got rails: Command not found.

并从那里执行rails,再次,我得到了rails:找不到命令。

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.

我在VPS上运行FreeBSD,想学习除PHP以外的其他一些语言,但我似乎无法想象出这一点我的生活...任何帮助都会令人惊叹。

4 个解决方案

#1


2  

I'm certain that your problem was caused by gems in the other gem directory, here:

我确定你的问题是由其他gem目录中的gem引起的,这里:

/root/.gem/ruby/1.9.1

So for future readers, look in your other GEM PATHS.

因此,对于未来的读者,请查看您的其他GEM路径。

(And then if that's wrong I'll update this answer appropriately.)

(如果那是错的,我会适当地更新这个答案。)

#2


22  

If you installed Rails only via Bundler, then rails will only be accessible if you run bundle exec rails.

如果仅通过Bundler安装Rails,则只有在运行bundle exec rails时才能访问rails。

A "naked" rails command will only exist if you gem install rails directly without Bundler.

只有在没有Bundler的情况下gem直接安装rails时,才会存在“naked”rails命令。

#3


2  

If your app is running in production but can't find rails command on root then this might help:

如果您的应用程序在生产中运行但在root上找不到rails命令,那么这可能有所帮助:

run

script/rails c ENV

script / rails c ENV

Instead of

rails c ENV

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.

我遇到了同样的问题并以这种方式解决了。该应用程序使用nginx / passenger运行,但无法在生产时运行rails console / rails服务器。

#4


0  

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

如果您使用的是rbenv,则可能需要在为rails应用程序安装依赖项后运行rbenv rehash。即。捆绑安装

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:

无论何时安装新版本的Ruby或提供命令的gem,都应该运行rehash子命令。这将为rbenv已知的所有Ruby可执行文件安装填充程序,这将允许您使用可执行文件:

Hope this helps!

希望这可以帮助!

#1


2  

I'm certain that your problem was caused by gems in the other gem directory, here:

我确定你的问题是由其他gem目录中的gem引起的,这里:

/root/.gem/ruby/1.9.1

So for future readers, look in your other GEM PATHS.

因此,对于未来的读者,请查看您的其他GEM路径。

(And then if that's wrong I'll update this answer appropriately.)

(如果那是错的,我会适当地更新这个答案。)

#2


22  

If you installed Rails only via Bundler, then rails will only be accessible if you run bundle exec rails.

如果仅通过Bundler安装Rails,则只有在运行bundle exec rails时才能访问rails。

A "naked" rails command will only exist if you gem install rails directly without Bundler.

只有在没有Bundler的情况下gem直接安装rails时,才会存在“naked”rails命令。

#3


2  

If your app is running in production but can't find rails command on root then this might help:

如果您的应用程序在生产中运行但在root上找不到rails命令,那么这可能有所帮助:

run

script/rails c ENV

script / rails c ENV

Instead of

rails c ENV

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.

我遇到了同样的问题并以这种方式解决了。该应用程序使用nginx / passenger运行,但无法在生产时运行rails console / rails服务器。

#4


0  

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

如果您使用的是rbenv,则可能需要在为rails应用程序安装依赖项后运行rbenv rehash。即。捆绑安装

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:

无论何时安装新版本的Ruby或提供命令的gem,都应该运行rehash子命令。这将为rbenv已知的所有Ruby可执行文件安装填充程序,这将允许您使用可执行文件:

Hope this helps!

希望这可以帮助!