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: CRLF line endings in .tool-versions breaks asdf #1645

Open
remino opened this issue Sep 20, 2023 · 2 comments
Open

bug: CRLF line endings in .tool-versions breaks asdf #1645

remino opened this issue Sep 20, 2023 · 2 comments
Labels

Comments

@remino
Copy link

remino commented Sep 20, 2023

Describe the Bug

asdf 0.13.1
Installed via Homebrew
macOS 13.5.1

Somehow, I had a .tool-versions with its lines ending in CRLF (\r\n), and that didn't sit well with asdf.

See output below:

❯ xxd .tool-versions
00000000: 6e6f 6465 6a73 2031 342e 372e 300d 0a    nodejs 14.7.0..
❯ asdf current
deno            1.36.2          /Users/remino/.tool-versions
"        Not installed. Run "asdf install nodejs 14.7.0
php             8.1.16          /Users/remino/.tool-versions
python          3.10.8 2.7.18   /Users/remino/.tool-versions
ruby            3.1.2           /Users/remino/.tool-versions
❯ xxd .tool-versions
00000000: 6e6f 6465 6a73 2031 342e 372e 300d 0a    nodejs 14.7.0..
❯ asdf current
deno            1.36.2          /Users/remino/.tool-versions
"        Not installed. Run "asdf install nodejs 14.7.0
php             8.1.16          /Users/remino/.tool-versions
python          3.10.8 2.7.18   /Users/remino/.tool-versions
ruby            3.1.2           /Users/remino/.tool-versions
❯ echo 'nodejs 14.7.0' > .tool-versions
❯ xxd .tool-versions
00000000: 6e6f 6465 6a73 2031 342e 372e 300a       nodejs 14.7.0.
❯ asdf current
deno            1.36.2          /Users/remino/.tool-versions
nodejs          14.7.0          /Users/remino/Sites/legacy-app/.tool-versions
php             8.1.16          /Users/remino/.tool-versions
python          3.10.8 2.7.18   /Users/remino/.tool-versions
ruby            3.1.2           /Users/remino/.tool-versions

Steps to Reproduce

  1. Ensure asdf is set up. Open a terminal.
  2. Set the tool version with an \n ending: printf 'nodejs 14.7.0\n' > .tool-versions
  3. Verify content of file: xxd .tool-versions
  4. Try asdf current. Should work as usual.
  5. Set a tool version with an \r\n ending: printf 'nodejs 14.7.0\r\n' > .tool-versions
  6. Verify content of file again: xxd .tool-versions
  7. Try asdf current. Its output should get broken for nodejs.

Expected Behaviour

I don't think asdf should take care of blank lines or particular line endings.

Actual Behaviour

Should work regardless of \r\n and \n.

Environment

(Some parts below have been redacted for privacy.)

OS:
Darwin <HOSTNAME> 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 arm64

SHELL:
zsh 5.9 (x86_64-apple-darwin22.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
v0.13.1

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/remino/.asdf
ASDF_DIR=/opt/homebrew/opt/asdf/libexec
ASDF_CONFIG_FILE=/Users/remino/.asdfrc

ASDF INSTALLED PLUGINS:
deno                         https://github.com/asdf-community/asdf-deno.git master 87442fe
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master 9275f49
php                          https://github.com/asdf-community/asdf-php.git master 1eaf4de
python                       https://github.com/danhper/asdf-python.git master 8505457
ruby                         https://github.com/asdf-vm/asdf-ruby.git master 09cd4a5

asdf plugins affected (if relevant)

nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master 9275f49
@remino remino added the bug label Sep 20, 2023
@hyperupcall
Copy link
Contributor

hyperupcall commented Sep 20, 2023

Interesting seeing this again. I previously merged #1561, which (was supposed to) print a warning message when this happened. I guess on some code paths it's not activated. It might be worth looking into automatically fixing the file, but if I remember correctly, we decided that a warning message will suffice.

Related to #1476 and #882.

@mdonatas-trafi
Copy link

Ran into this problem with version: v0.14.0-ccdd47d where a docker container is run by mounting a windows dir where files are naturally in CRLF mode. A lot of time was wasted.

Could this be solved by "teaching" asdf to work with CRLF and not just LF?

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

3 participants