Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: lib/utils.bash: line 234: ASDF_.._VERSION: invalid variable name #1029

Closed
jc00ke opened this issue Aug 26, 2021 · 26 comments
Closed

bug: lib/utils.bash: line 234: ASDF_.._VERSION: invalid variable name #1029

jc00ke opened this issue Aug 26, 2021 · 26 comments
Labels

Comments

@jc00ke
Copy link

jc00ke commented Aug 26, 2021

Describe the Bug

When I run neovim latest asdf reports an invalid variable name.

Steps to Reproduce

~
➜ nvim
/home/jesse/.asdf/lib/utils.bash: line 234: ASDF_.._VERSION: invalid variable name

Expected Behaviour

Neovim would start with no error notice in the terminal.

Actual Behaviour

I see this error message:

/home/jesse/.asdf/lib/utils.bash: line 234: ASDF_.._VERSION: invalid variable name

Environment

OS:
Linux jimmie 5.11.0-31-generic #33-Ubuntu SMP Wed Aug 11 13:19:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
fish, version 3.1.2

ASDF VERSION:
v0.8.1-a1ef92a

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/jesse/.asdf

ASDF INSTALLED PLUGINS:
deno                         https://github.com/asdf-community/asdf-deno.git
dotnet-core                  https://github.com/emersonsoares/asdf-dotnet-core.git
elixir                       https://github.com/asdf-vm/asdf-elixir.git
elm                          https://github.com/asdf-community/asdf-elm.git
erlang                       https://github.com/asdf-vm/asdf-erlang.git
haskell                      https://github.com/vic/asdf-haskell.git
lua                          https://github.com/Stratus3D/asdf-lua.git
neovim                       https://github.com/richin13/asdf-neovim.git
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git
postgres                     https://github.com/smashedtoatoms/asdf-postgres.git
python                       https://github.com/danhper/asdf-python.git
redis                        https://github.com/smashedtoatoms/asdf-redis.git
ruby                         https://github.com/asdf-vm/asdf-ruby.git
rust                         https://github.com/code-lever/asdf-rust.git
shfmt                        https://github.com/luizm/asdf-shfmt.git
yq                           https://github.com/sudermanjr/asdf-yq.git


### asdf plugins affected (if relevant)

It might be one of the later plugins I have installed. Plugins that might be affecting it:

* dotnet-core
* haskell
* neovim (naturally)
@jc00ke jc00ke added the bug label Aug 26, 2021
@jc00ke
Copy link
Author

jc00ke commented Aug 26, 2021

I noticed @lifeiscontent is having a similar issue in #693 (comment)

@jthegedus
Copy link
Contributor

Is this a fish issue or a neovim issue? Is it reproducible without neovim?

@Stratus3D
Copy link
Member

I'm fairly certain this is the same as #693. Some plugin(s) names aren't properly handled and it results in this invalid variable name.

@jc00ke
Copy link
Author

jc00ke commented Aug 26, 2021

Is this a fish issue or a neovim issue? Is it reproducible without neovim?

It's new that I see it, and I've used fish for years. I have yet to be able to reproduce it with any other command.

➜ asdf shim-versions nvim
.. 14.0.0
neovim nightly
neovim 0.5.0
~
➜ bat .tool-versions

       │ File: .tool-versions

   1   │ deno 1.12.2
   2   │ elixir 1.12.1-otp-24
   3   │ elm 0.19.1
   4   │ erlang 24.0.2
   5   │ golang 1.15.2
   6   │ lua 5.4.2
   7   │ neovim nightly
   8   │ nodejs 16.1.0
   9   │ postgres 11.4
  10   │ python 3.9.1
  11   │ redis 6.2.3
  12   │ ruby 3.0.1
  13   │ rust 1.54.0
  14   │ ripgrep 13.0.0
  15   │ bat 0.18.1
  16   │ direnv 2.28.0
  17   │ starship 0.55.0
  18   │ zoxide 0.7.2
  19   │ fd 8.2.1
  20   │ exa 0.10.1
  21   │ duf 0.6.2
  22   │ delta 0.8.2
  23   │ shfmt 3.3.0
  24   │ yq v4.11.2
  25   │ haskell 9.0.1

Hmm, what's with that .. 14.0.0? I see that when I look at shims for other plugins like Ruby and Elixir.

