Repository navigation
Add bin_dir setting and use sudo only for unwritable bin directories - #20
Merged
Merged
Conversation
jsnjack
reviewed
Oct 30, 2026
The bin_dir setting changes where grm installs binaries. It defaults to /usr/local/bin/ and must be an absolute path; an empty value restores the default. A missing directory is created before the first binary is installed. Binary file operations use sudo only when the current user cannot create files in the target directory, or in its nearest existing parent when the directory does not exist yet, so a user-owned directory such as ~/.local/bin works without sudo and keeps user ownership. System package operations still use sudo. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
patrick-5546
force-pushed
the
bin-dir-setting
branch
from
October 30, 2026 17:05
9b23a36 to
1b160ea
Compare
jsnjack
self-requested a review
November 2, 2026 16:13
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
grm installs binaries to
/usr/local/bin/and copies and removes them through sudo. On machines where the user has no sudo access, or prefers to keep tools in the home directory, there is no way to choose another directory. Running the commands through sudo also makes binaries in a user-owned directory owned by root.Change
grm set bin_dir <absolute path>stores the directory in the config file. Relative paths are rejected, and an empty value restores the default.GrmConfig.BinDir()returns the setting orDefaultBinDir, andinstallReleaseuses it for new binary components, including--rename.runPrivileged.installBinaryTocreates it withmkdir -pbefore the first copy, using the same rule. A new~/.local/binis created without sudo, and a directory under a root-owned parent is created through sudo.Behavior change
When the target directory is already writable by the current user, grm no longer uses sudo for binary files. For example, if Homebrew has made
/usr/local/binwritable by the user, binaries installed there are now owned by the user instead of root. When the directory is not writable, grm uses sudo as before.A missing target directory is now created. This also applies to the default: if
/usr/local/bindoes not exist, grm creates it through sudo, wheremasterfails to copy the binary.Existing installs keep their recorded paths. After
bin_dirchanges, a binary moves to the new directory on its next update orgrm install --refresh, and the installation plan lists the old file for removal.Tested
BinDir(),installReleasewithbin_dir(with and without--rename, and with a directory that does not exist yet), and sudo use for writable, unwritable, and missing directories. The missing-directory cases fail without the directory handling.TestInstallReleaseMigratesLegacyConfigandTestInstallReselectsOnlyWhenFilterChangesreplacePATHwith fake programs and install to/usr/local/bin, so they now also provide a fakemkdir. Without it, they fail on systems where/usr/local/bindoes not exist.make fmt vet build lintpasses.go test ./...passes in afedora:44container as root and as a regular user, with and without/usr/local/bin. On Ubuntu, three existing asset filter tests fail onmastertoo, because they expectrpmto be installed anddpkgto be missing.sudofirst onPATH: aftergrm set bin_dir <dir>with a<dir>that does not exist yet,grm install bootandy/dust -f tar.gz -ycreates the directory and installs the binary owned by the user, without sudo. Under an unwritable parent, only themkdirruns through sudo.