Hakanai
Hakanai

Reputation: 12680

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

For this Gemfile:

source 'https://rubygems.org'

ruby '2.3.1' # equivalent version to what jruby supports

gem 'jrubyfx'

Bundler can't find the gem, even though 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.

If I let gem itself do the work, it can find it fine:

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

So now I even have it on my system, but despite it even being present locally, Bundler still can't find it.

Environment:

$ 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)

I have verified that both gem and bundler are definitely running with JRuby - they both take forever to start and I only have one JRuby installed at the moment (the latest one the ruby-build from Homebrew had available).

Tried so far:

Upvotes: 3

Views: 1078

Answers (1)

mabe02
mabe02

Reputation: 2734

I had a look at the Gemfile of some github projects using the same gem.

Try to add the engine and engine_version after the ruby version as follows:

# Gemfile

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

gem 'jrubyfx', '~> 1.2'

According to 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.

Upvotes: 2

Related Questions