Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get cabal repl working #7

Open
hhefesto opened this issue Feb 3, 2020 · 8 comments
Open

get cabal repl working #7

hhefesto opened this issue Feb 3, 2020 · 8 comments

Comments

@hhefesto
Copy link
Contributor

hhefesto commented Feb 3, 2020

Original Issue: sfultong/stand-in-language#16

: user specified .o/.so/.DLL could not be loaded (libjumper.so: cannot open shared object file: No such file or directory)
Whilst trying to load: (dynamic) jumper
Additional directories searched: (none)

@hhefesto
Copy link
Contributor Author

hhefesto commented Feb 4, 2020

on shell.nix having sil = super.callCabal2nix "sil" ./. { gc = pkgs.boehmgc; jumper = sil_jumper; };
the cabal new-repl error is:

[nix-shell:~/src/stand-in-language]$ cabal new-repl
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - sil-0.1.0.0 (lib) (first run)
Preprocessing library for sil-0.1.0.0..
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
<command line>: user specified .o/.so/.DLL could not be loaded (libgc.so: cannot open shared object file: No such file or directory)
Whilst trying to load:  (dynamic) gc
Additional directories searched: (none)
cabal: repl failed for sil-0.1.0.0.

using sil = super.callCabal2nix "sil" ./. { jumper = sil_jumper; }; instead gives a similar error with an extra of cabal not being updated:

[nix-shell:~/src/stand-in-language]$ cabal new-repl
Warning: The package list for 'www.stackage.org' is 103 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - sil-0.1.0.0 (lib) (configuration changed)
Configuring library for sil-0.1.0.0..
Preprocessing library for sil-0.1.0.0..
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
<command line>: user specified .o/.so/.DLL could not be loaded (libgc.so: cannot open shared object file: No such file or directory)
Whilst trying to load:  (dynamic) gc
Additional directories searched: (none)
cabal: repl failed for sil-0.1.0.0.

So it might be that the missing gc complaint comes from sil-jumper

@hhefesto
Copy link
Contributor Author

hhefesto commented Feb 4, 2020

by the way. Originally the issue says that

Whilst trying to load: (dynamic) jumper

but I get
Whilst trying to load: (dynamic) gc

@sfultong
Copy link
Collaborator

sfultong commented Feb 4, 2020

ghci doesn't know where to look for the right shared libraries. Maybe cabal isn't passing them in correctly or something.

so somehow we have to add to the ghci shared library path (maybe set the LD_LIBRARY_PATH environment variable? That's probably too easy)

@hhefesto
Copy link
Contributor Author

hhefesto commented Feb 5, 2020

Solved it, but not elegantly:

So pkgs.bohemgc provides libgc.so.1

I copied libgc.so.1 into a new lib directory in the root of the git repo (in my case, inside of the nix-shell, I found libgc.so.1 by running ldd `which nix` ), renamed it to libgc.so, and referenced it in sil.cabal

There should be a more elegant solution using Nix.

@hhefesto
Copy link
Contributor Author

hhefesto commented Feb 5, 2020

to reference it on sil.cabal I added extra-lib-dirs: lib under the library stanza

@hhefesto
Copy link
Contributor Author

by adding extra-lib-dirs: lib there are two effects:
cabal new-repl works
cabal new-build fails

to get cabal build to work again, comment the extra-lib-dirs line, re-enter nix-shell and run cabal new-build

@hhefesto
Copy link
Contributor Author

by adding extra-lib-dirs: lib there are two effects:
cabal new-repl works
cabal new-build fails

to get cabal build to work again, comment the extra-lib-dirs line, re-enter nix-shell and run cabal new-build

This is solved by giving complete path to extra-lib-dirs.

In my case:

library
  ...
  extra-lib-dirs:      /home/hhefesto/src/stand-in-language/lib

@hhefesto
Copy link
Contributor Author

Might be able to have nix-shell sed replace a placeholder and put the appropriate extra-lib-dirs whole route (as needed).

Gitter:

@sfultong
Jul 10 15:37
oh, apparently there is a way to run a command when you enter a nix shell
https://nix.dev/tutorials/declarative-and-reproducible-developer-environments.html
see shellHook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants