Skip to content

Proper way to vendor dependencies? #10934

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

Open
lRespublica opened this issue Apr 22, 2025 · 3 comments
Open

Proper way to vendor dependencies? #10934

lRespublica opened this issue Apr 22, 2025 · 3 comments

Comments

@lRespublica
Copy link
Contributor

What is your question?
I need to build a program locally using cabal-install without internet access.

The build environment only includes GHC and cabal-install; no additional packages are installed. Therefore, all build dependencies must be available locally in some form.

Many modern statically linked languages (such as Rust and Go) provide a dependency vendoring mechanism to address this issue. Is it possible to achieve something similar using the native cabal-install tools?

System information

  • GNU/Linux
  • cabal - 3.14.2.0
  • GHC - 9.6.6

Additional context
For my purposes, I wrote a small script that creates a local repository with all the required package dependencies.

https://github.com/lRespublica/cabal-vendor

However, I’m still running into a few issues. For example, it's not possible to specify a relative path for the repository location, so I have to resort to using sed hacks during the build process - which isn't ideal.

That’s why I’m asking this question here - maybe I’m going about this the wrong way.

@lRespublica lRespublica changed the title Proper way to vendor dependancies? Proper way to vendor dependencies? Apr 22, 2025
@philderbeast
Copy link
Collaborator

There's a section in the source guide on vendoring. If you have local source code repositories for all of the dependencies then a cabal.project with local paths will pick up the dependencies locally.

source-repository-package
  type: git
  location: /home/... -- full path to local git repo with dependency

packages: .

You could have two project too, one for local offline use and another for when online.

@lRespublica
Copy link
Contributor Author

Yes, I saw it, but it doesn't support automatic dependency resolution - only manual downloading of packages. On top of that, it requires editing the cabal.project file, which feels just as hacky as setting up a local repository.

@philderbeast
Copy link
Collaborator

I don't think we have an automatic way of vendoring with cabal so added a feature request, #10935.

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

2 participants