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

How to bring up a REPL? #742

Closed
philderbeast opened this issue Aug 26, 2018 · 8 comments
Closed

How to bring up a REPL? #742

philderbeast opened this issue Aug 26, 2018 · 8 comments

Comments

@philderbeast
Copy link
Contributor

Please show how to bring up a REPL in the tutorial. From #380 it looks like I might be able to run a -repl target to do this.

The command to run as shown now in the readme;

rules_haskell_examples> bazel run @tutorial//main:demorgan
INFO: Analysed target @tutorial//main:demorgan (1 packages loaded).
INFO: Found 1 target...
Target @tutorial//main:demorgan up-to-date:
  bazel-bin/external/tutorial/main/demorgan
INFO: Elapsed time: 1.573s, Critical Path: 1.41s
INFO: 5 processes: 5 darwin-sandbox.
INFO: Build completed successfully, 9 total actions
INFO: Build completed successfully, 9 total actions
True

From the root folder, trying to run the -repl target;

rules_haskell_examples> bazel run @tutorial//main:demorgan-repl
INFO: Analysed target @tutorial//main:demorgan-repl (0 packages loaded).
INFO: Found 1 target...
Target @tutorial//main:demorgan-repl up-to-date:
  bazel-bin/external/tutorial/main/demorgan-repl
INFO: Elapsed time: 0.157s, Critical Path: 0.04s
INFO: 1 process: 1 darwin-sandbox.
INFO: Build completed successfully, 4 total actions
INFO: Build completed successfully, 4 total actions
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /Users/pdejoux/.ghci

<no location info>: error:
    can't find file: external/tutorial/main/Main.hs
Failed, no modules loaded.

<no location info>: error:
    Could not find module ‘Main’
    It is not a module in the current program, or in any known package.
Loaded GHCi configuration from bazel-out/darwin-fastbuild/bin/external/tutorial/main/ghci-repl-script-demorgan
Prelude> :q
Leaving GHCi.

From the tutorial folder, trying to run the -repl target;

rules_haskell_examples> cd tutorial
tutorial> bazel run //main:demorgan-repl
INFO: Analysed target //main:demorgan-repl (1 packages loaded).
INFO: Found 1 target...
Target //main:demorgan-repl up-to-date:
  bazel-bin/main/demorgan-repl
INFO: Elapsed time: 0.226s, Critical Path: 0.04s
INFO: 1 process: 1 darwin-sandbox.
INFO: Build completed successfully, 4 total actions
INFO: Build completed successfully, 4 total actions
GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /Users/pdejoux/.ghci
[1 of 1] Compiling Main             ( main/Main.hs, interpreted )

main/Main.hs:5:1: error:
    Could not find module ‘Bool’
    Perhaps you haven't installed the "dyn" libraries for package ‘booleans-1.0.0’?
    Use -v to see a list of the files searched for.
  |
5 | import Bool
  | ^^^^^^^^^^^
Failed, no modules loaded.

<no location info>: error:
    Could not find module ‘Main’
    It is not a module in the current program, or in any known package.
Loaded GHCi configuration from bazel-out/darwin-fastbuild/bin/main/ghci-repl-script-demorgan
Prelude> :q
Leaving GHCi.
@mboes
Copy link
Member

mboes commented Aug 27, 2018

Your latter command session works for me on Linux. Perhaps this is a Darwin specific problem. @judah seen this before?

@judah
Copy link
Collaborator

judah commented Aug 28, 2018

The latter command failed for me with bazel-0.16.2 on Mac OS High Sierra, though with a different error:

GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
ghc: can't find a package database at bazel-out/darwin-fastbuild/bin/external/tutorial/lib/externalZStutorialZSlibZSbooleans-1.0.0

@judah
Copy link
Collaborator

judah commented Aug 28, 2018

@mboes does it work for you even after a "clean"?

$ bazel clean
$ bazel build @tutorial//main:demorgan-repl
...
INFO: Build completed successfully, 5 total actions
$ ls bazel-bin/external/tutorial/lib/
ls: bazel-bin/external/tutorial/lib/: No such file or directory
$ bazel build @tutorial//main:demorgan
...
INFO: Build completed successfully, 19 total actions
$ ls bazel-bin/external/tutorial/lib/
externalZStutorialZSlibZSbooleans-1.0.0
interfaces-booleans
libHSexternalZStutorialZSlibZSbooleans-1.0.0-ghc8.2.2.dylib
libHSexternalZStutorialZSlibZSbooleans-1.0.0-ghc8.2.2.dylib.temp
libHSexternalZStutorialZSlibZSbooleans-1.0.0.a
objects-booleans
registration-file-booleans

Do you get similar output, or do you get the "lib" outputs still built from the repl too on Linux?

@mboes
Copy link
Member

mboes commented Aug 28, 2018

@judah same behaviour as you. -repl only works if we build first. How nasty.

@mboes
Copy link
Member

mboes commented Aug 28, 2018

There seem to be two bugs here. I do likewise get the same output as @philderbeast's second command session in the description.

@Profpatsch
Copy link
Contributor

-repl only works if we build first. How nasty.

That should be fixed once we switch the repl code to runfiles (#348).

Profpatsch referenced this issue in tweag/rules_haskell_examples Mar 7, 2019
We suffix all the build directories and files that we make with a
package name and version. As package name is a target name, there can
only be a unique one in single project and we preserve some sanity in
build environment, at least for the directories we declare and pass
around. This allows multiple `haskell_library` and `haskell_binary`
targets in a single package.

Closes #7.
@aspiwack aspiwack transferred this issue from tweag/rules_haskell_examples Mar 13, 2019
@mboes
Copy link
Member

mboes commented Mar 13, 2019

@Profpatsch ok so is there anything left here to do that isn't a dupe of #348?

@Profpatsch
Copy link
Contributor

Actually all of that should be fixed by #736, according to Andreas.

@mboes mboes closed this as completed Aug 11, 2019
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

4 participants