对于这个 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 projects 的 Gemfile
使用相同的 gem。
尝试在ruby版本后面加上engine
和engine_version
如下:
# Gemfile
ruby '2.3.1', engine: 'jruby', engine_version: '9.1.8.0'
source 'https://rubygems.org'
gem 'jrubyfx', '~> 1.2'
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/