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

fix: get invalid ASDF_DATA_DIR when exec asdf shims by non-shell #1154

Conversation

knokmki612
Copy link
Contributor

@knokmki612 knokmki612 commented Jan 7, 2022

Summary

asdf_data_dir function inits ASDF_DATA_DIR with HOME when value is empty.
HOME may replace to empty string when asdf shims called by non-shell program.
this makes invalid value of ASDF_DATA_DIR.

the PR fixes this issue by use asdf_dir function instead of call environment variable.

Other Information

I faced this issue when using hugo which installed by nklmilojevic/asdf-hugo and nodejs which installed by asdf-vm/asdf-nodejs like this:

$ hugo server
Start building sites … 
hugo v0.91.2-1798BD3F linux/amd64 BuildDate=2021-12-23T15:33:34Z VendorInfo=gohugoio
Error: Error building site: POSTCSS: failed to transform "style/style.css" (text/css): unknown command: npx. Perhaps you have to reshim?
Built in 87 ms

I looked into it by edit $ASDF_DIR/bin/asdf shebang as #!/usr/bin/env -S bash -x.

log: https://gist.github.com/knokmki612/41b4dd92580c8c893e834c83c946114e#file-asdf-hugo-server-log

My hugo site using PostCSS integration and hugo call npx (in my environment, this places as asdf shims) when build the site by this code. it seems no using sub shell and directly exec npx. this will drop environment variables.

Environments

  • asdf: v0.9.0-9ee24a3
  • hugo: hugo v0.91.2-1798BD3F
  • nodejs: v16.13.1
  • distro: Fedora Silverblue 35

.tool-versions:

nodejs lts
hugo 0.91.2

asdf_data_dir function inits ASDF_DATA_DIR with HOME when value is empty.
HOME may replace to empty string when asdf shims called by non-shell program.
this makes invalid value of ASDF_DATA_DIR.
@knokmki612 knokmki612 requested a review from a team as a code owner January 7, 2022 15:34
In most cases, `$ASDF_DATA_DIR` should be include `$HOME` and
`setup_asdf_dir()` expects mock home directory
@Stratus3D
Copy link
Member

Hi @knokmki612 , sorry for the late review here. I've had your PR sitting open in a browser tab since you created it.

Thanks for the PR. I don't see any reason why we can't merge this now.

@Stratus3D Stratus3D merged commit b9962f7 into asdf-vm:master Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants