【问题标题】:Ruby on Rails Bundle Install Not workingRuby on Rails 捆绑安装不起作用
【发布时间】:2017-10-31 13:55:05
【问题描述】:

所以我目前正在使用 Michael Hartl 教程学习 Ruby on Rails(目前真的很菜鸟 - 对编程真的很陌生)。我试图编辑我正在制作的“hello_app”中的 gemfiles - 正如迈克尔所说的那样,但是当我回到终端运行捆绑安装时 - 我得到以下内容而不是安装:

Abduls-MacBook-Pro:hello_app Monahim$ bundle install

[!] There was an error parsing `Gemfile`: unexpected fraction part after numeric literal -   gem 'sqlite3' , 1.3.12
                 ^
/Users/Monahim/railsmhartl/hello_app/Gemfile:40: syntax error, unexpected tIDENTIFIER, expecting keyword_end
gem 'byebug', '9.0.0' platform: :mri, end
                            ^
/Users/Monahim/railsmhartl/hello_app/Gemfile:55: syntax error, unexpected end-of-input, expecting keyword_end. Bundler cannot continue.

 #  from /Users/Monahim/railsmhartl/hello_app/Gemfile:38
 #  -------------------------------------------
 #  group :development, :test do
 >    gem 'sqlite3' , 1.3.12
#    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
 #  -------------------------------------------
Abduls-MacBook-Pro:hello_app Monahim$ 

有人可以告诉我发生了什么吗?我该如何解决?这是我的 Atom 文本编辑器中的内容:

source 'http://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "ht//githublinkhere /#{repo_name}.git"
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.1'
# Use sqlite3 as the database for Active Record

# Use Puma as the app server
gem 'puma', '~> 3.4.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.6'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 3.0.0'
# See /githubrailsreadmelinkhere for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2.1'
gem 'jquery-rails', '4.1.1'
# Turbolinks makes navigating your web application faster. Read more:          /githubturbolinkhere
gem 'turbolinks', '~> 5.0.1'
# Build JSON APIs with ease. Read more: linktojbuilder
gem 'jbuilder', '~> 2.4.1'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

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

group :development, :test do
  gem 'sqlite3' , 1.3.12
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', '9.0.0' platform: :mri, 
end
# Adds support for Capybara system testing and selenium driver

group :development do
  # Access an IRB console on exception pages or by using <%= console %>   anywhere in the code.
  gem 'web-console', '>= 3.1.1'
  gem 'listen', '>= 3.0.5', '< 3.0.8'
  # Spring speeds up development by keeping your application running in the background. Read more: /github.com/railsspringlinkhere
  gem 'spring' , '1.7.2.'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

非常感谢您完成此操作。请解释一下操作系统发生了什么,以便我学习并纠正错误。显然,您可以看出我对这款游戏非常非常陌生,但我渴望学习!

请指教, 谢谢!

【问题讨论】:

  • 试试这个,定义 gem 定义而不在你 Gemfile 中提供版本控制 gem 'sqlite3'。或者提供版本控制试试这个gem 'sqlite3', '1.3.12'

标签: ruby-on-rails ruby sqlite rubygems


【解决方案1】:

您的Gemfile 中的group :development, :test 中有两个错别字/错误:

  1. 您的sqlite3 gem 版本中缺少引号(或双引号):

    gem 'sqlite3' , 1.3.12
                   ^      ^ 
    
  2. gem 'byebug' 中缺少逗号 ,

    gem 'byebug', '9.0.0' platform: :mri,
                         ^              ^
    

所以group :development, :test 应该是这样的:

group :development, :test do
  gem 'sqlite3', '1.3.12'
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', '9.0.0', platform: :mri 
end

【讨论】:

  • 它在使用您的编辑和捆绑更新后工作。谢谢!
  • @abdulmuhaimen 太好了!请不要忘记接受答案(点击绿色勾号)。祝你好运!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多