-
Notifications
You must be signed in to change notification settings - Fork 710
[RFC] Revive cabal sandboxes (UX) #10098
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
Comments
Perhaps a design like python https://docs.python.org/3/library/venv.html I agree I have also been in situations where I really know what I am doing and just need cabal to create a package database with certain packages in. Something which is very difficult to achieve currently (and seems to line up with the motivation for this feature). If anyone is interested then this quite ugly code is in Implementation wish I think it should be implemented somewhat directly if possible, features such as |
Thank you @hasufell for submitting this. This is great! A possible addition to step 2 of the your proposed workflow would be that, when the user installs a library, all of its dependencies could be made available/visible by default to ghc/ghci. That way, the user doesn't need to explicitly install them to import modules from dependencies. |
Following up on this hoping that we can move it forward. What are the next steps? |
I think the main thing we are "stuck" on is to decide whether we want a "thick" or "thin" abstraction. A thin abstraction would boil down to just creating a But it wouldn't guarantee configuration consistency. A user might unknowingly break their sandbox, e.g. because they don't know that the @mpickering opined about this on the Matrix channel too. If we want a thick abstraction, we will likely end up with an implementation that uses the old If we try to be pragmatic, I think a thin abstraction is more likely to have a straight forward prototype. |
Is there a natural transition path where we start with a thin abstraction as a first step, and progressively modify the implementation towards the thick abstraction without affecting the user experience? |
So the thin abstraction could theoretically live outside of cabal. We just need to add support for certain configurations to Then we can write a new executable that creates the appropriate config and utilize #9063 to have nicer integration. If the experiment fails in terms of UX, we can continue the discussion about a thick abstraction. The downside of this approach is that it's external and probably not shipped with cabal itself. |
I'd be open to having this externally as an experiment, although for this to survive each cabal release, I think it should be part of the features of cabal. Otherwise, there's a very high risk that things will change on Cabal's side in a way that no longer allows for this. Please correct me if I'm wrong about this. Hopefully, it's possible to make it very simple, so that the maintenance burden is minimal and is not seen as an issue to make it part of the official cabal. EDIT: Either way, let's try a quick prototype and see where we are. |
Unfortunately you cannot set |
Yes, that is described in the top post. Same goes for |
But you can from the global config! brb, need to hack |
Ok. So how to move forward on this? What's the next immediate step? I'm not well-versed enough in the current way cabal manages package DBs and such to fully follow the specific changes that would be needed. |
This is the next step: #10184 |
FWIW, I think one of the benefits of The proposed "thin" solution appears to want to hardcode the sandbox file path to |
There are two variants of the "thin" (v2-based) solution:
We're probably going to pursue the latter, because it can be implemented outside of cabal-install much easier. With that approach, a sandbox configuration is simply a file or code snippet following the Since cabal 3.8, the That means we can easily support the use case of "shared sandbox file". Your |
|
@mpickering In model/concept orthogonal to the Python platform, pipx is optimized for creating virtual environments for tool-based commands, whereas uv is best for virtual environment management across projects and scripts. I'm sad that |
Gentle nudge. |
Motivation
At ZuriHac 2024 we (@andreabedini, myself and others) talked with @ivanperez-keera and @fdedden about the user experience of using GHC and cabal for people who are not Haskell developers and are not interested in Haskell on its own, but rather use it to:
These users are not interested in:
The
cabal v2
commands are assuming a lot of these things UX-wise.We are well aware that there are ways to utilize store location and environment files to achieve something similar. But this misses a consistent UX experience.
Imperative workflow
We propose here an imperative workflow of managing haskell packages.
install
a packageThis follows the workflow of 90% of Linux distributions. It usually disallows having multiple versions of the same library.
A sandbox workflow
The sandbox workflow is an extension of the imperative workflow. A sandbox is scoped to a specific directory (and its subdirectories). Installing packages inside the sandbox only makes them available within that directory. A sandbox can be conveniently created and conveniently destroyed. A user would rather destroy a sandbox and start from scratch rather than try to fix it. This is outlined in the following workflow:
A similar workflow can be imagined with an actual cabal package that is developed ad-hoc iteratively.
Users who want maximum caching and declarative configuration can use the existing -v2 interface instead.
Implementation details
We have considered the following:
v2 based sandbox implementation
A possible implementation would be:
cabal sandbox init
would e.g. augmentcabal.project.local
with several configurationswrite-ghc-environment-files: always
store-dir: .cabal-sandbox
(this doesn't seem to be supported yet through the cabal project file)package-env: .
(seems to be not supported either through cabal project file)cabal install
would thenconstraints: <pkg-name> installed
tocabal.project.local
cabal sandbox destroy
would.cabal-sandbox
directorycabal.project.local
This would ensure consistency between directly invoking ghc and using cabal to actually build packages.
It would also allow to move the created constraints to
cabal.project
file instead (for committing them to git). We could also imagine slight variants of this idea where we utilize yet another project file with a different suffix ifcabal.project.local
is deemed inappropriate.Alternative v2 implementation without utilizing cabal.project files
An alternative implementation could create a sandbox config file that then triggers sandbox behavior in cabal (through cabal checking for its existence). This is partly implemented here: hasufell#3
But I consider it more controversial. However it is more opaque.
Related discussions and prior art
cabal install --lib
into own command (cabal env) #6481The text was updated successfully, but these errors were encountered: