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

ERROR Failed attempting to build your project with Dune #91

Open
bentxt opened this issue Mar 6, 2024 · 2 comments
Open

ERROR Failed attempting to build your project with Dune #91

bentxt opened this issue Mar 6, 2024 · 2 comments
Labels
needs reporter action The issue or PR is waiting on action from the reporter/author

Comments

@bentxt
Copy link

bentxt commented Mar 6, 2024

npm create melange-app@latest

 ERROR

    Failed attempting to build your project with Dune
    The scaffolding process failed while running `opam exec -- dune build`.
    Dune is OCaml and ReasonML's build tool.
    Please try `cd`ing into the project directory created by
    `create-melange-app` and running the following commands:

    eval $(opam env)
    dune build
[...]
    `opam switch list`,
    `dune build`,
    `cat dune-project`, and `cat dune`

eval $(opam env)

dune build

ben@moonraker meli $ dune build
File "dune", line 32, characters 0-349:
32 | (rule
33 |   (alias webpack)
34 |    (targets (dir dist))
....
41 |               --entry ./output/src/App.mjs && cp ./public/index.html dist/index.html"))
42 |    (mode
43 |      (promote (until-clean))))
/bin/sh: ../../node_modules/.bin/webpack: No such file or directory

opam switch list

ben@moonraker meli 1 $ opam switch list
#   switch                                         compiler                    description
    /Users/ben/build/flow/flow                     ocaml-base-compiler.4.14.0  /Users/ben/build/flow/flow
    /Users/ben/hack/melange/melange-opam-template  ocaml-base-compiler.5.1.0   /Users/ben/hack/melange/melange-opam-template
->  /Users/ben/hack/melange/meli/meli              ocaml-base-compiler.5.1.1   /Users/ben/hack/melange/meli/meli
    /Users/ben/sources/nox/nox                     ocaml-base-compiler.5.0.0   /Users/ben/sources/nox/nox
    default                                        ocaml.5.1.1                 default

[NOTE] Current switch has been selected based on the current directory.
       The current global system switch is default.

dune build

ben@moonraker meli $ dune build
File "dune", line 32, characters 0-349:
32 | (rule
33 |   (alias webpack)
34 |    (targets (dir dist))
....
41 |               --entry ./output/src/App.mjs && cp ./public/index.html dist/index.html"))
42 |    (mode
43 |      (promote (until-clean))))
/bin/sh: ../../node_modules/.bin/webpack: No such file or directory

dune file

 $ perl -nle '/^;/ || print' dune

(dirs :standard \ node_modules)

(alias
  (name all)
  (deps
     (alias_rec webpack)))


(rule
  (alias webpack)
   (targets (dir dist))
   (deps
     (alias_rec meli)
     (:webpack ./webpack.config.js)
     (source_tree ./public))
   (action
    (system "../../node_modules/.bin/webpack --mode production \
              --entry ./output/src/App.mjs && cp ./public/index.html dist/index.html"))
   (mode
     (promote (until-clean))))


  (melange.emit
   (target output)
   (alias meli)
   (libraries app)
   (module_systems (es6 mjs)))

dune-project file

$ perl -nle '/^;/ || print' dune-project
(lang dune 3.14)


(using melange 0.1)

(using directory-targets 0.1)

(name meli)

(generate_opam_files true)

(source
 (github your-username/meli))

(authors "Your Name <[email protected]>")

(maintainers "Your Name <[email protected]>")

(license MIT)

(documentation https://github.com/your-username/meli)

(package
 (name meli)
 (synopsis "Enter a synopsis of your app here")
 (description "Enter a description of your app here")
 (allow_empty)
 (depends
  (dune (>= 3.14))
  (melange (>= 3.0.0-51))
  (ocaml (>= 5.1.1))
  opam-check-npm-deps
  ppx_deriving
  (reason (>= 3.11.0))
)
 (tags
  (reasonml, ocaml, melange)))
@dmmulroy
Copy link
Owner

dmmulroy commented Mar 6, 2024

By chance did you opt out of running npm install? Could you share the package.json that was generated?

@dmmulroy dmmulroy added the needs reporter action The issue or PR is waiting on action from the reporter/author label Mar 21, 2024
@irfanns
Copy link

irfanns commented Jul 1, 2024

Hi, I got this issue too with both vite and webpack. Seems there's an issue with dune build getting to the node_modules/ subfolder in the project root, as the dune build seems to happen two folders upward of the created project?

Already ran npm install, npm i vite (for the vite project) and also npm i webpack (for the webpack project)

Thank you!

-- hi, after debugging locally, I think the problem was with opam switches. I have set the global opam switch to a top folder location and it seemed to have broke dune build. After deleting all local opam switches and trying again, it works now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reporter action The issue or PR is waiting on action from the reporter/author
Projects
None yet
Development

No branches or pull requests

3 participants