ruby - 即使 gem 安装有效,Bundler 也找不到 gem

标签 ruby rubygems bundler jruby

对于这个 Gemfile:

source 'https://rubygems.org'

ruby '2.3.1' # equivalent version to what jruby supports

gem 'jrubyfx'

即使 it is clearly available,Bundler 也找不到 gem :

$ bundle install
Fetching gem metadata from https://api.rubygems.org/..........
Could not find gem 'jrubyfx' in any of the gem sources listed in your Gemfile.

如果我让 gem 自己完成工作, 可以很好地找到它:

$ gem install jrubyfx
Successfully installed jrubyfx-1.2.0-java
1 gem installed

所以现在我什至在我的系统上有它,但尽管它在本地存在,但 Bundler 仍然找不到它。

环境:

$ bundle --version
Bundler version 1.16.0.pre.3
$ gem --version
2.6.8
$ rbenv version
jruby-9.1.8.0 (set by /Users/trejkaz/Documents/prototype/.ruby-version)
$ ruby --version
jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit Server VM 25.151-b12 on 1.8.0_151-b12 +jit [darwin-x86_64]
$ jenv version
1.8 (set by /Users/trejkaz/Documents/prototype/.java-version)
$ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

我已经确认 gem 和 bundler 确实都在与 JRuby 一起运行——它们都需要很长时间才能启动,而我目前只安装了一个 JRuby(Homebrew 提供的最新 ruby​​-build 可用)。

到目前为止尝试过:

  • 将来源从 https 更改为 http
  • 更改 URL 以包含领先的 api。
  • --full-index 添加到 bundle 命令行,如对 this question 的回答中所建议的那样
  • this question看起来也很相似,但只是少了一个逗号

最佳答案

我查看了一些 github projectsGemfile使用相同的 gem。

尝试在ruby版本后面加上engineengine_version如下:

# Gemfile

ruby '2.3.1', engine: 'jruby', engine_version: '9.1.8.0'
source 'https://rubygems.org'

gem 'jrubyfx', '~> 1.2'

根据 bundler documentation :

Both :engine and :engine_version are optional. When these options are omitted, this means the app is compatible with a particular Ruby ABI but the engine is irrelevant. When :engine is used, :engine_version must also be specified. Using the platform command with the --ruby flag, you can see what ruby directive is specified in the Gemfile.

关于ruby - 即使 gem 安装有效,Bundler 也找不到 gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46858713/

相关文章:

ruby - 我如何在 Heroku 上使用 rdiscount?

ruby - 为什么我的 map /正则表达式 block 的输出没有大写?

ruby - 在 rails 4 中安装 opencv gem 时找不到 Opencv_photo 错误?

rubygems - ruby 中的rc是什么意思?

ruby - RVM Ruby 1.9.1 安装找不到 zlib 但它的运行时和开发库在那里

mysql - 我无法运行 bundler ,不断出现错误

ruby - Sinatra 应用程序未部署到 Heroku,rackup 崩溃

ruby - 使用自定义命名空间解析 Ruby 中的 ATOM

ruby - 我可以根据命令行输入为我的 gem 指定动态依赖项吗?

ruby-on-rails - 如何解决heroku "You are trying to install in deployment mode after changing your Gemfile"错误?