3

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:

  • Changing sources from https to http
  • Changing the URL to include the leading api.
  • Adding --full-index to the bundle command-line as suggested in an answer to this question
  • this question looked similar too, but was just a missing comma
Hakanai
  • 12,010
  • 10
  • 62
  • 132

1 Answers1

2

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.

mabe02
  • 2,676
  • 2
  • 20
  • 35
  • After changing the engine, the gem is now found. Here's the puzzle - if I revert the change and try to `bundle install` again, it works, even if I have removed `Gemfile.lock`. So I guess once the gem is installed _via bundler_ it somehow works for future builds, even though installing it _via gem_ didn't make a difference. – Hakanai Oct 25 '17 at 03:32
  • jrubyfx developer here. I'm somewhat surprised that it works once you do get it. However, I know we had the jrubyfx packaging explicitly state compatibility with jruby and not standard MRI (hence you see the `-java` at the end of the version), so I would maybe suggest that you ensure you weren't using the bundler under MRI by accident beforehand? I know I occasionally do that myself when I forget to `rvm use jruby`. Either way, glad you got it working! – byteit101 Nov 15 '17 at 21:16