jthegedus / asdf-gcloud

☁️ GCloud CLI (Google Cloud SDK) plugin for asdf version manager. Pin gcloud versions for each project!
https://asdf-vm.com
MIT License
55 stars 22 forks source link

bug: exec-env does not work when invoked via asdf direnv plugin #65

Closed log2 closed 2 years ago

log2 commented 2 years ago

Describe the bug

During environment caching, asdf direnv plugin invokes exec-env on all plugins registered in .tool-versions; unfortunately, exec-env is not called via absolute path, so calling gcloud plugin's exec-env results in:

direnv: loading ~/.asdf/plugins/gcloud/bin/exec-env
./exec-env:10: ./lib/utils.bash: No such file or directory

Since that script internally uses dirname and path used to invoke script is relative to current directory (thus, ./exec-env).

Using realpath around "$current_script_path", if available, should solve this issue.

Steps to reproduce

  1. Have .envrc in place
  2. Add use asdf in .envrc, if missing
  3. Ensure that a version for gcloud is declared in asdf, either via .tool-versions or using asdf shell gcloud
  4. Enter direnv allow

asdf version

v0.10.2

asdf-gcloud version

main f59e332

gcloud version

394.0.0

Additional Information

No response

jthegedus commented 2 years ago

This might be fixed by #63, please check with v1.2.1

log2 commented 2 years ago

Thank you @jthegedus, you are right: the present issue is fixed with that version.

Closing issue.