Open ELLIOTTCABLE opened 2 years ago
This is something which it would be nice to fix properly in opam, but we're a bit nervous that making a small tweak here runs a risk of making the already confusing switch repo selections more confusing which rules out 1 and 2, at least for now. In terms of switch naming, is it possible in your workflow either to be hashing the worktree path or transforming it to create unique repo names for each worktree?
I use
git worktree
fairly heavily, to concurrently work on multiple branches on our monorepo. Unfortunately, this means ouropam repo
— which exists in that monorepo — doesn't play nice.Our initial git-repository setup does something a lil' like this:
Unfortunately, if I run this initial setup in
~/code/monorepo
, that means opam now has this understanding:Note that the path
~/code/monorepo
is now hard-coded in a global way.Meanwhile, if someone subsequently sets up another clone of the repository and attempts to give it a clean copy of the switch (which is the entire point of directory-local switches, yes?) ...
Wait, hold up. Now the
theproj
repo points at the alt worktree; both for us, and for the original git-clone. That's bad.One fix I attempted, was setting the repo during switch-creation; so it's hopefully locally to only that switch:
Okay, nope, no suck luck — even if I attempt to create a new
theproj
repo inopam switch create
, it still conflicts with a completely separatetheproj
repo in another switch.My last attempt involved using
$PWD
as the name of the repo, because that's somewhat honest — it is, indeed, a directory-local repo specific to that worktree. Something like the following:Unfortunately, this leads — somewhat unsurprisingly — to build-failures like the following, due to non-existent directories like
/tmp/opam-NNN//home/elliott.cable/code/monorepo.worktrees/alt/packages...
:So,
tl;dr
, I'd love to see one of the following:
``` $ opam config report # opam config report # opam-version 2.1.2 # self-upgrade no # system arch=x86_64 os=linux os-distribution=debian os-version=10 [ERROR] No switch is currently set. Please use 'opam switch' to set or install a switch # read-state OpamStd.OpamSys.Exit(50) ```opam config report