![](/img/trans.png)
[英]Command 'rails server' not working or Rails server command not working
[英]Rails server command not working (other commands, as well)
我正在構建 Rails 應用程序的第一部分,但無法獲取命令
rails server
工作,或真正的任何其他 rails 命令。 每當我嘗試使用 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
等等(無論我輸入什么命令,它都會給我相同的“rails new”命令)......
關於我的系統中可能缺少什么或為什么這些命令沒有響應的任何想法? 謝謝
PS另一個奇怪的事情是當我創建這個應用程序時,最初,我使用了命令:
rails new first_app
這實際上創建了兩個應用程序:一個名為“new”,另一個名為“first_app”。 它也沒有創建默認的 Gemfile。
我正在運行 Rails 3.1.0 和 Ruby 1.9.2。 在 Ubuntu 10.04 上。
我只是遇到了這個問題。 每次執行“rails server”命令時,請確保您實際上位於 rails 應用程序的目錄中。 我不在目錄中。 愚蠢的錯誤但是,它發生了......
您可能已經安裝了 Rails 3.1.0,但正如 forresty 所提到的,我不相信您的路徑正在使用它。
我強烈推薦rvm (假設您沒有使用它)。 它將避免后續出現的問題,並且易於設置!
編輯
它可能仍在嘗試使用您的系統導軌。
rvm use 1.9.2
然后只做gem install rails
,沒有sudo
。 看看這是否有效。 RVM 使用您的配置文件來存儲它的所有 gem,我的猜測是當您輸入rails
,它使用的是系統一。 要確認這一點,請輸入which rails
,我猜它不會在~/.rvm/...
。
確保你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
看來您使用的是舊版本的 Rails。
嘗試運行rails -v
和which rails
對我來說, rails new "first_app"
產生了這些文件:
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
run git init from "."
並且似乎沒有安裝 git,所以它沒有繼續創建其余文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.