asdf-ruby
asdf-ruby copied to clipboard
Using `brew bundle exec bundle install` fails during post install due to not finding asdf
I've often had success with brew bundle to specify macOS dependencies, and then using brew bundle exec bundle install
to make sure the build env has everything set in there. This is a way to make sure mysql2
gem finds the mysql libraries, for example. Bundle Install With Homebrew Magic Using Brew Bundle Exec does a really good job explaining this pattern.
I've had problems doing this since switching to asdf. I'm including the output from brew bundle exec bundle install
at the bottom of this issue, which is conveniently already formatted for markdown 😁
Some details that might be relevant:
❯ asdf --version
v0.10.2
❯ asdf plugin list --urls | grep ruby
ruby https://github.com/asdf-vm/asdf-ruby.git
❯ asdf plugin list --refs | grep ruby
ruby master a1352b4
The workaround I've found is to run bundle install
without brew bundle exec
to make sure it succeeds.
Backtrace
Errno::ENOENT: No such file or directory - asdf
/Users/josh.nichols/.asdf/plugins/ruby/rubygems-plugin/rubygems_plugin.rb:5:in ``'
/Users/josh.nichols/.asdf/plugins/ruby/rubygems-plugin/rubygems_plugin.rb:5:in `install'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/installer.rb:89:in `block in run'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/process_lock.rb:12:in `block in lock'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/process_lock.rb:9:in `open'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/process_lock.rb:9:in `lock'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/installer.rb:71:in `run'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/installer.rb:23:in `install'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/cli/install.rb:60:in `run'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/cli.rb:253:in `block in install'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/settings.rb:131:in `temporary'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/cli.rb:252:in `install'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/cli.rb:31:in `dispatch'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/cli.rb:25:in `start'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/exe/bundle:49:in `block in <top (required)>'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/bundler-2.2.29/exe/bundle:37:in `<top (required)>'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/bin/bundle:25:in `load'
/Users/josh.nichols/.asdf/installs/ruby/2.7.6/bin/bundle:25:in `<main>'
Environment
Bundler 2.2.29
Platforms ruby, arm64-darwin-21
Ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a25176072e02db9254f0e0c84c805cd) [arm64-darwin21]
Full Path /Users/josh.nichols/.asdf/installs/ruby/2.7.6/bin/ruby
Config Dir /Users/josh.nichols/.asdf/installs/ruby/2.7.6/etc
RubyGems 3.3.19
Gem Home /Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0
Gem Path /Users/josh.nichols/.gem/ruby/2.7.0:/Users/josh.nichols/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0
User Home /Users/josh.nichols
User Path /Users/josh.nichols/.gem/ruby/2.7.0
Bin Dir /Users/josh.nichols/.asdf/installs/ruby/2.7.6/bin
OpenSSL
Compiled OpenSSL 1.1.1n 15 Mar 2022
Loaded OpenSSL 1.1.1n 15 Mar 2022
Cert File /Users/josh.nichols/.asdf/installs/ruby/2.7.6/openssl/ssl/cert.pem
Cert Dir /Users/josh.nichols/.asdf/installs/ruby/2.7.6/openssl/ssl/certs
Tools
Git 2.37.1
RVM not installed
rbenv not installed
chruby not installed
Bundler Build Metadata
Built At 2021-10-08
Git SHA 4440b035ef
Released Version true
Bundler settings
force_ruby_platform
Set for the current user (/Users/josh.nichols/.bundle/config): true
unset
Set for the current user (/Users/josh.nichols/.bundle/config): "jobs"
From brew bundle help
:
brew bundle exec command:
Run an external command in an isolated build environment based on the
Brewfile dependencies.
That would include an isolated env that doesn't have asdf on the path.
I think the simplest fix would be to check that asdf
is on the path before calling it in rubygem_plugin.rb
.
I don't know if there are any hints in the environment when something is brew bundle exec'd
, but that would be another way to skip trying to do it. I ran brew bundle exec env
to get a dump, and while there's tons of HOMEBREW_
variables, I don't see any that suggest it's part of a bundle.