Reason: Failure: Link list cannot be empty

Created on 8 Apr 2017  Â·  19Comments  Â·  Source: reasonml/reason

I installed opam, ocaml and reason according to the "INSTALLING REASON AND MERLIN" section in "NATIVE WORKFLOW" ( didn't use the ReasonNativeProject ). After running rebuild Hello.native the console logged

Failure: Link list cannot be empty.
Compilation unsuccessful after building 3 targets (0 cached) in 00:00:00.

All 19 comments

Hello! Could you provide the exact repro steps please? Plus:

which refmt rebuild
opam list

Reproduce steps are just the installing guide from the documentation:

brew update
brew install opam
opam init
opam update
opam switch 4.02.3
eval $(opam config env)
opam install reason
opam install merlin
echo 'print_string "hello!"' > Hello.re
rebuild Hello.native

which refmt rebuild:

~/.opam/4.02.3/bin/refmt
~/.opam/4.02.3/bin/rebuild

opam list:

Installed packages for 4.02.3:

base-bigarray base Bigarray library distributed with the OCaml
base-bytes base Bytes library distributed with the OCaml co
base-ocamlbuild base OCamlbuild binary and libraries distributed
base-threads base Threads library distributed with the OCaml
base-unix base Unix library distributed with the OCaml com
biniou 1.0.12 Binary data format designed for speed, safe
camomile 0.8.5 A comprehensive Unicode library
conf-m4 1 Virtual package relying on m4
conf-which 1 Virtual package relying on which
cppo 1.4.1 Equivalent of the C preprocessor for OCaml
easy-format 1.2.0 High-level and functional interface to the
jbuilder 1.0+beta6 Fast, portable and opinionated build system
lambda-term 1.10.1 Terminal manipulation library for OCaml
lwt 2.7.0 Monadic promises and concurrent I/O
menhir 20170101 LR(1) parser generator
merlin 2.5.3 Editor helper, provides completion, typing
merlin-extend 0.3 A protocol to provide custom frontend to Me
ocaml-migrate-parsetree 0.7 Convert OCaml parsetrees between different
ocamlbuild 0 Build system distributed with the OCaml com
ocamlfind 1.7.1 A library manager for OCaml
ppx_tools 5.0+4.02.0 Tools for authors of ppx rewriters and othe
ppx_tools_versioned 5.0alpha A variant of ppx_tools based on ocaml-migra
react 1.2.0 Declarative events and signals for OCaml
reason 1.13.3 Reason: Meta Language Toolchain
reason-parser 1.13.2 Reason Parser: Meta Language Toolchain
ReasonNativeProject 0.0.1 (pinned)
result 1.2 Compatibility Result module
topkg 0.8.1 The transitory OCaml software packager
utop 1.19.3 Universal toplevel for OCaml
yojson 1.3.3 Yojson is an optimized parsing and printing
zed 1.4 Abstract engine for text edition in OCaml

cc @yunxing. Are you on windows by any chance?

macOS Sierra Version 10.12.4

I turned up the verbosity level and the log may be helpful to you:

Doing sanity checks
include directories are: [ "." ]
==> Hello.native
====> Hello.cmx
======> Hello.re
Hello.re exists and up to date
======> Hello.ml.depends
========> Hello.re
Hello.re already built
start rule re dependecies (%=Hello )
mid rule re dependecies (%=Hello ): cache miss: a product is not in build dir (Hello.ml.depends)
~/.opam/4.02.3/bin/ocamldep.opt -modules -pp 'refmt --print binary' -impl Hello.re | tee Hello.re.depends > Hello.ml.depends
end rule re dependecies (%=Hello )
======> Hello.cmi
========> Hello.rei
========> Hello.re
Hello.re already built
========> Hello.re.depends
Hello.re.depends already built
start rule re -> cmo & cmi (%=Hello )
mid rule re -> cmo & cmi (%=Hello ): cache miss: a product is not in build dir (Hello.cmo)
~/.opam/4.02.3/bin/ocamlc.opt -c -pp 'refmt --print binary' -o Hello.cmo -intf-suffix .rei -impl Hello.re
end rule re -> cmo & cmi (%=Hello )
start rule re & rei -> cmx & o (%=Hello )
mid rule re & rei -> cmx & o (%=Hello ): cache miss: a product is not in build dir (Hello.cmx)
~/.opam/4.02.3/bin/ocamlopt.opt -c -pp 'refmt --print binary' -o Hello.cmx -intf-suffix .rei -impl Hello.re
end rule re & rei -> cmx & o (%=Hello )
====> Hello.o
Hello.o already built
start rule ocaml: cmx* & o* -> native (%=Hello )
Failure: Link list cannot be empty.

This seems right. Can you try ReasonNativeProject? Although I don't think that changes anything. Also, what's your file's content?

print_string "Hello!"

The ReasonNativeProject and JS Workflow setup do work and both examples run correctly.

I'm a newcomer to both reason and ocaml. I think the exsiting of both ReasonNativeProject and "INSTALLING REASON AND MERLIN" part can be a little bit confusing, because they do some same installation work and they both serve as a getting start guide for "native" reason development.

Thanks for the feedback. You're right, the native workflow section was a bit confusing. I've re-arranged them and removed some overlap.

I'm not sure what's wrong with your thing. I've found https://github.com/ocaml/ocamlbuild/issues/120 and http://stackoverflow.com/questions/35222842/bizare-errors-and-im-unable-to-build-ocaml-programs-on-windows. Curious: go you have the Xcode command-line tools installed?

I do have Xcode command-line tools installed. I will go to the given links to learn more about the issue later. The re-arranged documentation seems much clearer to me.

Since the ReasonNativeProject is working for me, it's time dive into Reason land! Thanks for your quick response and everything you guys have done to create a refreshing development experience.

Yeah sorry, I was shooting in the dark. Our current native workflow is a bit experimental. I see that you're on Discord; don't hesitate to reach out!

Also, just in case you need it: https://github.com/chenglou/intro-to-reason-compilation

Sure!

Sorry to bug you again, but this is really weird. I just pulled the master of ReasonNativeProject. I ran opam pin add -y ReasonNativeProject . and make build. And the same error appeared:

cp pkg/META.in pkg/META
ocamlbuild -package topkg pkg/build.native
./build.native build
ocamlfind ocamldep -modules -pp 'refmt --print binary' -impl src/test.re | tee src/test.re.depends > src/test.ml.depends
ocamlfind ocamlc -c -I src -pp 'refmt --print binary' -o src/test.cmo -intf-suffix .rei -impl src/test.re
ocamlfind ocamlopt -c -I src -pp 'refmt --print binary' -o src/test.cmx -intf-suffix .rei -impl src/test.re
Failure: Link list cannot be empty.

trying to repo now

@irrigator what's your fullpath to the example project?

Please apply the following diff to the example project:
image

Then try it again:

~/o/ReasonNativeProject (master|✚1) $ make build
cp pkg/META.in pkg/META
ocamlbuild -package topkg pkg/build.native
Finished, 4 targets (0 cached) in 00:00:00.
./build.native build
Doing sanity checks
include directories are: [ "."; "src" ]
==> opam
opam exists in source dir -> import it
==> pkg/META
pkg/META exists in source dir -> import it
==> pkg/META
pkg/META already built
==> src/test.native
====> src/test.cmx
======> src/test.re
src/test.re exists in source dir -> import it
======> src/test.ml.depends
========> src/test.re
src/test.re already built
start rule re dependecies (%=src/test )
dyndeps: {.  .}
mid rule re dependecies (%=src/test ): cache miss: a product is not in build dir (src/test.re.depends)
ocamlfind ocamldep -modules -pp 'refmt --print binary' -impl src/test.re | tee src/test.re.depends > src/test.ml.depends
resource_changed: src/test.re.depends
resource_changed: src/test.ml.depends
end rule re dependecies (%=src/test )
======> src/test.cmi
========> src/test.rei
========> src/test.re
src/test.re already built
========> src/test.re.depends
src/test.re.depends already built
start rule re -> cmo & cmi (%=src/test )
dyndeps: {.  .}
mid rule re -> cmo & cmi (%=src/test ): cache miss: a product is not in build dir (src/test.cmo)
ocamlfind ocamlc -c -I src -pp 'refmt --print binary' -o src/test.cmo -intf-suffix .rei -impl src/test.re
resource_changed: src/test.cmo
resource_changed: src/test.cmi
end rule re -> cmo & cmi (%=src/test )
start rule re & rei -> cmx & o (%=src/test )
dyndeps: {.  .}
mid rule re & rei -> cmx & o (%=src/test ): cache miss: a product is not in build dir (src/test.cmx)
ocamlfind ocamlopt -c -I src -pp 'refmt --print binary' -o src/test.cmx -intf-suffix .rei -impl src/test.re
resource_changed: src/test.cmx
resource_changed: src/test.o
end rule re & rei -> cmx & o (%=src/test )
====> src/test.o
src/test.o already built
start rule ocaml: cmx* & o* -> native (%=src/test )
prepare_libs: "src/test.native" -> [  ]
caml_transitive_closure ~caml_obj_ext:"cmx" ~pack_mode:false
  ~used_libraries:[  ] [ "src/test.cmx" ]
packages: {.  .}
dependency_map: {::}
used_files: {. src/test.cmx .}
open_packages: [  ]
lib_index: {::}
dependencies: {::}
caml_transitive_closure: [ "src/test.cmx" ] -> [ "src/test.cmx" ]
link: [ "src/test.cmx" ] -o src/test.native
dyndeps: {.  .}
mid rule ocaml: cmx* & o* -> native (%=src/test ): cache miss: a product is not in build dir (src/test.native)
ocamlfind ocamlopt -linkpkg src/test.cmx -o src/test.native
resource_changed: src/test.native
end rule ocaml: cmx* & o* -> native (%=src/test )

Please let me know what your output is

The fullpath is ~/Code/play/ReasonNativeProject and the verbose log of make build is below:

cp pkg/META.in pkg/META
ocamlbuild -package topkg pkg/build.native
Finished, 4 targets (4 cached) in 00:00:00.
./build.native build
Doing sanity checks
include directories are: [ "."; "src" ]
==> opam
opam exists and up to date
==> pkg/META
pkg/META exists and up to date
==> pkg/META
pkg/META already built
==> src/test.native
====> src/test.cmx
======> src/test.re
src/test.re exists in source dir -> import it
======> src/test.ml.depends
========> src/test.re
src/test.re already built
start rule re dependecies (%=src/test )
dyndeps: {. .}
mid rule re dependecies (%=src/test ): cache miss: a product is not in build dir (src/test.re.depends)
ocamlfind ocamldep -modules -pp 'refmt --print binary' -impl src/test.re | tee src/test.re.depends > src/test.ml.depends
resource_changed: src/test.re.depends
resource_changed: src/test.ml.depends
end rule re dependecies (%=src/test )
======> src/test.cmi
========> src/test.rei
========> src/test.re
src/test.re already built
========> src/test.re.depends
src/test.re.depends already built
start rule re -> cmo & cmi (%=src/test )
dyndeps: {. .}
mid rule re -> cmo & cmi (%=src/test ): cache miss: a product is not in build dir (src/test.cmo)
ocamlfind ocamlc -c -I src -pp 'refmt --print binary' -o src/test.cmo -intf-suffix .rei -impl src/test.re
resource_changed: src/test.cmo
resource_changed: src/test.cmi
end rule re -> cmo & cmi (%=src/test )
start rule re & rei -> cmx & o (%=src/test )
dyndeps: {. .}
mid rule re & rei -> cmx & o (%=src/test ): cache miss: a product is not in build dir (src/test.cmx)
ocamlfind ocamlopt -c -I src -pp 'refmt --print binary' -o src/test.cmx -intf-suffix .rei -impl src/test.re
resource_changed: src/test.cmx
resource_changed: src/test.o
end rule re & rei -> cmx & o (%=src/test )
====> src/test.o
src/test.o already built
start rule ocaml: cmx* & o* -> native (%=src/test )
prepare_libs: "src/test.native" -> [ ]
caml_transitive_closure ~caml_obj_ext:"cmx" ~pack_mode:false
~used_libraries:[ ] [ "src/test.cmx" ]
packages: {. .}
dependency_map: {::}
used_files: {. src/test.cmx .}
open_packages: [ ]
lib_index: {::}
dependencies: {::}
caml_transitive_closure: [ "src/test.cmx" ] -> [ ]
Failure: Link list cannot be empty.
build.native: [ERROR] cmd ['rebuild' '-use-ocamlfind' '-I' 'src' '-verbose' '10' 'opam' 'pkg/META'
'pkg/META' 'src/test.native']: exited with 2
make: * [build] Error 1

Still debugging it on my side.

I noticed this line of output is different between ours: caml_transitive_closure: [ "src/test.cmx" ] -> [ ]

Digging into ocamlbuild, I think this line could be the issue: "https://github.com/ocaml/ocamlbuild/blob/b2d70ac96a7779abe09b2cd5bea5216e64846328/src/ocaml_dependencies.ml#L201"

I suspect in your case sys_file_exists 'src/test.cmx' returns false, sys_file_exists is defined here. Do you mind make sure _build/src/test.cmx exists after the build failure?

The test.cmx, test.native and other artifacts do exist in _build, but they seem to be the output of the last successful build. I delete them all and run make build, everything works!

The problem might be that I didn't run make clean before a make build?

@irrigator btw I've changed Test.re to lower-case test.re recently. Maybe because of FS insensitivity it bugged.

I'm closing this one as this is a transient issue and can be solved through indeed make clean. Sorry for the trouble!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kyldvs picture kyldvs  Â·  3Comments

TrakBit picture TrakBit  Â·  3Comments

cristianoc picture cristianoc  Â·  4Comments

jberdine picture jberdine  Â·  3Comments

ondrejsevcik picture ondrejsevcik  Â·  3Comments