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

Install cabal-install, firstly run cabal install --lib base, and vanilla GHC stops working #8825

Closed
gksato opened this issue Mar 2, 2023 · 5 comments · Fixed by #8903
Closed
Labels

Comments

@gksato
Copy link

gksato commented Mar 2, 2023

Describe the bug

If you execute cabal install --lib base as the first command for the installation of cabal-install, vanilla GHC stops working.

The command neither installs nor builds any package, but will create ~/.ghc/<arch>-<os>-<ghcver>/environments/default. If this is before any build of packages, the file ~/.cabal/store/ghc-<ghcver>/package.db is and continues to be non-existent, but it gets pointed to by the newly created ~/.ghc/<arch>-<os>-<ghcver>/environments/default. The env file is in an invalid state! As a result, vanilla GHC stops working until you delete the env file or you build something with cabal-install.

To Reproduce

Steps to reproduce the behavior:

# create vanilla installation
$ rm -rf ~/.cabal
$ curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_CABAL_VERSION=3.8.1.0 BOOTSTRAP_GHC_VERSION=9.4.4 sh

$ cabal v2-update
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org has been updated.
The index-state is set to 2023-03-01T23:54:23Z.
To revert to previous state run:
    cabal v2-update 'hackage.haskell.org,2023-02-02T05:57:26Z'

$ cabal v2-install --lib base
Resolving dependencies...
Up to date

$ ghci
Loaded package environment from $HOME/.ghc/x86_64-linux-9.4.4/environments/default
GHCi, version 9.4.4: https://www.haskell.org/ghc/  :? for help
ghc-9.4.4: can't find a package database at $HOME/.cabal/store/ghc-9.4.4/package.db

Expected behavior

Vanilla GHC should work after cabal v2-install --lib base. We have, at least, three options:

  • cabal v2-install --lib base should not create ~/.ghc/<arch>-<os>-<ghcver>/environments/default.
  • cabal v2-install --lib base should ensure that the cabal-managed package database exists.
  • cabal v2-install --lib base should not write the dependency on the cabal-managed package database in an env file until an actual dependency appears.

I have no idea which is the best among these three options or whether there is a better option.

System information

  • OS: Ubuntu 22.10 on Docker on MacOS Ventura 13.2.1
  • cabal-install: 3.8.1.0
  • GHC: 9.4.4
@gbaz
Copy link
Collaborator

gbaz commented Mar 2, 2023

Good catch. I think the correct and general answer would be cabal v2-install --lib ensures that the database exists before writing an env file pointing to it.

@Mikolaj
Copy link
Member

Mikolaj commented Mar 2, 2023

Would it ensure by failing or by creating it?

@gksato
Copy link
Author

gksato commented Mar 2, 2023

What I meant is by creating it. "By failing" would mean doing nothing, so I considered it included in the first option.

@gbaz
Copy link
Collaborator

gbaz commented Mar 2, 2023

Good catch mikolaj, my proposal would actually be "ensure by failing" not creating -- as I think creating a vacuous empty packagedb is a bit silly -- and further, sort of invasive since it would involve mucking around with packagedb logic.

On the other hand, simply not creating an env file but emitting a warning can be done entirely as a local change to one function: https://github.com/haskell/cabal/blob/master/cabal-install/src/Distribution/Client/CmdInstall.hs#L697

@gksato
Copy link
Author

gksato commented Mar 19, 2023

@gbaz Sounds completely sensible. And you say "ensure" to mean cabal v2-install --lib base should create an env fille if cabal's package database exists and do nothing with a warning only in the case the db does not exist, right? After all, some users might actually want to work in an environment where only base is available, and after #8607 the command should create such an environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants