简体   繁体   English

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

[英]Cannot find gem even though bundle reports it is installed

I am attempting to install kaminari, but Rails cannot find it or a dependency (I've run into both - currently dependency):我正在尝试安装 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.

This is despite it being installed:尽管已安装它:

∴ 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

I first attempted to delete Gemfile.lock .我首先尝试删除Gemfile.lock Same result.结果相同。 Then I deleted the refstats gemset and recreated it.然后我删除了refstats gemset 并重新创建了它。 Same result.结果相同。 Then I tried bundle install --force and got same result.然后我尝试了bundle install --force并得到了相同的结果。

I've tried both gem 'kaminari', '~> 1.2' and gem 'kaminari' in my Gemfile .我在我的 Gemfile 中尝试了gem 'kaminari', '~> 1.2'gem 'kaminari' Gemfile

Any suggestions?有什么建议么?

EDIT:编辑:

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]

Edit 2:编辑2:

∴ cat .ruby-version
ruby-2.6.3

I have no.ruby-gemset, but my console is reporting I'm using the right one:我没有.ruby-gemset,但我的控制台报告我使用的是正确的:

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

EDIT 3: Well, the gremlin has disappeared, though I cannot say why.编辑3:好吧,小精灵消失了,虽然我不能说为什么。 This is what I did:这就是我所做的:

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

I really cannot say why it started working, unless installing to the rvm root had some effect.我真的不能说它为什么开始工作,除非安装到 rvm root 有一些效果。 But that's what I did, and it's all working now.但这就是我所做的,现在一切正常。 Thanks for the time.谢谢你的时间。

Just because the gem is installed on your machine does not mean it is part of your bundle.仅仅因为 gem 安装在你的机器上并不意味着它是你的包的一部分。 bundle exec scopes the available gems to only what is included in your Gemfile and those gems dependencies. bundle exec将可用 gem 的范围限定为 Gemfile 和那些 gem 依赖项中包含的内容。 See if i18n for that version shows up when you run bundle show .运行bundle show时,查看该版本的i18n是否显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 脚本/控制台不起作用; 报告“缺少Rails宝石。 即使rails显示为已安装,也请`gem install -v = rails ......” - script/console won't work; reports “Missing the Rails gem. Please `gem install -v= rails`…” even though rails shows as installed Ruby on Rails:即使已安装gem仍未找到 - Ruby on Rails: gem not found even though it is installed 指示即使未安装也未安装的Ruby gem - Ruby gem indicative of not being installed even though it is 即使安装了正确的gem,rails中的NoMethodError也是如此 - NoMethodError in rails even though correct gem is installed 即使它位于Gemfile中并且捆绑安装位于Dockerfile中,也找不到gem mysql2 - Could not find gem mysql2 even though it's in the Gemfile and bundle install is in the Dockerfile 即使我已安装Rails,也无法找到exception_notification gem - Rails can't find exception_notification gem even though I have it installed 找不到耙子,但安装了宝石。 已经进行了捆绑更新等 - Cannot find rake, but gem is installed. Already did bundle update, etc 缺少Rails 2.3.4宝石。 即使它已安装! - Missing the Rails 2.3.4 gem. Even though it's installed! 即使安装了bundler-1.1.3,“ bundle install”也会失败 - “bundle install” fails even though bundler-1.1.3 is installed bash: bundle: 即使安装了 bundler 也找不到命令 - bash: bundle: command not found even though bundler is installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM