-
Notifications
You must be signed in to change notification settings - Fork 265
[global] Use non default profile and improve error handling when adding/removing global packages #603
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
3b7ce1c
to
ad39112
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.
I think a caveat to this is that users can't edit their global devbox.json directly. I'm thinking of the scenario where a user removes a package from devbox.json, but then it's never uninstalled because devbox thinks it didn't install it.
@gcurtis good call. I wonder if we should use jsonc and put a comment telling people not to edit manually. We could also add a hash or description:
|
Wait, I'm not sure I followed everything. Why can't users edit manually? I think they should be able to. |
@loreto as is, if they remove manually the package won't actually get removed. If they add manually it will get added to shells, but not outside of shell. |
Yeah, but why? If we have a |
@loreto using a different profile wont be in path. I was really trying to stick to using the default one. The issue is that if someone modifies devbox.json and removes a package, we can't be sure if the same package in the profile was added by nix or devbox |
Why are we trying to use the default Nix profile and PATH? Is it to avoid messing with the user's If I create the following {
"packages": [
"go",
"python3"
],
"shell": {
"init_hook": [
"unset DEVBOX_SHELL_ENABLED",
"export DEVBOX_HOME_ENABLED=1"
]
},
"nixpkgs": {
"commit": "f80ac848e3d6f0c12c52758c0f25c10c97ca3b62"
}
} And then append this to my if [ "${DEVBOX_SHELL_ENABLED:-0}" = 0 -a "${DEVBOX_HOME_ENABLED:-0}" = 0 ]; then
exec devbox shell -c ~/devbox.json
fi I get a global devbox shell when I launch my terminal, and when I do There would be some work to make this nicer (maybe silence all output when starting a global shell), but it means that the global shell uses the same exact logic as a project shell (that is, it uses print-dev-env). |
I don't mind that it's not in the path either, I think it's reasonable to require users to add a line to their rc files if they want to use devbox global (as you have to do for brew, or for nix itself). I think I prefer to that if it means:
|
Why not add a devbox.lock file? Users can still manually edit devbox.json, but devbox itself will read from devbox.lock. If a package has been removed from devbox.json but still exists in devbox.lock, then devbox will remove it. This allows manual editing of packages in addition to using the command line interface. It is similar to how other package managers like Composer and npm work. |
@nbish11 Agreed, I think a lock file is something we should add as an additional improvement (although it would probably be a follow up to this PR). |
Summary
This is stacked on #599
This improves error handling when adding and removing packages. It also uses a new devbox only profile.
How was it tested?