Closed hakuch closed 7 years ago
$ jbuilder utop <dir>
must be directed at a directory that contains a jbuild file. In your case, it should be lib
. Hence the following will work:
$ jbuilder utop lib
I suppose we could improve the error in this case.
Ah, I understand. Invoking jbuilder utop lib
works for me.
I'll close this ticket, though I agree that a more helpful error message would be useful.
Thanks for your help!
I'm getting the same error with 1.0+beta13:
In src/jbuild
:
(jbuild_version 1)
(executable ((name main) (libraries (core))))
In src/main.ml
:
let () = print_endline "Hello, World!"
Command & error:
$ jbuilder build src/main.exe
$ jbuilder utop src
Don't know how to build src/.utop/utop.bc
jbuilder utop
will not work with executables by design. It might be slightly annoying, but it's not easy to fix so it's best to just work around it.
OK, changed the jbuild
file to:
(jbuild_version 1)
(library ((name main) (libraries (core))))
And main.ml
:
let greet name = "Hello, " ^ name ^ "!"
Now I get the following error:
$ jbuilder utop src
ocamldep src/.utop/utop.depends.ocamldep-output
ocamldep src/main.depends.ocamldep-output
ocamlc src/main.{cmi,cmo,cmt}
ocamlc src/main.cma
ocamlc src/.utop/utop.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /Users/yawar/.opam/4.02.3/bin/ocamlc.opt -w -40 -g -bin-annot -I /Users/yawar/.opam/4.02.3/lib/bin_prot -I /Users/yawar/.opam/4.02.3/lib/bytes -I /Users/yawar/.opam/4.02.3/lib/camomile -I /Users/yawar/.opam/4.02.3/lib/core -I /Users/yawar/.opam/4.02.3/lib/core_kernel -I /Users/yawar/.opam/4.02.3/lib/fieldslib -I /Users/yawar/.opam/4.02.3/lib/findlib -I /Users/yawar/.opam/4.02.3/lib/lambda-term -I /Users/yawar/.opam/4.02.3/lib/lwt -I /Users/yawar/.opam/4.02.3/lib/num -I /Users/yawar/.opam/4.02.3/lib/ocaml -I /Users/yawar/.opam/4.02.3/lib/ocaml/threads -I /Users/yawar/.opam/4.02.3/lib/ppx_assert -I /Users/yawar/.opam/4.02.3/lib/ppx_bench -I /Users/yawar/.opam/4.02.3/lib/ppx_expect -I /Users/yawar/.opam/4.02.3/lib/ppx_inline_test -I /Users/yawar/.opam/4.02.3/lib/react -I /Users/yawar/.opam/4.02.3/lib/result -I /Users/yawar/.opam/4.02.3/lib/sexplib -I /Users/yawar/.opam/4.02.3/lib/typerep -I /Users/yawar/.opam/4.02.3/lib/utop -I /Users/yawar/.opam/4.02.3/lib/variantslib -I /Users/yawar/.opam/4.02.3/lib/zed -I src -no-alias-deps -I src/.utop -o src/.utop/utop.cmo -c -impl src/.utop/utop.ml)
File "src/.utop/utop.ml", line 1, characters 0-20:
Error: Unbound module Clflags
You need utop >= 2.0
Ah, thanks! Utop loaded after upgrading. I'm getting another error now:
utop # Main.greet;;
Error: The files _build/default/src/.utop/utop.bc
and /Users/yawar/.opam/4.02.3/lib/ocaml/compiler-libs/main.cmi
make inconsistent assumptions over interface Main
But I think I'll call it a night 😊
No idea about that error. Does it at least work for you in a recent version of OCaml?
Hi Rudi, the error goes away when I rename my source file from main.ml
to greet.ml
. Do you perhaps have a module Main
in the utop subcommand source code?
Btw, really cool work here.
utop itself doesn't have a main module, and the generated module by the utop subcommand is utop.ml
.
Perhaps it's the main module from compiler-libs?
@diml Anyway, we can address this? Could utop use ocaml-compiler-libs to give all this stuff qualified names perhaps?
jbuilder utop will not work with executables by design. It might be slightly annoying, but it's not easy to fix so it's best to just work around it.
Maybe this limitation could at least be lifted in so far as to drop me into a prompt with all dependencies loaded? Then I could #use the files I want to load manually.
Am I misunderstanding the feature? I get these errors:
I expect that
jbuilder utop
will open a utop session with thezlist
library loaded such that I could executeopen Zlist
.Installation environment:
OCaml version:
4.05.0
jbuilder version: 142155551d1a7e4db6737ad4a43c6113c55c5329 (pinned with opam) utop version:2.0.1
Steps to reproduce
(I'm using hakuch/Zlist@f5ba1146045731547b1f61963d5c5c7f24b10ea1)
git clone https://gitlab.com/jhaberku/Zlist.git zlist
cd zlist
jbuilder build
jbuilder utop .