0
votes

I'm trying install tidal in command line this way:

cabal install tidal

but it ends with this message:

Warning: You asked to install executables, but there are no executables in target: tidal. Perhaps you want to use --lib to install libraries instead.

Return of:

cabal install tidal --lib

is:

Resolving dependencies... Up to date

If I check ghk-pkg list, there is no package tidal ... Have somebody similar problem or what I'm doing wrong?


My environment is:

  • Windows 10 Education
  • Haskell 8.4.3
  • Cabal 3.2.0.0
  • Ghc 8.10.1

Thank you for help.

2

2 Answers

1
votes

Like Stack for a longer time, Cabal-install does now (as of 3.2) not really install libraries anymore – in the sense of, change the computer's state so that GHC can access the library on it. Both tools only install executables now. It used to do that for libraries too, but that was stopped with the now default Nix-style builds.

Now (and, really, also already before), the way to use a library is instead to just depend on it, and let Cabal figure out behind the scenes if it needs to be installed. I.e., you add a .cabal file to your .hs source file with build-depends: tidal in it. Then when you say cabal install ., it will first download and install the library before then using it for building your own executable.


Of course both Stack and Cabal do technically speaking install libraries, just they don't globally register them. I.e., cabal knows where it has installed the library, but you're not really supposed to know about that. It's in the spirit of continuous integration: if your code builds now with the particular state of libraries you happen to have installed, that's not very reliable. If it builds with just those libraries that are explicitly listed in a project file, the chances are much better that future-you (or somebody else) will still be able to use your code on another computer without hours of figuring out what libraries to install first.

0
votes

cabal install --lib tidal doesn't install the library binaries in a location managed by ghc-pkg. The binaries remain in the Cabal "store".

What it does is to create a plaintext GHC package environment file that is picked up by standalone invocations of ghc and ghci and tells them where to look for the extra libraries.

By default (as mentioned in the docs) this package environment file will be created at ~/.ghc/$ARCH-$OS-$GHCVER/environments/default and will be picked by ghc and ghci invocations made anywhere.

We can also supply an extra --package-env parameter to create the environment file in a local folder, which will only affect ghc and ghci invocations made in that folder. For example:

cabal install --lib --package-env . tidal

cabal projects themselves ignore environment files, as their package environments are constructed from the build-depends section of the cabal file for the sake of reproducibility. But environment files are useful for not having to create a cabal project in the first place, if you only need it for playing with the library in ghci, or if you are compiling simple programs using ghc only.