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

Bundler can't find a gem even though gem install works

对于这个 Gemfile:

source 'https://rubygems.org'

ruby '2.3.1' # equivalent version to what jruby supports

gem 'jrubyfx'

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

$ 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(最新的 ruby-从 Homebrew 构建可用)。

到目前为止尝试过:

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

尝试在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.