-
Notifications
You must be signed in to change notification settings - Fork 249
[bin wrappers] fixes for only-path-without-wrappers call #1163
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
Conversation
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
dd9ce16
to
1eecb88
Compare
dc141bd
to
c312540
Compare
devbox.go
Outdated
@@ -73,3 +73,7 @@ func GlobalDataPath() (string, error) { | |||
func PrintEnvrcContent(w io.Writer) error { | |||
return impl.PrintEnvrcContent(w) | |||
} | |||
|
|||
func OnlyPathWithoutWrappers() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason for skipping adding this to Devbox interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a small utility function which doesn't have any dependency on the core "devbox" struct.
I was going to inline it in boxcli/shellenv.go
, but needed the exportify
function so added it here.
internal/impl/devbox.go
Outdated
func OnlyPathWithoutWrappers() string { | ||
|
||
path := []string{} | ||
for _, p := range strings.Split(os.Getenv("PATH"), string(filepath.ListSeparator)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.Getenv("PATH") works because OnlyPathWithoutWrappers is used only in the context of direnv enabled or inside devbox shell. So the PATH is guaranteed to be a devbox computed PATH.
But it won't work outside that context, if you just run the command you'll get PATH env variable (assuming you don't have devbox global).
So I worry this might be used in future in a different context with the assumption that it will compute a devbox PATH and exclude wrappers bin and introduce a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
The
devbox shellenv only-path-without-wrappers
command is Hidden, and I can add more comments to clarify its usage. It'll only be used by someone developing devbox code. So, this is low risk. -
The internal function could be renamed to
ExportSystemPathWithoutWrappers
. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah the rename can clarify the usage then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution is much better than the one I suggested in the previous PR!
4f27836
to
0911fba
Compare
0911fba
to
089cc4d
Compare
Summary
follow up to #1160
correctness:
wrapnix.GetWrapperBinPath
-c <project dir>
, but that is moot now (see below change)perf:
os.Getenv("PATH")
, remove WrapperBins, and exportify it. This function is used in a very specific context, so we can know we can skip the nix.ComputeEnv calculation.time devbox shellenv only-path-without-wrappers
is now consistently ~ 18-25 milliseconds.I have a slight preference for this over writing PATH to a file and sourcing it, since we may run into correctness issues with that file getting outdated, and it'll introduce perf regression on every shellenv call to write the file.
How was it tested?
iex -S mix
worksvisual inspection: