BUNDLE_GLOBAL_GEM_CACHE breaks natively compiled libraries
Nobody has claimed this yet.
- 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 setting up BUNDLE_GLOBAL_GEM_CACHE=1 it installs the gems correctly. In a CI environment you want to carry that cache over to a next build. When the next CI run happens (which contains only the cache folder from previous execution) the gems "install" correctly but when trying to execute the code it claims the gems with native extensions are missing the compiled extension/library.
You can see an example here:
https://gitlab.com/gitlab-org/gitlab-development-kit/-/jobs/4117614795
LoadError: cannot find 'llhttp-ext' library
/builds/gitlab-org/gitlab-development-kit/gdk/gitlab/vendor/bundle/ruby/3.0.0/gems/ffi-compiler-1.0.1/lib/ffi-compiler/loader.rb:21:in `find'
/builds/gitlab-org/gitlab-development-kit/gdk/gitlab/vendor/bundle/ruby/3.0.0/gems/llhttp-ffi-0.4.0/lib/llhttp.rb:13:in `<module:LLHttp>'
/builds/gitlab-org/gitlab-development-kit/gdk/gitlab/vendor/bundle/ruby/3.0.0/gems/llhttp-ffi-0.4.0/lib/llhttp.rb:6:in `<top (required)>'
<internal:/home/gdk/.asdf/installs/ruby/3.0.5/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/home/gdk/.asdf/installs/ruby/3.0.5/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
Did you try upgrading rubygems & bundler?
Yes, I've tried using latest versions of both:
Bundler version 2.4.12
$ gem --version
3.4.11
Post steps to reproduce the problem
I've tested this locally by setting:
export BUNDLE_GLOBAL_GEM_CACHE=1
export BUNDLE_USER_CACHE=~/.cache/bundle
And doing the following:
- On the original project:
bundle install - Go back to another project with fewer gems:
bundle clean --force - Go back to the original project:
bundle install - Try to run rails console (and get a lot of missing libraries errors, including
pg)
Which command did you run?
bundle installrails console
What were you expecting to happen?
- It should load the code correctly
What actually happened?
- I've got a missing (binary/compiled) library error
If not included with the output of your command, run bundle env and paste the output below
Environment
Bundler 2.4.11
Platforms ruby, arm64-darwin-22
Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf) [arm64-darwin-22]
Full Path /Users/brodock/.rvm/rubies/ruby-3.0.5/bin/ruby
Config Dir /Users/brodock/.rvm/rubies/ruby-3.0.5/etc
RubyGems 3.4.12
Gem Home /Users/brodock/.rvm/gems/ruby-3.0.5
Gem Path /Users/brodock/.rvm/gems/ruby-3.0.5:/Users/brodock/.rvm/rubies/ruby-3.0.5/lib/ruby/gems/3.0.0
User Home /Users/brodock
User Path /Users/brodock/.gem/ruby/3.0.0
Bin Dir /Users/brodock/.rvm/gems/ruby-3.0.5/bin
Tools
Git 2.40.0
RVM 1.29.12-next master
rbenv not installed
chruby not installed
Bundler Build Metadata
Built At 2023-04-10
Git SHA be1d1b4623
Released Version true
Bundler settings
Environment
Bundler 2.4.11
Platforms ruby, arm64-darwin-22
Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf) [arm64-darwin-22]
Full Path /Users/brodock/.rvm/rubies/ruby-3.0.5/bin/ruby
Config Dir /Users/brodock/.rvm/rubies/ruby-3.0.5/etc
RubyGems 3.4.12
Gem Home /Users/brodock/.rvm/gems/ruby-3.0.5
Gem Path /Users/brodock/.rvm/gems/ruby-3.0.5:/Users/brodock/.rvm/rubies/ruby-3.0.5/lib/ruby/gems/3.0.0
User Home /Users/brodock
User Path /Users/brodock/.gem/ruby/3.0.0
Bin Dir /Users/brodock/.rvm/gems/ruby-3.0.5/bin
Tools
Git 2.40.0
RVM 1.29.12-next master
rbenv not installed
chruby not installed
Bundler Build Metadata
Built At 2023-04-10
Git SHA be1d1b4623
Released Version true
Bundler settings
build.ffi
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): "--disable-system-libffi"
build.nokogiri
Set for the current user (/Users/brodock/.bundle/config): "--use-system-libraries"
build.pg
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): "--with-pg-config=/opt/homebrew/bin/pg_config"
Set for the current user (/Users/brodock/.bundle/config): "--with-pg-config=/opt/homebrew/bin/pg_config"
build.pg_query
Set for the current user (/Users/brodock/.bundle/config): "--with-ldflags=-Wl,-undefined,dynamic_lookup"
build.re2
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): "--with-re2-dir=/opt/homebrew/opt/re2"
Set for the current user (/Users/brodock/.bundle/config): "--with-re2-dir=/opt/homebrew/opt/re2"
build.thin
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): "--with-cflags=-Wno-error=implicit-function-declaration"
Set for the current user (/Users/brodock/.bundle/config): "--with-cflags=-Wno-error=implicit-function-declaration"
build.thrift
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): "--with-cppflags=-Wno-error=compound-token-split-by-macro"
Set for the current user (/Users/brodock/.bundle/config): "--with-cppflags=-Wno-error=compound-token-split-by-macro"
cache_all
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): false
gem.changelog
Set for the current user (/Users/brodock/.bundle/config): true
gem.ci
Set for the current user (/Users/brodock/.bundle/config): "gitlab"
gem.coc
Set for the current user (/Users/brodock/.bundle/config): false
gem.mit
Set for the current user (/Users/brodock/.bundle/config): true
gem.rubocop
Set for the current user (/Users/brodock/.bundle/config): "true"
gem.test
Set for the current user (/Users/brodock/.bundle/config): "rspec"
global_gem_cache
Set via BUNDLE_GLOBAL_GEM_CACHE: true
jobs
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): 10
set
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): "without production"
user_cache
Set via BUNDLE_USER_CACHE: "~/.cache/bundle"
without
Set for your local app (/Users/brodock/Projetos/Gitlab/gdk-ee/gitlab/.bundle/config): [:production]
Set for the current user (/Users/brodock/.bundle/config): [:production]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with BUNDLE_GLOBAL_GEM_CACHE=1 using bundle install, bundle clean --force, and rails console, focusing on the llhttp-ffi and pg native-extension errors shown in the report. Trace Bundler's global gem cache handling and add coverage so a cache-only subsequent install loads compiled libraries successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100