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

--package-db clear does not seem to work #7926

Closed
farao opened this issue Jan 24, 2022 · 5 comments
Closed

--package-db clear does not seem to work #7926

farao opened this issue Jan 24, 2022 · 5 comments

Comments

@farao
Copy link
Contributor

farao commented Jan 24, 2022

Description
I would like to run cabal only from a user defined package database and ignore the global (as I understood systemwide) and local (as I understood ~/.cabal) ones.

First, I would expect cabal v2-build --package-db=clear not to build at all (because of missing dependencies) and (second) mkdir database; cabal v2-build --package-db=clear --package-db=database/ to download the missing dependencies to the database/ directory.

Unfortunately, in both cases, cabal downloads the missing dependencies to ~/.cabal. Is my understanding of the --package-db option wrong or does it simply not work?

System information

  • Fedora Linux 35
  • cabal 3.6.0.0, ghc 8.10.5
@Mikolaj
Copy link
Member

Mikolaj commented Jan 24, 2022

Hi! Package database is a GHC concept that v2 barely uses (v1 used it for the lack of something better). What is it exactly that you'd like to accomplish? Why is standard workflow not sufficient for your use case? Could you let us know the documentation that led you to this workflow so that we can perhaps fix anything that is misleading?

@farao
Copy link
Contributor Author

farao commented Jan 24, 2022

Thanks for the quick answer.

My use case: I want (if possible) to develop my cabal project on my (and other) developer machines and then push it to a local server that has no internet connection but needs to build the project.

Thus, my idea was to create a "local package database" in a directory, check the directory into git and push the whole project including the local database to that (local) server, so that it has all dependencies that it needs to build.

The documentation which led me to this is simply the documentation of --package-db in cabal v2-build --help which sounded as if this is the function to accomplish it.

@Mikolaj
Copy link
Member

Mikolaj commented Jan 24, 2022

Thank you for the details. Indeed, some old flags don't quite work with v2 commands and the documentation about that is not up to date. There are already tickets about that, I think.

I have no idea if you can make it work the way you do, perhaps using v1 while it's still (sort of) working and is not removed. Anybody? The tricky part may be the distinction between a db of compiled library object files and a db of package source tarballs. These are different things and GHC package db is more of the former kind (I guess, plus some metadata?).

I know people accomplish something like that from another end, by building a Hackage or Stackage mirror on a machine the server can connect to and then using cabal as usual. Perhaps there are better ways.

Another way might be via freeze files and caches of packages downloaded based on a freeze file. I don't remember how it's done, right now, and it has improved since I did it years ago.

Please note down in this issue (regardless if you close it or not) what worked for you so that people searching the issue tracker may find a solution. If the experience shows something in cabal can be improved, please let us know as well.

@fgaz
Copy link
Member

fgaz commented Jan 24, 2022

We are about to add --package-db to cabal-install: #7676

Still, I think what you want to do could be better accomplished by copying the sources of the dependencies and building it all on the target machine. You could do that with by running cabal fetch or cabal build --only-download and copying just ~/.cabal/packages.

Another approach is to use cabal get to get all the dependencies, then either set up a file+noindex repository or put them all in cabal.project under packages:.

@jneira
Copy link
Member

jneira commented Feb 16, 2022

@farao given there is an issue about adding that option and some way to get your final goal I think we could close this one, feel free to reopen or post any question here, thanks!

@jneira jneira closed this as completed Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants