country_select gem 导致 "Could not find i18n_data-0.10.0 in any of the sources" 错误

country_select gem causes "Could not find i18n_data-0.10.0 in any of the sources" error

我正在尝试使用 country_select gem。我安装它使用 gem install country_select -v 4.0,然后我将它添加到我的 gem 文件的底部,运行 捆绑安装,然后当我尝试重新启动我的服务器时,我得到了这个错误:

Could not find i18n_data-0.10.0 in any of the sources
Run `bundle install` to install missing gems.

我已经搜索过这个错误,但没有找到其他人遇到这个问题 - 如果您能提供帮助,我们将不胜感激。

这是我的gem文件:

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

ruby '2.7.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.3'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

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

#country select gemfile
gem 'country_select', '~> 4.0'

捆绑安装 returns 以下内容:

The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Using rake 13.0.1
Using concurrent-ruby 1.1.7
Using i18n 1.8.5
Using minitest 5.14.2
Using thread_safe 0.3.6
Using tzinfo 1.2.7
Using zeitwerk 2.4.0
Using activesupport 6.0.3.3
Using builder 3.2.4
Using erubi 1.9.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.10
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.7.0
Using rails-html-sanitizer 1.3.0
Using actionview 6.0.3.3
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 6.0.3.3
Using nio4r 2.5.3
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.3
Using actioncable 6.0.3.3
Using globalid 0.4.2
Using activejob 6.0.3.3
Using activemodel 6.0.3.3
Using activerecord 6.0.3.3
Using mimemagic 0.3.5
Using marcel 0.3.3
Using activestorage 6.0.3.3
Using mini_mime 1.0.2
Using mail 2.7.1
Using actionmailbox 6.0.3.3
Using actionmailer 6.0.3.3
Using actiontext 6.0.3.3
Using public_suffix 4.0.6
Using addressable 2.7.0
Using bindex 0.8.1
Using msgpack 1.3.3
Using bootsnap 1.4.8
Using bundler 2.1.4
Using byebug 11.1.3
Using regexp_parser 1.7.1
Using xpath 3.2.0
Using capybara 3.33.0
Using childprocess 3.0.0
Using i18n_data 0.10.0
Using sixarm_ruby_unaccent 1.2.0
Using unicode_utils 1.4.0
Using countries 3.0.1
Using sort_alphabetical 1.1.0
Using country_select 4.0.0
Using ffi 1.13.1
Using jbuilder 2.10.1
Using rb-fsevent 0.10.4
Using rb-inotify 0.10.1
Using listen 3.2.1
Using method_source 1.0.0
Using pg 1.2.3
Using puma 4.3.6
Using rack-proxy 0.6.5
Using thor 1.0.1
Using railties 6.0.3.3
Using sprockets 4.0.2
Using sprockets-rails 3.2.2
Using rails 6.0.3.3
Using rubyzip 2.3.0
Using sassc 2.4.0
Using tilt 2.0.10
Using sassc-rails 2.1.2
Using sass-rails 6.0.0
Using selenium-webdriver 3.142.7
Using spring 2.1.1
Using spring-watcher-listen 2.0.1
Using turbolinks-source 5.2.0
Using turbolinks 5.2.1
Using web-console 4.0.4
Using webdrivers 4.4.1
Using webpacker 4.3.0
Bundle complete! 18 Gemfile dependencies, 80 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

在朋友的帮助下,我解决了这个问题。这可能是因为我通过命令行下载 gem 然后将其添加到我的 gem 文件,这导致我的 country_select gem 的依赖项出现问题。

我尝试了很多方法来修复它,但我不确定是什么解决了它,所以我是这样做的:

我删除了 gemfile.lock 和 运行 捆绑安装并再次尝试 rails 服务器。这导致找不到其他文件。我尝试删除 gemfile.lock 和 运行 其他命令:bundle update --all、bundle install --redownload 或 bundle pristine。每次,rails 服务器都不会启动服务器,因为它 'could not find nio4r-2.5.4 in any of the sources'.

最后,我尝试了 运行“bundle exec rails 服务器”并启动了服务器。但是,我的“rails 测试”命令仍然无效。我想我需要在 rails 命令之前添加“bundle exec”才能继续工作。这可能是唯一修复它的方法。