Skip to content

chore: Export BASE_DIR environment variable #2045

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lukebakken
Copy link

@lukebakken lukebakken commented Mar 29, 2025

New users to asdf who wish to contribute will run into the following
errors when running ./scripts/test.bash:

 ✗ help should show dummy plugin help specific to version when version is present [7]
   (from function `setup_asdf_dir' in file test/test_helpers.bash, line 16,
    from function `setup' in test file test/help_command.bats, line 6)
     `setup_asdf_dir' failed
   mkdir: cannot create directory ‘/w spacetest_help_should_show_dummy_plugin_help_specific_to_version_when_version_is_present’: Permission denied

This is due to paths within the various test suites relying on the
BASE_DIR environment variable, which is not set by default.

This pull request modifies scripts/test.bash to correctly export
BASE_DIR

Note: I am a long-time asdf user, who would like to contribute to the
project and noticed this while setting up my dev environment on an
up-to-date Arch Linux system. My intention is to work on this issue:

#2042

@lukebakken lukebakken marked this pull request as ready for review March 29, 2025 15:11
@lukebakken lukebakken requested a review from a team as a code owner March 29, 2025 15:11
@lukebakken
Copy link
Author

I did search this project to find code, issues, etc concerning BASE_DIR -

https://github.com/search?q=repo%3Aasdf-vm%2Fasdf%20BASE_DIR&type=code

If I missed something obvious, apologies!

@Stratus3D
Copy link
Member

Hi @lukebakken thanks for the PR. This behavior definitely needs to be fixed.

With the recent rewrite in Go only the Go tests should be run directly. One of the Go test files should run the BATS tests, and it does set the BASE_DIR environment variable before running them - https://github.com/asdf-vm/asdf/blob/master/cmd/asdf/main_test.go#L127.

I think we actually need to update (or remove) ./scripts/test.bash instead of setting BASE_DIR in another location.

@lukebakken
Copy link
Author

With the recent rewrite in Go only the Go tests should be run directly. One of the Go test files should run the BATS tests, and it does set the BASE_DIR environment variable before running them

Yep, I sure missed that 😇

One advantage to being able to run the bats tests outside of go is that it allows running a subset of tests using -f. You don't need scripts/test.bash to do that, but it's nice to have.

@lukebakken lukebakken force-pushed the lukebakken/BASE_DIR-docs branch from 6da34a8 to 2beda74 Compare April 9, 2025 18:13
@lukebakken lukebakken changed the title docs: Document BASE_DIR environment variable chore: Rename BASE_DIR environment variable to ASDF_DEV_BASE_DIR Apr 9, 2025
@lukebakken lukebakken force-pushed the lukebakken/BASE_DIR-docs branch from 2beda74 to 630e5df Compare April 9, 2025 18:17
@lukebakken
Copy link
Author

@Stratus3D thanks for your review. Let me know what you think about the latest set of changes.

@Stratus3D
Copy link
Member

@lukebakken looks like you are now just renaming the environment variable. I don't think that's needed.

@lukebakken
Copy link
Author

I probably should have done two commits - rename, then this:

https://github.com/asdf-vm/asdf/pull/2045/files#diff-22a1a02b7da66d868b06d12332b26c446703bc3bed9808ab55893b50fe51260fR15

That export line is what addresses my original issue. Of course, I can revert the rename if you'd like.

@Stratus3D
Copy link
Member

@lukebakken I would like the variable rename reverted as it feels like unnecessary code churn. The other change is good.

@lukebakken lukebakken force-pushed the lukebakken/BASE_DIR-docs branch from 630e5df to 855b042 Compare April 17, 2025 14:54
@lukebakken lukebakken changed the title chore: Rename BASE_DIR environment variable to ASDF_DEV_BASE_DIR chore: Export BASE_DIR environment variable Apr 17, 2025

Verified

This commit was signed with the committer’s verified signature.
lukebakken Luke Bakken
New users to `asdf` who wish to contribute will run into the following
errors when running `./scripts/test.bash`:

```
 ✗ help should show dummy plugin help specific to version when version is present [7]
   (from function `setup_asdf_dir' in file test/test_helpers.bash, line 16,
    from function `setup' in test file test/help_command.bats, line 6)
     `setup_asdf_dir' failed
   mkdir: cannot create directory ‘/w spacetest_help_should_show_dummy_plugin_help_specific_to_version_when_version_is_present’: Permission denied
```

This is due to paths within the various test suites relying on the
`BASE_DIR` environment variable, which is not set by default.

This pull request modifies `scripts/test.bash` to correctly export
`BASE_DIR`

Note: I am a long-time asdf user, who would like to contribute to the
project and noticed this while setting up my dev environment on an
up-to-date Arch Linux system. My intention is to work on this issue:

asdf-vm#2042
@lukebakken lukebakken force-pushed the lukebakken/BASE_DIR-docs branch from 855b042 to 36c9fda Compare April 17, 2025 14:57
@lukebakken
Copy link
Author

@Stratus3D done, thanks for the reviews.

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