tversteeg/emplace

[BUG] **fn needs_root needs clarification**

Closed this issue · 6 comments

Describe the bug
N/A
N/A

Expected behavior
N/A

Desktop (please complete the following information):
N/A

Additional context
How does needs_root work? Does it try to install everything with sudo prefixed, or something else? What about a system without sudo, like a BSD derivitive? Would it use doas? And what about package managers like npm, pip, and brew, which can both use sudo and not use sudo?

Machine information
N//A

Also, while not related to this topic, is there a way to only mirror packages if a flag is specified? I know that there is a way to exclude install statements that have a flag, like pip's -r flag, but I think that it's a good idea to only install packages with bpkg if they have the -g flag.

How does needs_root work? Does it try to install everything with sudo prefixed, or something else? What about a system without sudo, like a BSD derivitive?

The only thing needs_root does at the moment is prepending the installation command with sudo when installing. I haven't thought about systems without sudo like BSD derivatives, but that could be easily fixed with a simple compiler target check.

And what about package managers like npm, pip, and brew, which can both use sudo and not use sudo?

When sudo isn't necessary for installation it's not used by default. I haven't encountered a situation where this matters yet but if it will then it's just a simple case of capturing whether sudo is used or not.

Also, while not related to this topic, is there a way to only mirror packages if a flag is specified? I know that there is a way to exclude install statements that have a flag, like pip's -r flag, but I think that it's a good idea to only install packages with bpkg if they have the -g flag.

The capture_flags function defines flags that will be stored, but these are optional. The sub_commands function can be used for mandatory flags, but it will only allow a single subcommand at the moment, not multiple. If it's necessary for a bpkg implementation I can add a separate function for that.

It's not necessary, but -g installs a package globally while excluding it installs it to ./deps/. So it's probably best if emplace only catches packages installed with -g. This may be a problem with other package mangers. In my workflow, I only want packages installed from a "system" package manager like brew, or packages installed with a -g/--global/global subcommand from yarn, npm, etc.

I know this is a hacky solution, but I could try to make invalidating-flags match a negative pattern. Would that work, or would that break something?

I know this is a hacky solution, but I could try to make invalidating-flags match a negative pattern. Would that work, or would that break something?

I'm not a big fan of that, I'd rather change sub_commands to allow multiple required flags with an enum similar to capture_flags.

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.