首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OCaml:运行“沙丘init exec`”后的沙丘构建错误

OCaml:运行“沙丘init exec`”后的沙丘构建错误
EN

Stack Overflow用户
提问于 2022-02-21 07:42:53
回答 1查看 916关注 0票数 0

我是OCaml新手,我跟随教程建立了一个开发环境。然后,我用沙丘和OCaml尝试了这个OCaml示例,但是屏蔽了以下错误:

代码语言:javascript
复制
$ 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

目录结构:

代码语言:javascript
复制
.
├── _build
│   └── log
├── dune
└── helloworld.ml

沙丘: 3.0.2

最高法院: 4.11.1

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-21 08:00:35

您可以通过在项目根目录中添加一个dune-project文件来解决这种情况:

代码语言:javascript
复制
(lang dune 3.0)

但是,根据文档,dune init exec不是用于创建项目:它只为现有项目中的可执行组件创建样板(有关详细信息,请参阅dune init --help沙丘手册 )。

若要初始化项目,应运行

代码语言:javascript
复制
dune init proj helloworld

这还将生成一个模板dune-project文件以及推荐的项目文件结构。

注意:在沙丘3.0之前,如果没有文件,会为您创建该文件:

代码语言:javascript
复制
❯ 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

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71202746

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档