Haskell-Things / ImplicitCAD

A math-inspired CAD program in haskell. CSG, bevels, and shells; 2D & 3D geometry; 2D gcode generation...
https://implicitcad.org/
GNU Affero General Public License v3.0
1.32k stars 140 forks source link

README ghci test not working and there is no ~/.cabal/lib/ ... #481

Open kjcole opened 5 months ago

kjcole commented 5 months ago

Maybe more documentation needed?

This is most likely a problem with your Linux distro and cabal not playing nice. GHC is not configured to see the ImplicitCAD libraries. You can confirm this by trying the test in ~/.cabal/lib/. If that works, you should be able to use ghc anywhere with the -Ldir or -llib options. Alternatively, some people have permanently fixed this by doing the cabal install as root.

A slightly edited log:

$ apt install ghc haskell-stack cabal-install
$ cabal update && cabal install implicit
$ echo "circle(30);" > test.escad
$ extopenscad test.escad
Loading File.
Processing File.
Rendering 2D object from test.escad to test.stl with resolution 2.0 in
box (V2 (-30.0) (-30.0),V2 30.0 30.0) circle 30.0
<<ghc:
  2264880 bytes, 2 GCs, 238032/238032 avg/max bytes residency (1
  samples), 18M in use, 0.005 INIT (0.002 elapsed), 0.004 MUT (0.002
  elapsed), 0.000 GC (0.000 elapsed)
:ghc>>
$ ls
test.escad  test.stl
$ ghci
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Prelude>  import Graphics.Implicit

<no location info>: error:
    Could not find module ‘Graphics.Implicit’
    It is not a module in the current program, or in any known package.
Prelude> ^D
$ locate cabal | grep lib | grep -i implicit | wc -l
117
$ locate cabal | grep lib | grep -i implicit | rev | cut -d "/" -f 2- | rev | sort | uniq | head -n 1
~/.cabal/store/ghc-8.8.4/implicit-0.4.1.0-a990a66c188ce67ca424777aeecf8a34c19946f74d8d9563353b724167c06df9

And within that directory we have /lib/Graphics/ which contains:

I attempted the import while cd'd to ~/.cabal/ and then to each of the subdirectories, all with the same result.

kjcole commented 5 months ago

And copying from the git repo didn't work either.

$ mkdir ~/.cabal/lib
$ cp -rv ~/gits/3D/ImplicitCAD/Graphics ~/.cabal/lib/
...

$ ghci
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
Prelude> import Graphics.Implicit

<no location info>: error:
    Could not find module ‘Graphics.Implicit’
    It is not a module in the current program, or in any known package.
Prelude> ^D
Leaving GHCi.

$ ghci -Llib ~/.cabal/lib/
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
target ‘~/.cabal/lib/’ is not a module name or a source file
Prelude> ^D
Leaving GHCi.

$ ghci -Ldir ~/.cabal/lib/
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
target ‘~/.cabal/lib/’ is not a module name or a source file
Prelude> ^D
Leaving GHCi.

$ ghci -Ldir ~/.cabal/lib
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
target ‘~/.cabal/lib’ is not a module name or a source file
Prelude> ^D
Leaving GHCi.