简体   繁体   中英

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 server

to work, or really any other rails command. Whenever I attempt a rails command I get the help screen like this:

$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)...

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:

rails new first_app

This actually created two apps: one called 'new' and another called 'first_app'. It also didn't create a default Gemfile.

I am running Rails 3.1.0 and Ruby 1.9.2. on 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. 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.

I'd strongly recommend rvm (assuming you're not using it). 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 . 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. To confirm this, type which rails and I'd guess it won't be under ~/.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

It seems your are using an older version of Rails.

Try running rails -v and which rails

For me rails new "first_app" produced these files:

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

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