Search code examples
tensorflowhaskellcabal

How do you get cabal to install a local package?


I'm trying to get tensorflow for haskell installed. I have the packages on my computer. I downloaded the source repo, modified it to compile, and I used the v1-install option (none of the other options will install a local package) and when I do it installs, but ghci tells me that it's not installed, and when I try to compile a program that uses the tensorflow library it fails to compile.

I'm using arch Linux, with ghc version 8.6.5, and cabal version 3.2.0.0.


Solution

  • Both stack and cabal have now pretty much the philosophy that you don't “install” any libraries, ever – not explicitly, that is. Installation has to happen of course, but the idea is that it should always stay behind the scenes, automatically done when the package manager sees it's needed. This is in the spirit of continuous integration, and does not only tend to make your projects more future-safe but also save work in not having to think of what to install from where yourself over and over again.

    The easiest case is of course if all the dependencies in your .cabal file can be fetched from Hackage, but a dependency can also be satisfied by a local package that lies on your hard drive somewhere. To tell cabal this is what you want, create a file cabal.project in the package from which you want to use TensorFlow, with the following content:

    packages: .
              /path/to/the/local/tensorflow/package
    

    Then, upon running cabal v2-build (not sure about v1-install), it will scan both your current package (.) and the TensorFlow one, figure out that the tensorflow-dependency in your project should come from the local package, satisfy all the dependencies, and re-build anything that's needed.