【问题标题】:Could not find gem 'mysql2 (< 0.5, >= 0.3.18)' in any of the gem sources listed in your Gemfile在 Gemfile 中列出的任何 gem 源中找不到 gem 'mysql2 (< 0.5, >= 0.3.18)'
【发布时间】:2018-08-12 03:05:04
【问题描述】:

创建新的 Rails 应用程序时出现以下错误。我运行了 bundle install 但没有成功。

在您的 Gemfile 中列出的任何 gem 源中都找不到 gem 'mysql2 (= 0.3.18)'。

宝石文件

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


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.5'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

【问题讨论】:

标签: ruby-on-rails ruby


【解决方案1】:

当我尝试使用您提供的内容时,我能够安装 mysql2 gem。试试这个(先更改或安装 ruby​​ 版本),如果它没有改变任何东西,请告诉我:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0.rc1'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.18', '< 0.5'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

【讨论】:

    【解决方案2】:

    尝试删除您的 Gemfile.lock 并再次运行 bundle install

    rm Gemfile.lock
    bundle install
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-02
      • 2012-02-11
      • 2017-07-14
      • 2015-06-13
      • 1970-01-01
      • 2014-05-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多