-
Notifications
You must be signed in to change notification settings - Fork 269
[runx] Use single path for all runx binaries #1544
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
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 think this is okay for internal use, but we should figure out how to handle package conflicts if we ever want to release it more generally.
internal/impl/devbox.go
Outdated
if err := os.RemoveAll(runxBinPath); err != nil { | ||
return "", err | ||
} | ||
if err := fileutil.EnsureDirExists(runxBinPath, 0o755, false); 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.
Same as os.MkdirAll
.
paths = append(paths, p...) | ||
for _, path := range paths { | ||
// create symlink to all files in p | ||
files, err := os.ReadDir(path) |
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.
Won't this symlink all files in the archive, including non-binaries? I'm wondering if this will create a bunch of conflicts. For example, if multiple packages have a README
in them.
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 it will, but mostly for files we don't care about. We can fix this later on. (Requires priorities similar to nix)
internal/impl/devbox.go
Outdated
for _, file := range files { | ||
src := filepath.Join(path, file.Name()) | ||
dst := filepath.Join(runxBinPath, file.Name()) | ||
if err := os.Symlink(src, dst); err != nil && errors.Is(err, os.ErrExist) { |
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.
Why ignore other errors?
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 catch, this should be !errors.Is(err, os.ErrExist)
Specifically I want to ignore already exist errors for the case of conflicts and race conditions.
internal/impl/devbox.go
Outdated
if err := fileutil.EnsureDirExists(runxBinPath, 0o755, false); err != nil { | ||
return "", err | ||
} | ||
packages := lo.Filter(d.InstallablePackages(), devpkg.IsRunX) |
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.
Doing devpkg.IsRunX
in the loop would avoid cloning the slice.
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.
Will change. Though slice is just a pointer slice on stack, I would favor readability over avoiding the opperation.
The conflicts for sure are not a great experience, but I actually think this is almost ready for release and would not mind releasing with that issue. The main issue I'm not sure about is the |
Summary
This allows adding and removing runx binaries inside a devbox environment without having to shellenv again.
How was it tested?