Cabal install tidal ends with warning

亡梦爱人 提交于 2021-01-29 09:00:53

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/61488500/cabal-install-tidal-ends-with-warning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!