Ruby on rails 找不到gem';mysql2(<;0.5,>;=0.3.18)和#x27;在gem文件中列出的任何gem源中

Ruby on rails 找不到gem';mysql2(<;0.5,>;=0.3.18)和#x27;在gem文件中列出的任何gem源中,ruby-on-rails,ruby,Ruby On Rails,Ruby,我在创建新的rails应用程序时遇到以下错误。我运行了bundle安装,但没有运行它 无法在gem文件中列出的任何gem源中找到gem“mysql2(=0.3.18)。 Gemfile git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end # B

我在创建新的rails应用程序时遇到以下错误。我运行了bundle安装,但没有运行它

无法在gem文件中列出的任何gem源中找到gem“mysql2(<0.5,>=0.3.18)。

Gemfile

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
git_源代码(:github)do | repo_名称|
repo_name=“#{repo_name}/#{repo_name}”除非repo_name.include?(“/”)
"https://github.com/#{repo_name}.git“
结束
#捆绑边缘Rails:gem'Rails',github'Rails/Rails'
gem'rails',“~>5.1.5”
#使用mysql作为活动记录的数据库
gem'mysql2','>=0.3.18','<0.5'
#使用Puma作为应用程序服务器
宝石“彪马”,“大于3.7”
#将SCS用于样式表
gem'sass-rails',“~>5.0”
#使用Uglifier作为JavaScript资产的压缩器
gem'uglifier','>=1.3.0'
#看https://github.com/rails/execjs#readme 获取更多受支持的运行时
#宝石“therubyracer”,平台::ruby

当我尝试使用您提供的内容时,我能够安装
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
源代码'https://rubygems.org'
git|u源(:github){| repo |“https://github.com/#{repo}.git}
ruby“2.5.0”
#捆绑边缘Rails:gem'Rails',github'Rails/Rails'
gem'rails',“~>5.2.0.rc1”
#使用Puma作为应用程序服务器
宝石“彪马”,“大于3.11”
#使用mysql作为活动记录的数据库
gem'mysql2','>=0.3.18','<0.5'
#将SCS用于样式表
gem'sass-rails',“~>5.0”
#使用Uglifier作为JavaScript资产的压缩器
gem'uglifier','>=1.3.0'
#看https://github.com/rails/execjs#readme 获取更多受支持的运行时
#宝石“迷你赛车手”,平台::ruby

尝试删除Gemfile.lock并再次运行bundle安装

rm Gemfile.lock
bundle install
检查并更新文件中的版本