我是OCaml新手,我跟随教程建立了一个开发环境。然后,我用沙丘和OCaml尝试了这个OCaml示例,但是屏蔽了以下错误:
$ dune init exe helloworld
Success: initialized executable component named helloworld
$ dune build
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目录结构:
.
├── _build
│ └── log
├── dune
└── helloworld.ml沙丘: 3.0.2
最高法院: 4.11.1
发布于 2022-02-21 08:00:35
您可以通过在项目根目录中添加一个dune-project文件来解决这种情况:
(lang dune 3.0)但是,根据文档,dune init exec不是用于创建项目:它只为现有项目中的可执行组件创建样板(有关详细信息,请参阅dune init --help或沙丘手册 )。
若要初始化项目,应运行
dune init proj helloworld这还将生成一个模板dune-project文件以及推荐的项目文件结构。
注意:在沙丘3.0之前,如果没有文件,会为您创建该文件:
❯ dune init exe helloworld
Success: initialized executable component named helloworld
❯ ls
_build dune helloworld.ml
❯ dune build
Info: Creating file dune-project with this contents:
| (lang dune 2.9)
❯ ls
_build dune dune-project helloworld.ml但是,从沙丘3.0开始,在项目中找不到时,不会自动添加dune-project。
https://stackoverflow.com/questions/71202746
复制相似问题