`bundle exec` option not used


I have a project I'm using Sidekiq with and my gem command run configuration has the box checked in the run dialog to execute the command in the context of the bundle, but this does not happen.  See this output:

bash -c ". /usr/local/share/chruby/chruby.sh && chruby ruby-2.5.1 && /home/rpc/.rubies/ruby-2.5.1/bin/ruby /home/rpc/.gem/ruby/2.5.1/bin/sidekiq"
WARN: Unresolved specs during Gem::Specification.reset:
      minitest (~> 5.1)
      rack-test (>= 0.6.3)
      nokogiri (>= 1.6)
      builder (~> 3.1)
      loofah (>= 2.2.2, ~> 2.2)
      rake (>= 0.8.7)
      thor (< 2.0, >= 0.19.0)
      method_source (>= 0)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Traceback (most recent call last):
    21: from /home/rpc/.gem/ruby/2.5.1/bin/sidekiq:23:in `<main>'
    20: from /home/rpc/.gem/ruby/2.5.1/bin/sidekiq:23:in `load'
    19: from /home/rpc/.gem/ruby/2.5.1/gems/sidekiq-5.2.1/bin/sidekiq:12:in `<top (required)>'
    18: from /home/rpc/.gem/ruby/2.5.1/gems/sidekiq-5.2.1/lib/sidekiq/cli.rb:53:in `run'
    17: from /home/rpc/.gem/ruby/2.5.1/gems/sidekiq-5.2.1/lib/sidekiq/cli.rb:278:in `boot_system'
    16: from /home/rpc/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:122:in `require'
    15: from /home/rpc/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:122:in `require'
    14: from /home/rpc/Projects/Rails/think_tsi/config/environment.rb:2:in `<top (required)>'
    13: from /home/rpc/Projects/Rails/think_tsi/config/environment.rb:2:in `require_relative'
    12: from /home/rpc/Projects/Rails/think_tsi/config/application.rb:1:in `<top (required)>'
    11: from /home/rpc/Projects/Rails/think_tsi/config/application.rb:1:in `require_relative'
    10: from /home/rpc/Projects/Rails/think_tsi/config/boot.rb:3:in `<top (required)>'
     9: from /home/rpc/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:122:in `require'
     8: from /home/rpc/.rubies/ruby-2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:122:in `require'
     7: from /home/rpc/.gem/ruby/2.5.1/gems/bundler-1.16.5/lib/bundler/setup.rb:10:in `<top (required)>'
     6: from /home/rpc/.gem/ruby/2.5.1/gems/bundler-1.16.5/lib/bundler.rb:107:in `setup'
     5: from /home/rpc/.gem/ruby/2.5.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:26:in `setup'
     4: from /home/rpc/.gem/ruby/2.5.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:26:in `map'
     3: from /home/rpc/.rubies/ruby-2.5.1/lib/ruby/2.5.0/forwardable.rb:229:in `each'
     2: from /home/rpc/.rubies/ruby-2.5.1/lib/ruby/2.5.0/forwardable.rb:229:in `each'
     1: from /home/rpc/.gem/ruby/2.5.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:31:in `block in setup'
/home/rpc/.gem/ruby/2.5.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:313:in `check_for_activated_spec!': You have already activated activesupport, but your Gemfile requires activesupport 5.2.1. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

Process finished with exit code 1

I can run this in a console with `bundle exec sidekiq` and it runs as expected.


RubyMine 2018.2.4
Build #RM-182.4505.55, built on October 8, 2018
Licensed to <name>
Subscription is active until <active date>
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-42-generic



Hello Robert,

could you please check how it goes in RubyMine 2018.3.1 EAP?


I'm having exactly the same problem. None of my run commands are getting run with bundler. I'm on 2019.2.4


Filip Kis, could you please provide more details about the problem you have?


Olga Kuvardina I noticed the same issue --

Checking the `Run script in the context of bundle` is not changing the run parameters.


I am using:

IntelliJ IDEA 2019.3 (Ultimate Edition)
Build #IU-193.5233.102, built on November 27, 2019
Licensed to Looker / Farid Zakaria
Subscription is active until November 5, 2020
Runtime version: 11.0.4+10-b520.11 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.6
GC: ParNew, ConcurrentMarkSweep
Memory: 4012M
Cores: 12
Registry: debugger.watches.in.variables=false
Non-Bundled Plugins: org.jetbrains.kotlin, org.jetbrains.plugins.slim, org.jetbrains.plugins.ruby


Farid, could you please check whether the option 'ruby.force.explicit.bundle.exec' is checked or not in Help - Find Action - Experimental Features?


Hi Olga, 

I had the option checked and tried also unchecking it, but my commands just never include `bundle exec` in their run parameters. 


Hi Olga Kuvardina


