-
Notifications
You must be signed in to change notification settings - Fork 249
[bin wrappers] Fixes: don't export PATH, and eval the symlink of the binary #1330
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
Changes from 1 commit
0380f45
daf14e6
2a3f1f3
10af51c
2f91182
568eb78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,13 +89,19 @@ func CreateWrappers(ctx context.Context, devbox devboxer) error { | |
// 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) { | ||
// Get the symlink path; create the symlink directory if it doesn't exist. | ||
curDir := xdg.CacheSubpath(filepath.Join("devbox", "bin", "current")) | ||
if err := fileutil.EnsureDirExists(curDir, 0755, false /*chmod*/); err != nil { | ||
return "", err | ||
} | ||
currentDevboxSymlinkPath := filepath.Join(curDir, "devbox") | ||
|
||
devboxBinaryPath, err := os.Executable() | ||
// Get the path to the devbox binary. | ||
execPath, err := os.Executable() | ||
if err != nil { | ||
return "", errors.WithStack(err) | ||
} | ||
devboxBinaryPath, err := filepath.EvalSymlinks(execPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me harden this, so if an error is returned, then we do NOT error here. And then we skip modifying the PATH in the bin-wrappers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if this errors, you can simply delete the symlink and not recreate it. The rest can be the same. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will fail if existing symlink is already a loop. I think in that case we should just remove the symlink and not create a new one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't remove the symlink: i'm a little concerned that if it was previously created and was working fine, then by removing the symlink we may break some bin-wrappers (that are from a different project) that have the symlinkDir in their PATH |
||
if err != nil { | ||
return "", errors.WithStack(err) | ||
} | ||
|
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.
change definition of this function to return sym link dir.
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.
I'd prefer not doing that, since I'd expect a function named
CreateDevboxSymlink
to return the path to the symlink, rather than its directory. Changing the name toCreateDevboxSymlinkAndGetDir
feels verbose. I think its okay for the handling logic to dofilepath.Dir
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.
but yeah, let me know if you feel strongly, and I can make the change.