为什么我的Gemfile不会运行?

时间:2022-11-26 10:10:31

I am following the Hartl Ruby on Rails tutorial, and am in section 1.2.4 of the tutorial

我正在关注Hartl Ruby on Rails教程,并在本教程的1.2.4节中

When setting up a Rails app it says to run these commands:

在设置Rails应用程序时,它说要运行这些命令:

cd first_app_direcory
sublime Gemfile
bundle update

The sublime Gemfile command edits the Gemfile obviously, but when I try to run the command bundle update I get the following error:

sublime Gemfile命令显然编辑了Gemfile,但是当我尝试运行命令bundle update时,我收到以下错误:

bundle update
Gemfile syntax error:
ruby 2.0.0 
         ^
/home/cameron/ruby/ror/first_app/Gemfile:2:
syntax error, unexpected tINTEGER,
expecting '('
ruby 2.0.0 
          ^

I took these two lines out of the gemfile, even though it says to include them. Also, I tried Ruby 1.9.3, and still got the same error message.

我把这两行从gemfile中取出来,即使它说要包含它们。此外,我尝试了Ruby 1.9.3,仍然得到相同的错误消息。

ruby 2.0.0 
#ruby-gemset=railstutorial_rails_4_0

After taking these lines out, it worked. I am trying to get it to work with those lines in the gemfile though. How can I do this?

采取这些线后,它工作。我试图让它与gemfile中的那些行一起工作。我怎样才能做到这一点?

This is the full Gemfile:

这是完整的Gemfile:

source 'https://rubygems.org'
ruby 2.0.0 
#ruby-gemset=railstutorial_rails_4_0

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use sqlite3 as the database for Active Record
group :developent do
    gem 'sqlite3', '1.3.7'
end

# Use SCSS for stylesheets
gem 'sass-rails', '4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.1.1'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails', '2.2.1'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks', '1.1.1'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '1.0.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', '0.3.20',require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

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

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

2 个解决方案

#1


7  

You should have

你应该有

ruby '2.0.0'

instead of

ruby 2.0.0

in your Gemfile.

在你的Gemfile中。

#2


2  

I think you need quotes around the 2.0.0.

我认为你需要2.0.0附近的报价。

Something like ruby "2.0.0".

像ruby“2.0.0”之类的东西。

#1


7  

You should have

你应该有

ruby '2.0.0'

instead of

ruby 2.0.0

in your Gemfile.

在你的Gemfile中。

#2


2  

I think you need quotes around the 2.0.0.

我认为你需要2.0.0附近的报价。

Something like ruby "2.0.0".

像ruby“2.0.0”之类的东西。