Having the same problem with Intellij 2020.1.1.  In my case I am trying to run minitest and the command never adds bundle exec even though the option is selected.  I also checked and 'ruby.force.explicit.bundle.exec' is checked in experimental features. 


Same issue on 2020.1.1 (it started with 2020.1 - previous versions worked fine). I'm using rbenv, if that provides any clues. The tests were never executed in the context of the bundle, even though the test configuration indicated they should be, and `ruby.force.explicit.bundle.exec` was enabled.

I was able to fix it by uninstalling my rbenv ruby and reinstalling. However, I'm not 100% sure that was the culprit, as I tried a few other things at the same time, such as uninstalling all of my system gems, performing a `gem update --system`, and invalidating my RubyMine caches.

Hope this helps someone - sorry I couldn't narrow it down further!


`gem update --system` resolved this for one of my team members, I would start there.


Olga Kuvardina, perhaps RubyMine could detect older rubygems versions and prompt the user to update?


I ran into this on 2020.2.1 after an update from 2019.2.4. Also a rbenv user.

`gem update --system` didn't work.

What did work was running the "bundler" action.

I got prompted about a Gemfile needing a non-existing version of bundler(weird, because it existed when I was on 2019.2.4). Anyways, I installed the recommended version, and suddenly things started working again.


Thanks, Gmcmonty . It was helpful.

 I just ran a bundler action `bundle install`. And after that, it started working fine.


Sort of an old issue, but I ran into the same problem whilst adding a gem configuration in RubyMine 2021.1.2 on MacOS Big Sur 11.4. As RubyMine refused to execute under the context of bundler, I just re-structured my gem configuration to directly execute bundler itself, and then followed it by the exec argument plus my gem. A quick workaround, although the issue should be fixed on RubyMine's end.



BGM, could you please specify which Run configuration's and project's type you've faced bundle exec issue in?


Olga Kuvardina, I have only tried Gem Command so far, as shown in the image above, which I use to run Jekyll's serve command for both development and production environments. Let me know if you would want me to test if the issue persists in any other Run configuration and I'll gladly test it out!


BGM, could you please check how it goes in case you enable 'ruby.force.explicit.bundle.exec' in Help - Find Action - Experimental Features? Does the command being run differ? If you don't add `exec` as the argument and enable instead the corresponding setting on the Bundler tab?


Olga Kuvardina, the command does not differ after enabling 'ruby.force.explicit.bundle.exec' alone, nor when enabling that plus check-marking the under-context run at the Bunlder tab. If you would like me to, I can provide the command that does the trick with "bundler" as both the gem and gem executable, and "exec" as the argument, and also the command ran when bundler isn't used at all even after check-marking the option.


BGM yes, if possible please provide the output from the Run console in both cases. Does the same happen for plain Ruby scripts (I mean bundle exec option isn't used even when the explicit option is enabled)?


I've had this issue repeatedly with numerous versions. For me it seems to occur if the version of bundler I'm using is different to that in my gemfile.lock. 

It seems to fix up for me if I:

  1. Make sure my bundler version matches that in the `BUNDLED WITH` of the gemfile.lock
  2. Then do a `bundle install` from within rubymine, which seems to kind of 'relink' it with bundler.

Gmcmonty Thanks!  Running bundler action `bundle install` fixed this for me too!


Same here. The issue popped up when the "BUNDLED WITH" version was updated in Gemfile.lock. Updating bundler (gem install bundler -v <whatever>) and then running `bundle install` from within Rubymine fixed the issue. 


For me, I need to have my Rubymine to settled its `bundle` process and also its indexing process and after that it started to works again.


I had the same issue here, unfortunately none of the proposed solution worked for me.

I'm on a Mac OS 13.2.1 and I'm using Intellij Idea 2023.3.3 Ultimate with the Ruby plugin, but I guess it works the same as Rubymine.
I also use rbenv to manage the ruby version on my machine.


What worked for me was manually executing “bundle exec” in the “Ruby arguments:” section of my Run/Debug Configuration.

First I got the path of the bundle command with 

rbenv which bundle

that returns “/Users/eparlato/.rbenv/versions/3.1.2/bin/bundle” on my machine. 

I simply put this line together with the exec command as a Ruby argument in my Run/Debug configuration

/Users/eparlato/.rbenv/versions/3.1.2/bin/bundle exec

This solved me the issue.


I then created a Run/Debug Configuration Template for RSPec with this trick. This way, any RSpec that I launch from the IDE (a single test, a file, a whole directory) has the above line in the “Ruby arguments:” section.

I hope it helps.


eparlato in case you face the issue with non working bundle exec, it'd be great if you could submit a bug report directly on our tracker providing also the idea.log (Help - Show log in) and the full output from the Run console when the issue is present.