0
votes

I'm trying to develop an input plugin for logstash.

i've used this tutorial

http://blog.eagerelk.com/how-to-write-a-logstash-plugin/

the problem that i've had when i tried to install "bundle" using "bundle install"

- this is the error message

Your Ruby engine is ruby, but your Gemfile specified jruby

- Gemfile:

source 'https://rubygems.org' ruby '2.2.0', :engine => 'jruby', :engine_version => '2.3.1' gemspec

- ruby -v :

ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin16]

- jruby -v :

jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 +jit [darwin-x86_64]

What am I doing wrong here?

2
Are you using rvm or rbenv in your project? - Lucas Costa
I'm using rbenv - IHEB
And have you created the .ruby-version and .ruby-gemset files appropriately? Looks like your bundler is trying to use the system's default Ruby (instead of the JRuby). - Lucas Costa
how can i verify that? - IHEB
@DavidS. yes, I know. But the concepts behind these files are the same :) - Lucas Costa

2 Answers

1
votes

Since you are using rbenv, here are some good troubleshooting steps:

  • Ensure that your PATH contains /path/to/your/home/directory/.rbenv/shims or some similar variant.
  • You also need eval "$(rbenv init -)" in your shell's .bash|zsh|whateverrc file.
  • If this is all in order, then check the .ruby-version file. Change to the directory of the project you're working on and invoke cat .ruby-version.
    • If not, just make a new file with this name and place an appropriate JRuby version string in it. A good way to check available versions is rbenv install --list, but the latest (from my local ruby-build) is jruby-9.1.7.0
  • Now invoke rbenv install. If you don't wish to make the file / want to skip this step just run rbenv install jruby-9.1.7.0
  • rbenv rehash; bundle should now work.
0
votes

Looks like your bundler is trying to use the system's default Ruby version instead of use the JRuby.

I recommend to you uninstall all previous installations of Ruby to make your system clean again.

After that, make sure your PATH is correct.
If you're using bash, your ~/.bashrc or ~/.bash_profile should have the following commands:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

If you're using zsh, these commands must resides in ~/.zshrc.

After that, enter your project directory and creates a new file .ruby-version:

echo 'jruby-9.1.7.0' > .ruby-version

Note: you can see other versions available using the command rbenv install --list.

Lastly, leaves the directory, enter it again, and run the following commands:

rbenv install jruby-9.1.7.0
gem install bundler # to install the bundler gem in the context of your new JRuby 9.1.7.0
bundle install      # to install the gems listed in your Gemfile