Skip to content

fix: correct handling of ASDF_FORCE_PREPEND environment variable #2011

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

Merged
merged 7 commits into from
Mar 14, 2025

Conversation

machupicchubeta
Copy link
Contributor

Summary

The error occurs if I set "yes" to FORCE_PREPEND env as described in the documentation.

Error message

strconv.ParseBool: parsing \"yes\": invalid syntax

Other Information

Referenced Documents

@machupicchubeta machupicchubeta requested a review from a team as a code owner March 9, 2025 15:19
The error occurs if I set "yes" to `FORCE_PREPEND` env as described in the documentation.

Error message:
```
strconv.ParseBool: parsing \"yes\": invalid syntax
```

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/7352bf4890143184ba419392ca5e6204167c8306/docs/manage/configuration.md#asdf_force_prepend
…ironment variable

Those test cases aims to check whether `ForcePrepend` was actually set to the correct/expected value.

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/7352bf4890143184ba419392ca5e6204167c8306/docs/manage/configuration.md#asdf_force_prepend
@machupicchubeta machupicchubeta force-pushed the force_prepend branch 3 times, most recently from 559004e to b017252 Compare March 10, 2025 15:21
If the `ASDF_FORCE_PREPEND` environment variable is not set on macOS, the behavior is the same as when "yes" is set.

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/7352bf4890143184ba419392ca5e6204167c8306/docs/manage/configuration.md#asdf_force_prepend
`ASDF_FORCE_PREPEND` is a specification that changes behavior depending on whether the string is "yes" or not.

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/7352bf4890143184ba419392ca5e6204167c8306/docs/manage/configuration.md#asdf_force_prepend
Copy link
Contributor

@andrecloutier andrecloutier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -59,8 +61,13 @@ type Settings struct {
}

func defaultConfig(dataDir, configFile string) *Config {
forcePrepend := forcePrependDefault
forcePrependEnv := os.Getenv("ASDF_FORCE_PREPEND")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to be able to handle inconsistent case here. Some folks might set this to YES by mistake and I think that should be handled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it means case-insensitive. Sounds good to me.
I'll try to write a commit.

Copy link
Member

@Stratus3D Stratus3D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @machupicchubeta ! I really appreciate the added tests!

@Stratus3D Stratus3D changed the title fix: Avoid ParseBool error fix: correct handling of ASDF_FORCE_PREPEND environment variable Mar 14, 2025
@Stratus3D Stratus3D merged commit 43a84a0 into asdf-vm:master Mar 14, 2025
9 checks passed
@Stratus3D Stratus3D mentioned this pull request Mar 14, 2025
@machupicchubeta machupicchubeta deleted the force_prepend branch March 15, 2025 06:42
@machupicchubeta
Copy link
Contributor Author

@andrecloutier @Stratus3D
Thank you for the review and merge!

@machupicchubeta machupicchubeta changed the title fix: correct handling of ASDF_FORCE_PREPEND environment variable fix: Correct handling of ASDF_FORCE_PREPEND environment variable Mar 15, 2025
@machupicchubeta machupicchubeta changed the title fix: Correct handling of ASDF_FORCE_PREPEND environment variable fix: correct handling of ASDF_FORCE_PREPEND environment variable Mar 15, 2025
machupicchubeta added a commit to machupicchubeta/asdf that referenced this pull request Mar 19, 2025
I agree that it would be valid even if it is set in uppercase as well as lowercase.

@Stratus3D commented:
- asdf-vm#2011 (comment)
> We might want to be able to handle inconsistent case here. Some folks might set this to YES by mistake and I think that should be handled.
machupicchubeta added a commit to machupicchubeta/asdf that referenced this pull request Mar 19, 2025
I agree that it would be valid even if it is set in uppercase as well as lowercase.

@Stratus3D commented:
- asdf-vm#2011 (comment)
> We might want to be able to handle inconsistent case here. Some folks might set this to `YES` by mistake and I think that should be handled.
machupicchubeta added a commit to machupicchubeta/asdf that referenced this pull request Mar 20, 2025
Previously, the value of `ForcePrepend` was not used anywhere and was not behaving as specified.
With this commit, the behavior will be as specified.

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/932ac468b7c24c2adef90a293a1f7280a0074cc4/docs/manage/configuration.md#asdf_force_prepend

Background:

@andrecloutier told about this issue me in a comment on another PullRequest. Thank you!
- asdf-vm#2011 (comment)
machupicchubeta added a commit to machupicchubeta/asdf that referenced this pull request Mar 20, 2025
Previously, the value of `ForcePrepend` was not used anywhere and was not behaving as specified.
With this commit, the behavior will be as specified.

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/932ac468b7c24c2adef90a293a1f7280a0074cc4/docs/manage/configuration.md#asdf_force_prepend

Background:

@andrecloutier told about this issue me in a comment on another PullRequest. Thank you!
- asdf-vm#2011 (comment)
machupicchubeta added a commit to machupicchubeta/asdf that referenced this pull request Mar 20, 2025
Previously, the value of `ForcePrepend` was not used anywhere and was not behaving as specified.
With this commit, the behavior will be as specified.

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/932ac468b7c24c2adef90a293a1f7280a0074cc4/docs/manage/configuration.md#asdf_force_prepend

Background:

@andrecloutier told about this issue me in a comment on another PullRequest. Thank you!
- asdf-vm#2011 (comment)
machupicchubeta added a commit to machupicchubeta/asdf that referenced this pull request Mar 20, 2025
Previously, the value of `ForcePrepend` was not used anywhere and was not behaving as specified.
With this commit, the behavior will be as specified.

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/932ac468b7c24c2adef90a293a1f7280a0074cc4/docs/manage/configuration.md#asdf_force_prepend

Background:

@andrecloutier told about this issue me in a comment on another PullRequest. Thank you!
- asdf-vm#2011 (comment)
machupicchubeta added a commit to machupicchubeta/asdf that referenced this pull request Mar 20, 2025
Previously, the value of `ForcePrepend` was not used anywhere and was not behaving as specified.
With this commit, the behavior will be as specified.

BREAKING CHANGE:
So far, `ASDF_FORCE_PREPEND` environment variable setting has been ignored, but this commit may change the behavior depending on the setting.

If it is not set, macOS behavior will not change, but Linux behavior will change.
If you want to get the same behavior as before, it is recommended to set the relevant environment variable.

Referenced Documents:
- https://github.com/asdf-vm/asdf/blob/932ac468b7c24c2adef90a293a1f7280a0074cc4/docs/manage/configuration.md#asdf_force_prepend

Background:
@andrecloutier told about this issue me in a comment on another PullRequest. Thank you!
- asdf-vm#2011 (comment)
machupicchubeta added a commit to machupicchubeta/asdf that referenced this pull request Mar 20, 2025
I agree that it would be valid even if it is set in uppercase as well as lowercase.

@Stratus3D commented:
- asdf-vm#2011 (comment)
> We might want to be able to handle inconsistent case here. Some folks might set this to `YES` by mistake and I think that should be handled.
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.

3 participants