@Kaylebor
Copy link

I'm having the same issue, linked here asdf-vm/asdf-ruby#236

In my case it happens with Ruby instead, but other than that the symptoms are similar.

@augustobmoura
Copy link
Member

augustobmoura commented Nov 25, 2021

The problem (at least on my side) is that running asdf reshim sometimes (god knows why) adds a ghost plugin candidate .. to the shim file, and because how the reshim script works, it's never removed.

Print from my npm shim file for example:

image

See those asdf-plugin: .., those are the ones that are causing the issue.

The workaround for me is deleting the shim script and then reshimming:

rm "$ASDF_DIR/shims/npm" 
asdf reshim node

You might as well delete all others shims and reshim them all over again:

rm "$ASDF_DIR"/shims/*
asdf reshim

I don't know if this issue exists because I kept messing with symlinks in the plugins dir, or because some bug in the past created them.

I think the solution should be cleaning these ghost plugins after reshims, or making a specific command for pruning/cleaning the shims directory

@Stratus3D
Copy link
Member

@augustobmoura thanks for the comment. It appears we've got a bug somewhere in our reshim logic as I just encountered issue myself (and I'm not using any symlinks). It does appear .. is getting added somehow. Perhaps from the output of ls or a similar command.

@Stratus3D Stratus3D added this to the v0.9.1 milestone Dec 1, 2021
@augustobmoura
Copy link
Member

I tried to debug it, but the problem is that it is not consistent. I tried manually reshimming it sometimes but never got it to write .. to any shim

@jc00ke
Copy link
Author

jc00ke commented Dec 14, 2021

Does someone want to debug with me on my machine? It still does it.

@sheldonhull
Copy link

This popped up for me and I have no idea what is causing it.

⚙️ direnv global defaults: [bash]                                                                                                                                                      
direnv: ([/Users/USERNAME/.asdf/installs/direnv/2.30.3/bin/direnv export zsh]) is taking a while to execute. Use CTRL-C to give up.
/Users/USERNAME/.asdf/lib/utils.bash:234: ASDF_.DS_STORE_VERSION: invalid variable name

@bbenzikry
Copy link

This popped up for me and I have no idea what is causing it.

⚙️ direnv global defaults: [bash]                                                                                                                                                      
direnv: ([/Users/USERNAME/.asdf/installs/direnv/2.30.3/bin/direnv export zsh]) is taking a while to execute. Use CTRL-C to give up.
/Users/USERNAME/.asdf/lib/utils.bash:234: ASDF_.DS_STORE_VERSION: invalid variable name

For me

rm $ASDF_DATA_DIR/plugins/.DS_Store

seemed to do the trick

@lifeiscontent
Copy link

lifeiscontent commented May 2, 2022

@Stratus3D any ideas on why a .DS_Store file would interfere with something like this?

@Stratus3D
Copy link
Member

Thanks for the comments @sheldonhull and @bbenzikry ! I now understand what the problem is - in your case, somewhere in the code we are looping over all files in $ASDF_DIR/plugins/ and assuming that each value is a plugin directory, but of course this is not necessarily true because a .DS_Store or any other type of file could end up in the $ASDF_DIR/plugins/ directory. The proper fix is to only use the directories present in $ASDF_DIR/plugins/. I'm going to try and fix this this week.

@Kaylebor
Copy link

Kaylebor commented May 3, 2022

@Stratus3D I had tried to fix that in December, but my approach was to clean up after :S

It worked for me, but I understand that didn't really fix the problem

Maybe some parts of my approach can be of use though, as I did use the plugins folder as reference of what would be valid metadata.

@Stratus3D
Copy link
Member

@sheldonhull can you share the output of asdf info? Also, do you recall any commands you ran leading up to this issue? I'm trying to replicate this locally and even with the .DS_Store file created I'm failing to replicate this.

@xeger
Copy link

xeger commented May 6, 2022

I'm encountering this too, but weirdly, only in CI, while invoking asdf inside a Docker image that I have previously built. Tt does not reproduce locally for me. I pasted some things you've asked others for, but I don't think the issue involves stray files under ~/.asdf/plugins in my case.

My findings: cannot identify shim as executable

I narrowed it down to shim_plugin_versions and specifically to this conditional:

  if [ -x "$shim_path" ]; then                           
    grep "# asdf-plugin: " "$shim_path" 2>/dev/null | sed -e "s/# asdf-plugin: //" | uniq
  else                    
    printf "asdf: unknown shim %s\\n" "$executable_name"
    return 1                                    
  fi                                  

shim_path is /var/www/.asdf/shims/bundle in this case, and in fact I can reproduce the test from the bash CLI:

bash-5.1$ if [ -x /var/www/.asdf/shims/bundle ]; then echo "is executable"; else echo "is not executable"; fi
is not executable

However, it looks executable to me! I don't understand why the -x test is failing; I tried adding a proper space to the shebang line (#! /usr/bin/env bash) as well as just directly invoking bash (#! /bin/bash).

Obviously I can invoke this shim (it's how we get into the error condition in the first place!) but something makes bash 5 think it's not executable.

-rwxr-xr-x    1 www-data www-data       121 May  6 20:09 /var/www/.asdf/shims/bundle

Marginally useful troubleshooting info

bash-5.1$ ls -la ~/.asdf/plugins
total 12
drwxr-sr-x    1 www-data www-data      4096 May  4 23:18 .
drwxr-sr-x    1 www-data www-data      4096 May  4 23:28 ..
drwxr-sr-x    1 www-data www-data      4096 May  4 23:18 ruby
bash-5.1$ asdf info
OS:
Linux 829230640ef8 5.4.0-1021-gcp #21-Ubuntu SMP Fri Jul 10 06:53:47 UTC 2020 x86_64 Linux

SHELL:
This account is not available

ASDF VERSION:
v0.10.0-77fd510

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/var/www/.asdf

ASDF INSTALLED PLUGINS:
ruby                         https://github.com/asdf-vm/asdf-ruby.git master 95bb530

@xeger
Copy link

xeger commented May 9, 2022

Update: asdf-vm is not the root cause for my case; it's actually a container virtualization bug in Alpine Linux 3.14 and has nothing to do with extra/missing files under ~/.asdf. Upgrading to a newer Docker version, which contains a newer runc, fixed the issue in my case.

It does seem like ASDF has some circular error case, where a stub that is non executable causes bizarre error messages (because asdf is parsing its own error output to determine something about the shim). Not a big issue though, as long as one's shims are all proper.

@Stratus3D
Copy link
Member

@xeger thanks for the info.

@sheldonhull ping.

I've got a fix that I think will address the .DS_Store issue, unsure if it will address the root cause of this ticket - #1228. Can anyone on this issue check out that fix and see if it addresses the issue? It won't fix bad shims, but it should prevent bad shims from being generated.

Stratus3D added a commit to Stratus3D/asdf that referenced this issue May 11, 2022
Stratus3D added a commit to Stratus3D/asdf that referenced this issue May 11, 2022
Stratus3D added a commit to Stratus3D/asdf that referenced this issue May 11, 2022
@Stratus3D
Copy link
Member

I've merged a possible fix for this so if you want to test it run asdf update --head.

@Stratus3D
Copy link
Member

Closing as I've not gotten any responses on whether this issue still exists with the latest version. I will reopen if not resolved.

@glasser
Copy link

glasser commented Aug 24, 2022

As a note, I'm getting this right now with asdf as installed from Homebrew at 0.10.2:

glasser@dsg-mbp 0 11:28:53 ~/Projects/Apollo/router bryn/ftv1 u= p= $ cat .envrc
use asdf
glasser@dsg-mbp 0 11:28:53 ~/Projects/Apollo/router bryn/ftv1 u= p= $ direnv reload
direnv: loading ~/Projects/Apollo/router/.envrc
direnv: using asdf
direnv: Creating env file /Users/glasser/.cache/asdf-direnv/env/45930459-3520607073-3344263149-1660765782
/usr/local/Cellar/asdf/0.10.2/libexec/lib/utils.bash:242: ASDF_.DS_STORE_VERSION: invalid variable name
direnv: loading ~/.cache/asdf-direnv/env/45930459-3520607073-3344263149-1660765782
direnv: using asdf nodejs 16.9.1
direnv: loading ~/.asdf/plugins/nodejs/bin/exec-env
direnv: using asdf rust 1.61.0
direnv: loading ~/.asdf/plugins/rust/bin/exec-env
direnv: export +CARGO_HOME +NPM_CONFIG_PREFIX +RUSTUP_HOME ~PATH

The error goes away if I rm ~/.asdf/plugins/.DS_Store

@Stratus3D
Copy link
Member

@glasser please share the output of asdf info.

@glasser
Copy link

glasser commented Aug 24, 2022

 $ asdf info
OS:
Darwin dsg-mbp 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64 x86_64

SHELL:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.

ASDF VERSION:
v0.10.2

ASDF ENVIRONMENT VARIABLES:


ASDF INSTALLED PLUGINS:
direnv                       https://github.com/asdf-community/asdf-direnv.git master 5ad45d0
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master b2d06a7
rust                         https://github.com/code-lever/asdf-rust.git master 0c88f99

Note that this is after I have deleted the DS_Store file and stopped the error.

@Stratus3D
Copy link
Member

@glasser what happens if you run asdf reshim? If that doesn't work could you share the contents of ~/.asdf/shims/direnv?

@glasser
Copy link

glasser commented Aug 25, 2022

I'll let you know if it crops up again — I don't know how to induce OSX into creating a .DS_Store file.

@glasser
Copy link

glasser commented Aug 25, 2022

Ah actually, just opening ~/.adsf/plugins in Finder seems to do it.

glasser@dsg-mbp 0 11:54:24 ~/Projects/Apollo/router main u-11 p-11 $ direnv reload
direnv: loading ~/Projects/Apollo/router/.envrc
direnv: using asdf
direnv: Creating env file /Users/glasser/.cache/asdf-direnv/env/45930459-3520607073-1811527558-1660765782
/usr/local/Cellar/asdf/0.10.2/libexec/lib/utils.bash:242: ASDF_.DS_STORE_VERSION: invalid variable name
direnv: loading ~/.cache/asdf-direnv/env/45930459-3520607073-1811527558-1660765782
direnv: using asdf nodejs 16.9.1
direnv: loading ~/.asdf/plugins/nodejs/bin/exec-env
direnv: using asdf rust 1.61.0
direnv: loading ~/.asdf/plugins/rust/bin/exec-env
direnv: export +CARGO_HOME +NPM_CONFIG_PREFIX +RUSTUP_HOME ~PATH
glasser@dsg-mbp 0 11:54:28 ~/Projects/Apollo/router main u-11 p-11 $ asdf info
OS:
Darwin dsg-mbp 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64 x86_64

SHELL:
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.

ASDF VERSION:
v0.10.2

ASDF ENVIRONMENT VARIABLES:


ASDF INSTALLED PLUGINS:
direnv                       https://github.com/asdf-community/asdf-direnv.git master 5ad45d0
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master b2d06a7
rust                         https://github.com/code-lever/asdf-rust.git master 0c88f99

glasser@dsg-mbp 0 11:54:34 ~/Projects/Apollo/router main u-11 p-11 $ asdf reshim
glasser@dsg-mbp 0 11:54:40 ~/Projects/Apollo/router main u-11 p-11 $ direnv reload
direnv: loading ~/Projects/Apollo/router/.envrc
direnv: using asdf
direnv: Creating env file /Users/glasser/.cache/asdf-direnv/env/45930459-3520607073-3907766587-1660765782
/usr/local/Cellar/asdf/0.10.2/libexec/lib/utils.bash:242: ASDF_.DS_STORE_VERSION: invalid variable name
direnv: loading ~/.cache/asdf-direnv/env/45930459-3520607073-3907766587-1660765782
direnv: using asdf nodejs 16.9.1
direnv: loading ~/.asdf/plugins/nodejs/bin/exec-env
direnv: using asdf rust 1.61.0
direnv: loading ~/.asdf/plugins/rust/bin/exec-env
direnv: export +CARGO_HOME +NPM_CONFIG_PREFIX +RUSTUP_HOME ~PATH
glasser@dsg-mbp 0 11:54:47 ~/Projects/Apollo/router main u-11 p-11 $ cat ~/.asdf/shims/direnv 
#!/usr/bin/env bash
# asdf-plugin: direnv 2.31.0
exec /usr/local/opt/asdf/libexec/bin/asdf exec "direnv" "$@"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants