ruby / ruby/rubygems

Parallel bundle install interferes with post-install hooks

Open
#9,386 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bundler
Dominant language
Ruby
Stars
4k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
81

Description

Describe the problem as clearly as you can

When running bundle install --jobs with more than one job, dependencies needed for a post-install hook may be in the middle of being installed and not yet functional.

In the case of JRuby, this situation prevents gems with jar-dependencies post-install hooks from successfully fetching necessary jars.

Did you try upgrading rubygems & bundler?

Confirmed on bundler 4.0.8.

Post steps to reproduce the problem

An example run locally, using parallel bundle install to set up local development dependencies for the ruby/stringio gem:

$ rm -rf Gemfile.lock
$ bundle install --force --jobs 3
Fetching https://github.com/ruby/ruby-core-tasks.git
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Installing rake 13.3.1
Installing erb 6.0.2 (java)
Installing jar-dependencies 0.5.5
Installing date 3.5.1 (java)
Installing power_assert 3.0.1
Installing rake-compiler 1.3.1
Installing tsort 0.2.0
Installing ruby-maven-libs 3.9.9
Installing psych 5.3.1 (java)
  jar dependencies for psych-5.3.1-java.gemspec . . .
Installing test-unit 3.7.7
Installing test-unit-ruby-core 1.0.14
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher

Saving session...
...saving history...truncating history files...
...completed.
--- ERROR REPORT TEMPLATE -------------------------------------------------------

The errors vary from run to run. The ClassNotFoundException above indicates that the command launched for the ruby-maven post-install fetch of snakeyaml could not find a class that should have been included in ruby-maven-libs.

I believe this is caused by the ruby-maven and ruby-maven-libs gems being installed concurrently to the post-install hook. If they are not yet done unpacking, the post-install hook will attempt to use them while they are incomplete, causing random errors.

Specifying no --jobs flag still appears to run in parallel, so I assume it started defaulting to parallel installs at some point.

When run with --jobs 1, it is able to complete successfully every time:

[] stringio $ rm -rf Gemfile.lock            
[] stringio $ bundle install --force --jobs 1
Fetching https://github.com/ruby/ruby-core-tasks.git
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Installing rake 13.3.1
Installing date 3.5.1 (java)
Installing erb 6.0.2 (java)
Installing jar-dependencies 0.5.5
Installing power_assert 3.0.1
Installing psych 5.3.1 (java)
  jar dependencies for psych-5.3.1-java.gemspec . . .
      org.snakeyaml:snakeyaml-engine:2.10:compile
Installing rake-compiler 1.3.1
Installing tsort 0.2.0
Installing rdoc 7.2.0
Installing ruby-maven-libs 3.9.9
Installing ruby-maven 3.9.3
Installing test-unit 3.7.7
Installing test-unit-ruby-core 1.0.14
Bundle complete! 7 Gemfile dependencies, 15 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Post-install message from jar-dependencies:

if you want to use the executable lock_jars then install ruby-maven gem before using lock_jars

  $ gem install ruby-maven -v '~> 3.9'

or add it as a development dependency to your Gemfile

   gem 'ruby-maven', '~> 3.9'
Which command did you run?

bundle install with no --jobs flag or with --jobs greater than 1.

The bug does not happen with --jobs 1 to force serial installation.

What were you expecting to happen?

I believe post-install hooks should be deferred until dependencies have been successfully downloaded and fully unpacked, since attempting to run them before this state may result in partial gems being activated for the hook.

If not included with the output of your command, run bundle env and paste the output below
Bundler       4.0.8
  Platforms   ruby, universal-java
Ruby          4.0.0p0 (2026-03-11 revision 991f63ae1a9fd011f49396cd42f740631a67eacd) [universal-java]
  Full Path   /Users/headius/work/jruby/bin/jruby
  Config Dir  /Users/headius/work/jruby/etc
RubyGems      4.0.3
  Gem Home    /Users/headius/work/jruby/lib/ruby/gems/shared
  Gem Path    /Users/headius/.gem/jruby/4.0.0:/Users/headius/work/jruby/lib/ruby/gems/shared
  User Home   /Users/headius
  User Path   /Users/headius/.gem/jruby/4.0.0
  Bin Dir     /Users/headius/work/jruby/bin
Tools         
  Git         2.39.5 (Apple Git-154)
  RVM         not installed
  rbenv       not installed
  chruby      0.3.9
Gem.ruby      /Users/headius/work/jruby/bin/jruby
bundle #!     /usr/bin/env jruby

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the documented stringio setup using bundle install --jobs 3, then compare it with --jobs 1 and inspect the Bundler installation flow for post-install hooks. Confirm whether hooks can run while dependencies such as ruby-maven and ruby-maven-libs are still being unpacked; done means parallel installation completes reliably without the reported ClassNotFoundException.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.