Skip to content

Conversation

ASRagab
Copy link
Contributor

@ASRagab ASRagab commented Mar 28, 2024

If you follow the current instructions for creating a hello world project, when running dune exec hello you receive the following error:

Error: I cannot find the root of the current workspace/project.
If you would like to create a new dune project, you can type:

    dune init project NAME

Otherwise, please make sure to run dune inside an existing project or
workspace. For more information about how dune identifies the root of the
current workspace/project, please refer to
https://dune.readthedocs.io/en/stable/usage.html#finding-the-root

I believe this has to do with the changed behavior of dune exec/build which will not create a dune-project for you anymore if it is missing.

After creating the file with the minimum required contents as seen on dune.build, the next error received is:

File "dune", line 1, characters 0-47:
1 | (executable
2 |  (name hello)
3 |  (public_name hello))
Error: The current project defines some public elements, but no opam packages
are defined.
Please add a <package>.opam file at the project root so that these elements
are installed into it.

If you dutifully follow the suggestion and add an empty hello.opam the project will build the exe and execute the binary

❯ dune build hello.exe
❯ dune exec hello
Hello, World!

It is of course possible that I missed a step, but this seems to be the minimum viable project, i.e as opposed to doing dune init proj ...

Copy link

@gabriel-bezerra gabriel-bezerra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes worked for me when trying to follow the installation guide.

@davesnx
Copy link
Member

davesnx commented Oct 10, 2024

Thanks!

@davesnx davesnx merged commit 3646db5 into reasonml:source Oct 10, 2024
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

Successfully merging this pull request may close these issues.

3 participants