即使软件包报告已安装gem,也找不到gem

时间:2020-07-22 15:10:37

标签: ruby-on-rails ruby bundler

我正在尝试安装kaminari,但是Rails找不到它或一个依赖项(我遇到了两种情况-当前是依赖项):

∴ bundle exec rails g kaminari:config
Could not find i18n-1.8.4 in any of the sources
Run `bundle install` to install missing gems.

尽管已安装,但这仍然是

∴ bundle info i18n
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`.
  * i18n (1.8.4)
    Summary: New wave Internationalization support for Ruby
    Homepage: https://github.com/ruby-i18n/i18n
    Path: /Users/shawn/.rvm/gems/ruby-2.6.3@refstats/gems/i18n-1.8.4

我首先尝试删除Gemfile.lock。结果相同。然后,我删除了refstats宝石集并重新创建了它。结果相同。然后我尝试了bundle install --force,并得到了相同的结果。

我在gem 'kaminari', '~> 1.2'中尝试过gem 'kaminari'Gemfile

有什么建议吗?

编辑:

宝石文件:

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

ruby '2.6.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3', '~> 1.4'
gem 'pg'
# 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'

gem 'devise', '~> 4'
gem 'kaminari'

# 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]

编辑2:

∴ cat .ruby-version
ruby-2.6.3

我没有.ruby-gemset,但是我的控制台报告我使用的是正确的:

12:36:50 shawn@macbook-pro:~/Documents/uga/refstats (git:master:547a0b4)  ruby-2.6.3@refstats
∴

编辑3: 好吧,小鬼不见了,尽管我不能说为什么。这就是我所做的:

1) Created new test rails app
2) Bundle install in new gemset
3) Added kaminari to Gemfile
4) Bundle install
5) Generated kaminari config successfully
6) Switch to non-working app, but forget to switch gemset, putting me in rvm with no gemset. Don't notice. 
7) Bundle install 
8) Notice things get installed, including kaminari. Notice I'm on wrong gemset.
9) Switch to correct gemset.
10) Bundle install (which installs nothing)
11) Generate kaminari config successfully

除非安装到rvm根目录有一定效果,否则我真的不能说为什么它开始起作用。但这就是我所做的,并且现在都在工作。感谢您的时间。

1 个答案:

答案 0 :(得分:0)

仅仅是因为您的计算机上安装了gem,并不意味着它是捆绑软件的一部分。 bundle exec将可用的gem范围限定为Gemfile中包含的内容以及这些gem依赖项。查看运行i18n时是否显示该版本的bundle show