Skip to content

Error "Library not loaded: /opt/homebrew/opt/re2/lib/libre2.9.dylib"

Overview

An error, after a gdk update:

/Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': dlopen(/Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/re2-1.6.0/lib/re2.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/re2/lib/libre2.9.dylib
  Referenced from: <B7397327-15D6-3B83-8BD1-C58C8E90BB35> /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/re2-1.6.0/lib/re2.bundle
  Reason: tried: '/opt/homebrew/opt/re2/lib/libre2.9.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/re2/lib/libre2.9.dylib' (no such file), '/opt/homebrew/opt/re2/lib/libre2.9.dylib' (no such file), '/usr/local/lib/libre2.9.dylib' (no such file), '/usr/lib/libre2.9.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/re2/20221201/lib/libre2.9.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/re2/20221201/lib/libre2.9.dylib' (no such file), '/opt/homebrew/Cellar/re2/20221201/lib/libre2.9.dylib' (no such file), '/usr/local/lib/libre2.9.dylib' (no such file), '/usr/lib/libre2.9.dylib' (no such file, not in dyld cache) - /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/re2-1.6.0/lib/re2.bundle (LoadError)
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `block in require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:299:in `load_dependency'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/re2-1.6.0/lib/re2.rb:6:in `<main>'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.4.4/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.4.4/lib/bundler/runtime.rb:55:in `each'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.4.4/lib/bundler/runtime.rb:55:in `block in require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.4.4/lib/bundler/runtime.rb:44:in `each'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.4.4/lib/bundler/runtime.rb:44:in `require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.4.4/lib/bundler.rb:195:in `require'
	from /Users/mkozonogitlab/Developer/gdk/gitlab/config/application.rb:15:in `<top (required)>'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/spring-4.1.0/lib/spring/application.rb:92:in `require'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/spring-4.1.0/lib/spring/application.rb:92:in `preload'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/spring-4.1.0/lib/spring/application.rb:166:in `serve'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/spring-4.1.0/lib/spring/application.rb:148:in `block in run'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/spring-4.1.0/lib/spring/application.rb:142:in `loop'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/spring-4.1.0/lib/spring/application.rb:142:in `run'
	from /Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/spring-4.1.0/lib/spring/application/boot.rb:19:in `<top (required)>'
	from <internal:/Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
	from <internal:/Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
	from -e:1:in `<main>'

Impacted categories

The following categories relate to this issue:

Steps to replicate (optional)

gdk update or gdk install

Workaround

  1. gem pristine re2

and then I got a nearly identical error for a different gem: dlopen(/Users/mkozonogitlab/.asdf/installs/ruby/3.0.5/lib/ruby/gems/3.0.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/icu4c/lib/libicudata.71.dyli

  1. gem pristine charlock_holmes

Update 12 July 2023:

See https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/troubleshooting/ruby.md#rebuilding-gems-with-native-extensions:

  1. bundle pristine re2

Proposal (optional)

From a Slack conversation (internal):

FYI I've submitted https://github.com/mudge/re2/pull/64 and https://github.com/Homebrew/homebrew-core/pull/119928 to make it possible to statically link re2

Though it appears Ubuntu doesn't compile its static library with -fPIC, so... we might just need to vendor the re2 library with the gem: https://github.com/mudge/re2/issues/61

Thanks @stanhu 🙏

Environment (optional)

  • Operating system name: <!-- output of `uname -a` command -->
  • Architecture: <!-- output of `arch` command -->
  • The contents of your gdk.yml (if any)
  • Ruby version: <!-- output of `ruby --version` command -->
  • GDK version: <!-- output of `git rev-parse --short HEAD` command -->
Edited by Michael Kozono