Skip to content
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

[Feature request] opam install --global-bin #4390

Open
kit-ty-kate opened this issue Oct 12, 2020 · 3 comments
Open

[Feature request] opam install --global-bin #4390

kit-ty-kate opened this issue Oct 12, 2020 · 3 comments
Labels
KIND: FEATURE WISH KIND: PLUGIN CANDIDATE Feature requests that might best be implemented as plugins to opam

Comments

@kit-ty-kate
Copy link
Member

While writing/releasing https://github.com/kit-ty-kate/waylaunch I realized that there isn't a simple way to use opam for software that need to be installed system-wide. In my case I need waylaunch to be installed in /usr/local/bin (or similar according to your system preferences) as it is quite critical to be able to execute it at all times, even if I remove the switch I used to install it, if one upgrade failed, or simply switch current switch. For these reasons symlinks or extending the PATH to include the opam switch does not work.

Similar issues have been opened for this:

However in this issue I try to propose a simple solutions for packages distributing executables like me, and that is to add a --global-bin option to opam install.
This would work in the following manner:

  1. Calling opam install --global-bin <pkgs> would install the packages in the current switch as usual
  2. At the end of the installation, opam would list all the binaries installed by the explicitly requested packages, detect if there is a clash somewhere with system packages already installed at the same place.
  3. Ask the user if they really want to install the executables at the listed place just before
  4. Copy all the binaries there in sudo mode.
  5. Keep track of what has been installed so that if the user is requesting to remove one of those packages later, opam will ask the user if they want to remove them in the same manner as with the installation.
  6. If the packages are already installed by opam in the current switch and opam install --global-bin is called on them, just do points 2, 3 and 4.

Here is a visual representation of what it would look like:

$ opam install --global-bin waylaunch dune
The following actions will be performed:
  ∗ install   bos                    0.2.0    [required by waylaunch]
  ∗ install   waylaunch              0.1.0
  ∗ install   dune                   2.7.1
===== ∗ 3  =====
Do you want to continue? [Y/n] y
⬇ retrieved bos.0.2.0  (cached)
⬇ retrieved dune.2.7.1  (cached)
⬇ retrieved waylaunch.0.1.0  (cached)
∗ installed bos.0.2.0
∗ installed dune.2.7.1
∗ installed waylaunch.0.1.0

<><> Global installations ><><><><><><><><><><><><><><><><><><><>
=> The dune package would like to install:
∗ /usr/local/bin/dune
=> The waylaunch package would like to install:
∗ /usr/local/bin/waylaunch
===== ∗ 3  =====
Do you want to continue? [Y/n] y
Password:
∗ installed /usr/local/bin/dune
∗ installed /usr/local/bin/waylaunch

I hope my proposal is simple enough to not be too much of a hassle internally.

@AltGr
Copy link
Member

AltGr commented Oct 13, 2020

Have you tried opam install --destdir ?
It already implements the base of what you ask for, although there is no check for existing destination files, handling of sudo, or recording of what was installed.

@dra27
Copy link
Member

dra27 commented Oct 29, 2020

I'm uneasy about the idea that opam would ever track what's been installed outside an opam root - what happens if the root disappears, or the package is installed from two switches?

@dra27
Copy link
Member

dra27 commented Jul 9, 2021

Discussed yesterday: this is slightly at odds with the idea of opam becoming less global. For the original use case (waylaunch) this would be adequately addressed by proposals for either global switches or layered switches, which is a feature wanted elsewhere too (in fact, it's a feature wanted by most "binary" programs installed by opam!).

@rjbou rjbou added the KIND: PLUGIN CANDIDATE Feature requests that might best be implemented as plugins to opam label Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KIND: FEATURE WISH KIND: PLUGIN CANDIDATE Feature requests that might best be implemented as plugins to opam
Projects
None yet
Development

No branches or pull requests

4 participants