-
Notifications
You must be signed in to change notification settings - Fork 248
[Bug fix] Ensure bin-wrappers use latest devbox binary to prevent false update notifications #1324
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. |
a4dff66
to
c4433d6
Compare
c4433d6
to
ff6e1ed
Compare
…se update notifications
ff6e1ed
to
2d3db2e
Compare
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.
perfect 👍
internal/wrapnix/wrapper.go
Outdated
// So, the bin-wrappers need to use a symlink to the latest devbox binary. This | ||
// symlink is updated when devbox is updated. | ||
func CreateDevboxSymlink() (string, error) { | ||
curDir := xdg.CacheSubpath(filepath.Join("devbox", "current")) |
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.
thoughts on making this devbox/bin/current
instead? that way we keep it with all the other bins.
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, I like that. Will update.
internal/wrapnix/wrapper.go
Outdated
return "", errors.WithStack(err) | ||
} | ||
|
||
if err := os.Symlink(devboxBinaryPath, currentDevboxSymlinkPath); err != nil { |
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.
Don't return error if error is os.ErrExist
(to protect against race conditions)
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.
good call.
I have a small commit locally to fix the code review feedback, but its not showing up on Github due to their incident: |
…binary (#1330) ## Summary This PR tries to address some concerns with #1324. 1. We drop `export` from `PATH` in the bin-wrappers. This would have modified PATH for all child programs, which we need not do. 2. When creating the symlink, we ensure the target value is passed through `EvalSymlink`. Previously, it was set as the result of `os.Executable`, which may still have been a symlink. ## How was it tested? did a basic sanity test of opening a devbox shell in a golang project
Summary
Motivation
In #1260, the bin-wrappers were changed to invoke the devbox-binary, instead of the devbox-launcher. However, when devbox has been updated, these bin-wrappers have the older devbox-binary's path hardcoded. So, they call the older devbox-binary leading to two issues:
Implementation
devbox shellenv
.devbox
via the launcher. This is problematic for users who have installedcoreutils
via devbox, but for most users this fallback would work.ensurePackagesAreInstalled
that runs indevbox.PrintEnv
duringdevbox shellenv
.devbox global shellenv
would run, refreshing these bin-wrappers.devbox version update
, so that it points to the new Devbox binary.Drawbacks
Switching between devbox versions (for testing and development) may lead to subtle unexpected behavior: The devbox-symlink will point to the version that created the bin-wrappers, rather than respecting the devbox of the PATH. We need to ensure we run
devbox install
or similar to re-create the bin-wrappers.How was it tested?
devbox shell
inexamples/development/go/hello-world
.devbox run build
using the devbox binary from this PR.devbox version -v
to ensure that it was re-created.