Installation in Arch Linux
ninioArtillero opened this issue · comments
Problem
I manage to successfully install Euterpea following the instructions on the web page but I wasn´t able to import it into ghci.
Context
Kernel: 6.0.6-zen1-1-zen
DE: KDE Plasma
OS: Garuda Linux
To reproduce
- Make sure to not have any previous configuration for the Haskell toolchain. In a terminal run
rm -rf .cabal .ghc
- Install ghcup from upstream script
- In a terminal run
ghcup tui
and install ghc 8.10.7. During ghcup installation you should be prompted for cabal installation, which at this time installs 9.2.4 by default (which is ok, you can have more than one version of ghc without conflict) - From within
ghcup tui
set ghc 8.10.7 - Clone this repo, and from inside its location run
cabal v1-install --allow-newer
(without the last flag it fails in my system). - Run
ghci
and thenimport Euterpea
This results in
$ ghci
Loaded package environment from /home/user/.ghc/x86_64-linux-9.2.4/environments/default
GHCi, version 9.2.4: https://www.haskell.org/ghc/ :? for help
ghci> import Euterpea
<no location info>: error:
Could not find module ‘Euterpea’
It is not a module in the current program, or in any known package.
Using the cabal v1 repl also fails: cabal v1-repl
and then import Euterpea
results in the same error.
Of notice:
- I'm have the Haskell toolchain installed vía ghcup and use statically linked packages installed from cabal only (with no Arch Linux official repository haskell-* packages).
- The package isn't displayed in
cat ~/.ghc/x86_64-linux-8.10.7/environments/default
nor inls ~/.cabal/store/ghc-8.10.7/package.db/
even thoughghc-pkg list
listsEuterpea-2.0.8
and the library also appears inls .cabal/lib/x86_64-linux-ghc-8.10.7/
- After this steps I followed the same installation procedure using ghc 9.2.4 (by setting it in
ghcup tui
) to the same results.
What worked
After all this (without clearing the previous steps) I set ghc 8.10.7 back(because most of my installed packages use this version). I then tried the following command:
cabal install Euterpea --lib --allow-newer
Again, without the last flag the command fails. With this the package is downloaded from Hackage instead of this repo.
I haven´t tried this command to install from the repo directory, but it should also work.
Now I was able to import the library and Euterpea appears in:
ls .cabal/store/ghc-8.10.7/package.db/
and
cat ~/.ghc/x86_64-linux-8.10.7/environments/default
Suggestion
I don´t get exactly how the different cabal commands behave and why they differ in results, neither where this issue should be fixed (the Euterpea.cabal? or all the way into the cabal build system or command?).
For the moment I suggest adding the above successful command as an option in the installation instructions.
Thanks for the very detailed info! Interesting...the --lib flag is new to me. A long time ago when just a regular "cabal install" ceased to install things globally, I was looking for something to solve that and never encountered --lib as a suggestion for whatever reason. I just did a quick test and it looks like "cabal install --lib --allow-newer" also works on Windows to install from a local repo copy (I'm also using ghc 8.10.7 currently; haven't tested any other versions). If it's a broader solution across some older versions then I like that a lot better than the v1-install and v2-install things. I've updated the install instructions on euterpea.com for Linux for the moment but it looks like --lib may be the way to go for the other OSs too.
Well, I guess I was too optimistic too quickly. Apparently --lib allows it to import into ghci on Windows but installing another library that depends on it (such as HSoM) will fail because the library isn't found. You may unfortunately find you have the same problem on Linux - if not, please do let me know. I will still keep the flag listed as an option on the website since the most common install scenario is users just wanting Euterpea working in GHCi.
Still a frustrating outcome. The description of --lib says "By default, it is writing to the global environment" but apparently not the way v1-install does.
Two related things I found...
haskell/cabal#7373
haskell/cabal#5559
The 2nd one is an open issue. So I guess there really is still just v1-install as the broadest solution even if --lib helps in some instances where it fails (but then --lib comes with its own problems).
EDIT: I should note that when I say --lib causes the library to not be found for other installs, Euterpea is missing with a "ghc-pkg list" command.
Since --lib does not appear to be a complete solution (i.e. permitting install of HSoM too, not just making Euterpea work with GHCi) without messing around with ghc environments, I have moved mention of the flag for Linux to the Troubleshooting page on the Euterpea website rather than putting it on the main page. I have some concern that if it's on the main page, users who may simply need v1-style commands with --allow-newer might go for --lib and have more problems. I will leave the issue open for now since it seems like there should be a better solution.
Thanks for looking into it. I'm going through the book (which is awesome) and still haven´t need the HSoM, but I'll gladly do some further testing in my system and come back.