简体   繁体   English

Rails 服务器命令不起作用(其他命令也是如此)

[英]Rails server command not working (other commands, as well)

I'm in the very first part of building a rails app and I can't get the command我正在构建 Rails 应用程序的第一部分,但无法获取命令

rails server

to work, or really any other rails command.工作,或真正的任何其他 rails 命令。 Whenever I attempt a rails command I get the help screen like this:每当我尝试使用 rails 命令时,我都会得到如下帮助屏幕:

$rails server
Usage:
  rails new APP_PATH [options]

 Options:
-r, [--ruby=PATH]              # Path to the Ruby binary of your choice                                   # Default: /home/sgallagher/.rvm/rubies/ruby-1.9.2-    p290/bin/ruby
-b, [--builder=BUILDER]        # Path to a application builder (can be a filesystem path or URL)
-m, [--template=TEMPLATE]      # Path to an application template (can be a filesystem path or URL)
[--skip-gemfile]           # Don't create a Gemfile
      [--skip-bundle]            # Don't run bundle install
    -G, [--skip-git]               # Skip Git ignores and keeps

and so on (it gives me the same "rails new" command no matter what command I put in)...等等(无论我输入什么命令,它都会给我相同的“rails new”命令)......

Any ideas on what might be missing in my system or why these commands aren't responding?关于我的系统中可能缺少什么或为什么这些命令没有响应的任何想法? Thanks谢谢

PS Another peculiar thing is when I created this app, initially, I used the command: PS另一个奇怪的事情是当我创建这个应用程序时,最初,我使用了命令:

rails new first_app

This actually created two apps: one called 'new' and another called 'first_app'.这实际上创建了两个应用程序:一个名为“new”,另一个名为“first_app”。 It also didn't create a default Gemfile.它也没有创建默认的 Gemfile。

I am running Rails 3.1.0 and Ruby 1.9.2.我正在运行 Rails 3.1.0 和 Ruby 1.9.2。 on Ubuntu 10.04.在 Ubuntu 10.04 上。

I was just having this problem.我只是遇到了这个问题。 Make sure you are actually in the directory of your rails app whenever you execute the 'rails server' command.每次执行“rails server”命令时,请确保您实际上位于 rails 应用程序的目录中。 I wasn't in the dir.我不在目录中。 Dumb mistake but, it happens...愚蠢的错误但是,它发生了......

You may have installed Rails 3.1.0 but as forresty mentioned, I don't believe your path is using it.您可能已经安装了 Rails 3.1.0,但正如 forresty 所提到的,我不相信您的路径正在使用它。

I'd strongly recommend rvm (assuming you're not using it).我强烈推荐rvm (假设您没有使用它)。 It will avoid problems down the road and it's easy to set up!它将避免后续出现的问题,并且易于设置!

EDIT编辑

It's possible that it's still trying to use your system rails.它可能仍在尝试使用您的系统导轨。

rvm use 1.9.2 then just do gem install rails , no sudo . rvm use 1.9.2然后只做gem install rails ,没有sudo See if that works.看看这是否有效。 RVM uses your profile to store all of its gems, my guess is when you type rails , it's using the system one. RVM 使用您的配置文件来存储它的所有 gem,我的猜测是当您输入rails ,它使用的是系统一。 To confirm this, type which rails and I'd guess it won't be under ~/.rvm/... .要确认这一点,请输入which rails ,我猜它不会在~/.rvm/...

make sure you echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile确保你echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

It seems your are using an older version of Rails.看来您使用的是旧版本的 Rails。

Try running rails -v and which rails尝试运行rails -vwhich rails

For me rails new "first_app" produced these files:对我来说, rails new "first_app"产生了这些文件:

create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
run git init from "."

and it seems that git wasn't installed so it didn't proceed with the creation of the rest of the files并且似乎没有安装 git,所以它没有继续创建其余文件

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

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