close
Skip to content

fix: handle tilde in env vars#2092

Merged
Stratus3D merged 1 commit into
masterfrom
tb/fix-tilde-parsing
May 16, 2025
Merged

fix: handle tilde in env vars#2092
Stratus3D merged 1 commit into
masterfrom
tb/fix-tilde-parsing

Conversation

@Stratus3D

Copy link
Copy Markdown
Member

This is an exact copy of #2003 that has been rebased onto latest master.

Summary

Adds support for ~ provided via env vars. Also removes go-homedir directly and indirectly via revive. While we could argue setting ~ in the environment is invalid, it's also a simple error to make (ASDF_DATA_DIR=~/.asdf vs ASDF_DATA_DIR="~/.asdf"). Since this code already handles parsing ~ out of the default values, it's not hard to handle the user provided case by moving the replacement a few lines down.

Fixes: #1997
Fixes: #1923

Other Information

Before

andre@Andres-MacBook-Pro asdf % ASDF_DATA_DIR="~/.asdf" asdf info 
OS:
Darwin Andres-MacBook-Pro.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 arm64

SHELL:
zsh 5.9 (arm64-apple-darwin24.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
0.16.4

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=~/.asdf
ASDF_CONFIG_FILE=/Users/andre/.asdfrc

ASDF INSTALLED PLUGINS:

After

andre@Andres-MacBook-Pro asdf % ASDF_DATA_DIR="~/.asdf" ./asdf info
OS:
Darwin Andres-MacBook-Pro.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 arm64

SHELL:
zsh 5.9 (arm64-apple-darwin24.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
"1391473-dev"

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/andre/.asdf
ASDF_CONFIG_FILE=/Users/andre/.asdfrc

ASDF INSTALLED PLUGINS:
bats       https://github.com/timgluz/asdf-bats.git          299551f1668b2ba11804bdca709da8933b647bb5
elixir     https://github.com/asdf-vm/asdf-elixir.git        ea842831ae39417f2dfe7b96fb0c3cc573314aa6
erlang     https://github.com/asdf-vm/asdf-erlang.git        0e617b61ece7cff73331aacc1cd9986e35618c41
go-sdk     https://github.com/yacchi/asdf-go-sdk.git         3d336a3b582ecb0e3d9337b78581bb8a955352dd

Adds support for `~` provided via env vars. Also removes `go-homedir`
directly and indirectly via revive. While we _could_ argue setting `~`
in the environment is invalid, it's also a simple error to make
(`ASDF_DATA_DIR=~/.asdf` vs `ASDF_DATA_DIR="~/.asdf"`). Since this code
already handles parsing `~` out of the default values, it's not hard to
handle the user provided case by moving the replacement a few lines
down.

Fixes: #1997
Fixes: #1923
@Stratus3D Stratus3D force-pushed the tb/fix-tilde-parsing branch from 03a45fd to 1dfd4c1 Compare May 16, 2025 15:27
@Stratus3D Stratus3D marked this pull request as ready for review May 16, 2025 15:29
@Stratus3D Stratus3D requested a review from a team as a code owner May 16, 2025 15:29
@Stratus3D Stratus3D merged commit 6da599a into master May 16, 2025
8 checks passed
@Stratus3D Stratus3D deleted the tb/fix-tilde-parsing branch May 16, 2025 15:31
This was referenced May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants