plugin version not resolved with ruby pg gem
- Dominant language
- Go
- Stars
- 25.6k
- Forks
- 941
- Avg merge
- 9h 24m
- Merged PRs (30d)
- 3
Description
### Steps to reproduce
1. set up `.tool-versions` with:
```
postgres 9.4.7
ruby 2.6.2
```
2. `asdf install` (successful)
3. `gem install bundler` (successful)
4. `gem install pg`
### Expected behavior
The pg gem should be able to build its native extensions as part of installation.
Its build process relies on `pg_config`, which is shimmed via the `postgres` plugin.
### Actual behavior
```
$ gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Users/mike/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/pg-1.1.4/ext
/Users/mike/.asdf/installs/ruby/2.6.2/bin/ruby -I /Users/mike/.asdf/installs/ruby/2.6.2/lib/ruby/2.6.0 -r ./siteconf20190329-82337-1d85knm.rb extconf.rb
checking for pg_config... yes
Using config values from /Users/mike/.asdf/shims/pg_config
asdf: No version set for command pg_config
you might want to add one of the following in your .tool-versions file:
postgres 9.4.7
asdf: No version set for command pg_config
you might want to add one of the following in your .tool-versions file:
```
### Environment
**OS**: macOS 10.14.3
**asdf version**: `master` @ `5d40982`
### Comments
When executing `pg_config` directly from the command line, through the asdf shim, it resolves to the correct `pg_config` binary and runs successfully. The problem occurs when the `pg_config` shim is invoked in the context of `gem install`.
After adding some debug output to `lib/utils.sh`, I can see that `search_path` is populated from `pwd`, which in this case is: `/Users/mike/.asdf/installs/ruby/2.6.2/lib/ruby/gems/2.6.0/gems/pg-1.1.4/ext`. As a result, [`usable_plugin_versions`](https://github.com/asdf-vm/asdf/blob/5d409821aa8563edab456d8dd256f1ff1e10440e/lib/utils.sh#L649) remains empty.
It seems that `asdf` assumes that `pwd` is going to return the directory in which my `.tool-versions` lives, which does have `postgres 9.4.7` in it.
For now, the way I'm working around this is to set a bundler config to circumvent the use of the `pg_config` shim and use the installed `pg_config` binary directly.
Possibly related: #488
Contributor guide
Research direction
Reproduce the failure with the shown .tool-versions setup and gem install pg, then inspect lib/utils.sh, especially usable_plugin_versions, while comparing direct pg_config execution with invocation from the gem extension directory. Done means the postgres 9.4.7 version is resolved when the pg gem invokes the pg_config shim from its build directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, postgresql, ruby
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100