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: run asdf local <name> <version> in a directory without .tool-versions, see error messages #1417

Closed
h3y6e opened this issue Jan 5, 2023 · 3 comments · Fixed by #1418 or #1386
Closed
Labels

Comments

@h3y6e
Copy link

h3y6e commented Jan 5, 2023

Describe the Bug

If asdf local <name> <version> is run with no .tool-versions in the current directory, then the following error message is printed.

tail: <$PWD>/.tool-versions: No such file or directory

This is not a fatal bug because a .tool-versions file is generated.

Steps to Reproduce

  1. Go to the directory where a .tool-versions file does not exist.
  2. Run asdf local <name> <version>.
  3. See error message.

Expected Behaviour

tail: <$PWD>/.tool-versions: No such file or directory is not displayed and a .tool-versions file is created.

Actual Behaviour

tail: <$PWD>/.tool-versions: No such file or directory is displayed. (a .tool-versions file is created.)

Environment

OS:
Darwin mbp2019 21.6.0 Darwin Kernel Version 21.6.0: Sun Nov  6 23:31:16 PST 2022; root:xnu-8020.240.14~1/RELEASE_X86_64 x86_64

SHELL:
zsh 5.8.1 (x86_64-apple-darwin21.0)

ASDF VERSION:
v0.11.0

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/usr/local/opt/asdf/libexec

ASDF INSTALLED PLUGINS:
elixir                       https://github.com/asdf-vm/asdf-elixir.git master 1693b35
erlang                       https://github.com/asdf-vm/asdf-erlang.git master 0d402e6
flutter                      https://github.com/oae/asdf-flutter.git master d108efd
julia                        https://github.com/rkyleg/asdf-julia.git master 1788f0f
kubectl                      https://github.com/asdf-community/asdf-kubectl.git master 3d00592
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master c9e5df4
php                          https://github.com/asdf-community/asdf-php.git master 306793c
python                       https://github.com/danhper/asdf-python.git master 8505457
ruby                         https://github.com/asdf-vm/asdf-ruby.git master 4eb815c
rust                         https://github.com/code-lever/asdf-rust.git master 0c88f99
terraform                    https://github.com/asdf-community/asdf-hashicorp.git master 3122c04
zig                          https://github.com/cheetah/asdf-zig.git master d88f6db

asdf plugins affected (if relevant)

No response

@h3y6e h3y6e added the bug label Jan 5, 2023
@h3y6e
Copy link
Author

h3y6e commented Jan 5, 2023

I thought perhaps this is caused by the following code evaluating -n "$(tail -c1 "$file")" first.

# Add a trailing newline at the end of the file if missing
[[ -n "$(tail -c1 "$file")" && -f "$file" ]] && printf '\n' >>"$file"

May I submit a PR to correct this?

@Stratus3D
Copy link
Member

Thanks for the bug report @h3y6e ! And thanks for pinpointing the issue!

Stratus3D added a commit that referenced this issue Jan 5, 2023
We need to add trailing newlines to .tool-versions file before appending
a new version to the file. The order of the checks was wrong here as the
first check assumed the file existed, and the second checked if it did.
Switching them fixes the issue.

This fix was provided by @h3y6e

Fixes #1417
Stratus3D added a commit that referenced this issue Jan 5, 2023
We need to add trailing newlines to .tool-versions file before appending
a new version to the file. The order of the checks was wrong here as the
first check assumed the file existed, and the second checked if it did.
Switching them fixes the issue.

This fix was provided by @h3y6e

Fixes #1417
@h3y6e
Copy link
Author

h3y6e commented Jan 5, 2023

Thank you for your swift response!

Stratus3D added a commit that referenced this issue Jan 5, 2023
…ine (#1418)

We need to add trailing newlines to .tool-versions file before appending
a new version to the file. The order of the checks was wrong here as the
first check assumed the file existed, and the second checked if it did.
Switching them fixes the issue.

This fix was provided by @h3y6e

Fixes #1417
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants