haskellghci

I am unable to run GHCI from the linux command line. Need guidance because scripts point to non-existent locations


I am trying to run ghci for the first time after a successful installation of Haskell 9.4.8.

After issuing ghci command, I am faced with this message:

/root/.ghcup/ghc/9.4.8/bin/ghc-9.4.8: line 12: /root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghc-9.4.8: No such file or directory

I looked at the installation directory structure and found that subdirectories "/bin/./ghc-9.4.8" do not exist under "/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/" - as the error message suggests.

My installation uses two scripts to try to launch ghci, /root/.ghcup/ghc/9.4.8/bin/ghci-9.4.8 - which in turn calls /root/.ghcup/ghc/9.4.8/bin/ghc-9.4.8. This second script makes reference to the missing subdirectory and file, causing the ghci invocation to fail. The scripts are straightforward, setting up some variables then calling something in each case.

Script ghci-9.4.8

#!/bin/sh
set -xv
echo "In GHCI 9.4.8"
exedir="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin"
exeprog="./ghci-9.4.8"
executablename="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghci-9.4.8"
bindir="/root/.ghcup/ghc/9.4.8/bin"
libdir="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/lib"
docdir="/root/.ghcup/ghc/9.4.8/share/doc/ghc-9.4.8"
includedir="/root/.ghcup/ghc/9.4.8/include"

executable="$bindir/ghc-9.4.8"
exec $executable --interactive "$@"

Script ghc-9.4.8

#!/bin/sh
set -xv
echo "In GHC 9.4.8"
exedir="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin"
exeprog="./ghc-9.4.8"
executablename="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghc-9.4.8"
bindir="/root/.ghcup/ghc/9.4.8/bin"
libdir="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/lib"
docdir="/root/.ghcup/ghc/9.4.8/share/doc/ghc-9.4.8"
includedir="/root/.ghcup/ghc/9.4.8/include"

exec "$executablename" -B"$libdir" ${1+"$@"}

I added a couple of eye-catcher "echo" statements into these scripts to help identify the flow and added "set -xv" to both to elaborate the activity taking place. Execution output here:

opensuse-64:~ # ghci
echo "In GHCI 9.4.8"
+ echo 'In GHCI 9.4.8'
In GHCI 9.4.8
exedir="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin"
+ exedir=/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin
exeprog="./ghci-9.4.8"
+ exeprog=./ghci-9.4.8
executablename="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghci-9.4.8"
+ executablename=/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghci-9.4.8
bindir="/root/.ghcup/ghc/9.4.8/bin"
+ bindir=/root/.ghcup/ghc/9.4.8/bin
libdir="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/lib"
+ libdir=/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/lib
docdir="/root/.ghcup/ghc/9.4.8/share/doc/ghc-9.4.8"
+ docdir=/root/.ghcup/ghc/9.4.8/share/doc/ghc-9.4.8
includedir="/root/.ghcup/ghc/9.4.8/include"
+ includedir=/root/.ghcup/ghc/9.4.8/include

executable="$bindir/ghc-9.4.8"
+ executable=/root/.ghcup/ghc/9.4.8/bin/ghc-9.4.8
exec $executable --interactive "$@"
+ exec /root/.ghcup/ghc/9.4.8/bin/ghc-9.4.8 --interactive

echo "In GHC 9.4.8"
+ echo 'In GHC 9.4.8'
In GHC 9.4.8
exedir="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin"
+ exedir=/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin
exeprog="./ghc-9.4.8"
+ exeprog=./ghc-9.4.8
executablename="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghc-9.4.8"
+ executablename=/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghc-9.4.8
bindir="/root/.ghcup/ghc/9.4.8/bin"
+ bindir=/root/.ghcup/ghc/9.4.8/bin
libdir="/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/lib"
+ libdir=/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/lib
docdir="/root/.ghcup/ghc/9.4.8/share/doc/ghc-9.4.8"
+ docdir=/root/.ghcup/ghc/9.4.8/share/doc/ghc-9.4.8
includedir="/root/.ghcup/ghc/9.4.8/include"
+ includedir=/root/.ghcup/ghc/9.4.8/include

exec "$executablename" -B"$libdir" ${1+"$@"}
+ exec /root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghc-9.4.8 -B/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/lib --interactive
/root/.ghcup/ghc/9.4.8/bin/ghc-9.4.8: line 12: /root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin/./ghc-9.4.8: No such file or directory

You will note the failure in the last line.

Question is, should there be a "/bin" directory with contents under "/root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/"?

Any help appreciated.


Solution

  • Yes, I suspect there really should be a /root/.ghcup/ghc/9.4.8/lib64/ghc-9.4.8/bin with executables inside. After a successful installation of GHC 9.4.8 through ghcup on my machine, here's what cd ~/.ghcup/ghc/9.4.8 && tree -L 4 looks like:

    .
    ├── bin
    │   ├── ghc -> ghc-9.4.8
    │   ├── ghc-9.4.8
    │   ├── ghci -> ghci-9.4.8
    │   ├── ghci-9.4.8
    │   ├── ghc-pkg -> ghc-pkg-9.4.8
    │   ├── ghc-pkg-9.4.8
    │   ├── haddock -> haddock-ghc-9.4.8
    │   ├── haddock-ghc-9.4.8
    │   ├── hp2ps -> hp2ps-ghc-9.4.8
    │   ├── hp2ps-ghc-9.4.8
    │   ├── hpc -> hpc-ghc-9.4.8
    │   ├── hpc-ghc-9.4.8
    │   ├── hsc2hs -> hsc2hs-ghc-9.4.8
    │   ├── hsc2hs-ghc-9.4.8
    │   ├── runghc -> runghc-9.4.8
    │   ├── runghc-9.4.8
    │   ├── runhaskell -> runhaskell-9.4.8
    │   └── runhaskell-9.4.8
    ├── lib
    │   └── ghc-9.4.8
    │       ├── bin
    │       │   ├── ghc -> ghc-9.4.8
    │       │   ├── ghc-9.4.8
    │       │   ├── ghc-iserv -> ghc-iserv-ghc-9.4.8
    │       │   ├── ghc-iserv-dyn -> ghc-iserv-dyn-ghc-9.4.8
    │       │   ├── ghc-iserv-dyn-ghc-9.4.8
    │       │   ├── ghc-iserv-ghc-9.4.8
    │       │   ├── ghc-iserv-prof -> ghc-iserv-prof-ghc-9.4.8
    │       │   ├── ghc-iserv-prof-ghc-9.4.8
    │       │   ├── ghc-pkg -> ghc-pkg-9.4.8
    │       │   ├── ghc-pkg-9.4.8
    │       │   ├── haddock -> haddock-ghc-9.4.8
    │       │   ├── haddock-ghc-9.4.8
    │       │   ├── hp2ps -> hp2ps-ghc-9.4.8
    │       │   ├── hp2ps-ghc-9.4.8
    │       │   ├── hpc -> hpc-ghc-9.4.8
    │       │   ├── hpc-ghc-9.4.8
    │       │   ├── hsc2hs -> hsc2hs-ghc-9.4.8
    │       │   ├── hsc2hs-ghc-9.4.8
    │       │   ├── runghc -> runghc-9.4.8
    │       │   ├── runghc-9.4.8
    │       │   ├── runhaskell -> runghc-9.4.8
    │       │   ├── runhaskell-9.4.8 -> runghc-9.4.8
    │       │   ├── unlit -> unlit-ghc-9.4.8
    │       │   └── unlit-ghc-9.4.8
    │       └── lib
    │           ├── bin
    │           ├── ghci-usage.txt
    │           ├── ghc-usage.txt
    │           ├── html
    │           ├── latex
    │           ├── llvm-passes
    │           ├── llvm-targets
    │           ├── package.conf.d
    │           ├── settings
    │           ├── template-hsc.h
    │           └── x86_64-linux-ghc-9.4.8
    └── share
        ├── doc
        │   └── ghc-9.4.8
        │       ├── archives
        │       ├── Haddock.pdf
        │       ├── html
        │       ├── users_guide
        │       └── users_guide.pdf
        └── man
            └── man1
                └── ghc.1
    
    19 directories, 51 files
    

    On my machine, the directory is named lib rather than lib64, but perhaps that difference can be chalked up to some arcane multi-arch autodetection of some kind; in any case, you can see there is a lib/ghc-9.4.8/bin with various executables of interest inside.

    You could try wiping .ghcup and installing again to see if anything changes, but that's walking into dead-chicken territory; once you've done that and it didn't help, file a bug with the ghcup folks and see if they have advice on next steps for debugging.