asdf-ruby
asdf-ruby copied to clipboard
Invalid variable name
When running any Ruby command, the first line is always:
/Users/ender/.asdf/lib/utils.bash: line 234: ASDF_.._VERSION: invalid variable name
Obviously ASDF_.._VERSION is not a real variable name. I don't even know how this happened.
It did not happen last week.
I'm on asdf version v0.8.1-a1ef92a, both asdf and asdf-ruby are on the latest versions, Ruby is version 3.0.2
This sounds similar to asdf-vm/asdf-nodejs#186? Although the "bad" variable name must be coming from a different place here.
I'm on MacOS, if that makes any difference.
Strange. Thank you for reporting @Kaylebor ! Do you have the command you used to install the plugin? In your situation asdf thinks the plugin name is .. on line 234. It's not clear to me why that is the case.
I installed the plugin a few months ago already, via asdf plugin add ruby and asdf install ruby 3.0.2.
At some point I had some unrelated issue with Ruby, so I might have uninstalled the plugin altogether and reinstalled both the plugin and Ruby with asdf install.
Of note is that I did not include the URL when calling plugin add, but I understand it should use the default then https://github.com/asdf-vm/asdf-ruby.git.
I added a couple of echo <VAR> 1>&2 to check some values (with redirection to stderr because otherwise asdf breaks), and from that function I got these values:
plugin_name = ..
upcase_name = ..
version_env_var = ASDF_.._VERSION
Full pry output when adding these echos:
➜ ~ pry
plugin_name = ..
upcase_name = ..
version_env_var = ASDF_.._VERSION
/Users/ender/.asdf/lib/utils.bash: line 237: ASDF_.._VERSION: invalid variable name
plugin_name = ruby
upcase_name = RUBY
version_env_var = ASDF_RUBY_VERSION
[1] pry(main)> quit
plugin_name = java
upcase_name = JAVA
version_env_var = ASDF_JAVA_VERSION
It's weird that Java is getting called here too... maybe there's some weird interaction between both plugins? Those three Java lines appear now every single time I run anything on the terminal, even empty lines.
It might even be that the Ruby plugin is working correctly, but something they did on the halcyon/asdf-java plugin is causing this message to appear.
Luckily it seems to correctly get the Ruby values after, so I can actually keep working like this until this issue is fixed.
UPDATE: removing source ~/.asdf/plugins/java/set-java-home.zsh from .zshrc made the JAVA messages disappear, but the Ruby error prevails. So while not ideal, it's not related.
I found that this comes all the way from line 693, which takes plugin_name from a list obtained from line 686:
IFS=$'\n' read -rd '' -a plugins <<<"$(shim_plugins "$shim_name")"
When running for Ruby, the contents of the list are .. ruby
I added another echo, and shim_name has a value of pry (which is the Ruby gem I'm running, not Ruby itself)
This comes from with_shim_executable, from $1.
Thoughts?
Can you post the output of asdf info for your system? Thanks for all the details, it does appear this a bug that may have been introduced recently.
Can you post the output of
asdf infofor your system? Thanks for all the details, it does appear this a bug that may have been introduced recently.
Sure, here:
OS:
Darwin Enders-MacBook-Pro.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
SHELL:
zsh 5.8 (x86_64-apple-darwin21.0)
ASDF VERSION:
v0.8.1-a1ef92a
ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/Users/ender/.asdf
ASDF INSTALLED PLUGINS:
elixir https://github.com/asdf-vm/asdf-elixir.git
erlang https://github.com/asdf-vm/asdf-erlang.git
java https://github.com/halcyon/asdf-java.git
nodejs https://github.com/asdf-vm/asdf-nodejs.git
python https://github.com/danhper/asdf-python.git
rebar https://github.com/Stratus3D/asdf-rebar.git
ruby https://github.com/asdf-vm/asdf-ruby.git
yarn https://github.com/twuni/asdf-yarn.git
Huh, you are using the version that everyone else is. I was thinking that perhaps we'd introduced a bug since v0.8.1, but you are on v0.8.1. What do you see if you run ls /Users/ender/.asdf/plugins/? It's as if there is a directory named .. literally somewhere.
Also, what do you see when you run type -a ruby or type -a irb? Did you try running asdf reshim?
ls gives me the directories corresponding to the plugins:
elixir erlang java nodejs python rebar ruby yarn
For type -a:
➜ ~ type -a ruby
ruby is /Users/ender/.asdf/shims/ruby
ruby is /usr/bin/ruby /0.0s
➜ ~ type -a irb
irb is /Users/ender/.asdf/shims/irb
irb is /usr/bin/irb
which ruby tells me that I'm using /Users/ender/.asdf/shims/ruby; similar for irb
I tried now asdf reshim, which completes without error nor message; running pry or irb continues giving the same warning.
It's a weird error 🙁
So I believe this issue may be related (and may share the same root bug) https://github.com/asdf-vm/asdf/issues/1029
What happens if you run asdf shim-versions ruby or asdf shim-versions irb?
Yeah, that looks similar to my issue.
Here are the commands you asked for:
➜ ~ asdf shim-versions ruby
.. 14.15.5
ruby 3.0.2 /0.1s
➜ ~ asdf shim-versions irb
.. 14.15.5
ruby 3.0.2
Then it's an issue with asdf core?
I'll link this issue to them, see if I can help fix it.
@Kaylebor that's really strange, 14.15.5 isn't a Ruby version since that Ruby doesn't exist yet. That value looks like a node.js version (version 14.15.5 is a valid node.js version). I think you may well have run into the same issue as https://github.com/asdf-vm/asdf-nodejs/issues/186, it just may be manifesting in a different way since you are using Ruby.
Try uninstalling the nodejs plugin and see if that gets around the issue. You will have to reshim afterwards most likely.
Weirdly, that nodejs version is installed (we use it in one of our repos), so you're right in saying it's not random.
I tried removing the nodejs plugin and running asdf reshim, but the warning persists.
The issue may be coming from the shim function: I cated pry, and got this code:
#!/usr/bin/env bash
# asdf-plugin: .. 14.15.5
# asdf-plugin: ruby 3.0.2
exec /Users/ender/.asdf/bin/asdf exec "pry" "$@"
Since the shim_plugin_versions uses those comments to get the plugin names, our issue starts there. On line 606 in lib/utils.bash:
grep "# asdf-plugin: " "$shim_path" 2>/dev/null | sed -e "s/# asdf-plugin: //" | uniq
@augustobmoura came to the same conclusion on asdf-vm/asdf#1029. As he said, manually deleting all shims and calling reshim after fixed it.
Is this still an issue @Kaylebor ? We've recently released a new version of asdf. Can you try upgrading to see if this issue is still around? Thanks!
I can't easily reproduce this, since I didn't know how the shim metadata became corrupted in the first place. It didn't happen again since I fixed it manually either.
I manually broke the metadata on the shim to try, in which case the issue persists (and can't be fixed without manually editing or deleting the shims); but that is only a problem if the metadata gets corrupted.
We could close this issue for now, and reopen it in the future if the problem reappears, since we can't reproduce it.
I'm going to close this for now as I am not encounter it either. But if it comes up again for anyone leave a comment and I will re-open this issue.