无法启动Rails服务器的问题

4

刚开始学习Rails。我使用的是Windows Vista,从http://rubyinstaller.org/下载了最新版本的Ruby并成功安装。

ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

我运行:

gem update --system
gem sources -a http://gemcutter.org
gem install rails

没有错误报告。
rails --v
Rails 3.1.0

接下来,我创建了一个文件夹用于存放我的Rails项目,并按照以下步骤创建了新的Rails应用:

rails new test
cd test
bundle install

(再次没有报错)

但是当我运行 rails server 命令时,出现了以下错误:

rails server
←[31mCould not find rails-3.1.0 in any of the sources←[
←[33mRun `bundle install` to install missing gems.←[0m

我尝试再次运行bundle,但仍然没有成功...之后,如果我再次输入rails -v,我会得到与之前相同的错误。我必须关闭窗口控制台并重新打开才能使rails -v再次工作!!

有人遇到过这个问题吗?你能帮忙吗?

谢谢!!!

按要求,gemfile内容如下:

source 'http://rubygems.org'

gem 'rails', '3.1.0'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

gem 'jquery-rails'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

bundle install 的结果:

Fetching source index for http://rubygems.org/
Using rake (0.9.2)
Using multi_json (1.0.3)
Using activesupport (3.1.0)
Using bcrypt-ruby (3.0.0)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.0)
Using erubis (2.7.0)
Using rack (1.3.2)
Using rack-cache (1.0.3)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.0)
Using actionpack (3.1.0)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.0)
Using arel (2.2.1)
Using tzinfo (0.3.29)
Using activerecord (3.1.0)
Using activeresource (3.1.0)
Using ansi (1.3.0)
Using bundler (1.0.18)
Using coffee-script-source (1.1.2)
Using execjs (1.2.4)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using rdoc (3.9.4)
Using thor (0.14.6)
Using railties (3.1.0)
Using coffee-rails (3.1.0)
Using jquery-rails (1.0.13)
Installing rails (3.1.0)
Using sass (3.1.7)
Using sass-rails (3.1.0)
Using sqlite3 (1.3.4)
Using turn (0.8.2)
Using uglifier (1.0.2)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem
is installed.

你的Gemfile是什么样子的?bundler的输出是什么?你在使用RVM吗? - Jordan Running
谢谢回复!关于RVM,恐怕我不知道它是什么...现在读了一些资料,但要么它是自动安装的,要么我没有它...其他所需信息在原帖中! - jribeiro
RVM通常用于Linux/Mac/*nix,除非您使用的是Cygwin,但我怀疑您是否从http://rubyinstaller.org安装了Ruby和Rails。 - Augusto
你如何创建一个名为 test 的应用程序?在Windows和Linux上都会出现错误,错误信息为“无效的应用程序名称test。请提供一个不与保留的Rails单词匹配的名称。” - Augusto
它实际上被称为“hello”。对于错误我很抱歉。 - jribeiro
1个回答

7
尝试使用bundle exec rails server代替rails server

1
我尝试了,但这次收到了以下信息:“在任何来源中都找不到rails-3.1.0”。 - jribeiro
确保您的vendor目录中没有rails - John Douthat
对不起,您说的“vendor”是什么意思? - jribeiro
通常情况下,你的应用程序的根目录中会有一个名为 vendor 的文件夹,与 appconfiglib 等文件夹并列。 - John Douthat
2
尝试运行 bundle checkbundle list 命令,查看是否出现任何错误。 - John Douthat
让我们在聊天中继续这个讨论 - John Douthat

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接