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

Flag to disable merlin generation? #257

Closed
timbertson opened this issue Sep 17, 2017 · 8 comments
Closed

Flag to disable merlin generation? #257

timbertson opened this issue Sep 17, 2017 · 8 comments

Comments

@timbertson
Copy link
Contributor

I'm trying to build just the opam-installer binary from the opam repo, because I'd like to have this tool available without having all of opam installed.

So I installed the deps which are required for this specific executable, but not the full set of deps that the rest of opam needs.

But jbuilder complains:

$ jbuilder build src/tools/opam_installer.exe --debug-dependency-path
Error: External library "cudf" not found.
-> required by "src/solver/jbuild (context default)"
Hint: try: jbuilder external-lib-deps --missing src/tools/opam_installer.exe
Dependency path:
    _build/default/src/tools/opam_installer.exe
--> _build/default/src/tools/opam_installer.cmx
--> _build/default/src/tools/.merlin-exists
--> src/tools/.merlin
--> _build/default/src/tools/opam_admin_top.requires.sexp
--> _build/default/src/client/opam_client.requires.sexp
--> _build/default/src/solver/opam_solver.requires.sexp

I've verified that the .merlin generation is what's causing the additional dependency, by doing:

$ touch src/tools/.merlin-exists

..after which the build completes fine. So evidently merlin generation is pulling in additional libraries in the workspace (my guess: it depends on every build target in src/tools, which includes opam-admin which depends on opam-client, etc.).

I'd like to split out an opam-installer package, so for this purpose .merlin files are useless (I'll never point an editor at this workspace, I'm just building it).

Is there some way to disable .merlin file generation? Ideally with a commandline flag or environment variable, since editing a workspace config file is an awkward thing to do from an opam package build command.

@timbertson
Copy link
Contributor Author

FWIW the docs say:

(merlin) instructs Jbuilder to generate the .merlin files from this context. There can be at most one build context with a (merlin) field. If no build context has a (merlin) field, the selected context for merlin will be (context default) if present. Otherwise Jbuilder won’t generate .merlin files.

I found this a little confusing. I eventually figured out it means that merlin files won't be generated if you lack a default context, but I initially thought you could disable merlin files by explicitly listing a default context with no merlin field.

@ghost
Copy link

ghost commented Sep 22, 2017

Indeed, I tried to improve the doc.

TBH, I'm not particularly excited by allowing to disable the generation of .merlin files. The problem is the same as the one described in #230, and I'd prefer to work towards fixing the underlying issue. As a temporary workaround, you can simply put the opam-installer tool in its own directory.

@rgrinberg
Copy link
Member

I will close this as we'd like to move away from generating .merlin files altogether. Jeremie improved the docs so there's really not much else to do here.

@emillon
Copy link
Collaborator

emillon commented Apr 5, 2018

I was looking to do something similar to support jbuilder and ocamlbuild at the same time for a transition period, and what I ended up doing is define a default context with (merlin false), ie a jbuild-workspace file with the following contents:

(context
  (opam
    (switch 4.06.1)
    (merlin false)
    )
  )

@mjambon
Copy link

mjambon commented May 4, 2018

For the record, I'm using the following jbuild-workspace file.

(context
  (opam
    (name default)
    (switch 4.05.0)
    (merlin false)
  )
)

Without (name default), I was getting the following error when running jbuilder utop DIR:

Error: Context "default" not found!

Note that I don't really understand what I'm doing here. I tested this with jbuilder 1.0+beta19.1 and 1.0+beta20.

Edit: Another way is to tell jbuilder explicitly which context to use, e.g. jbuilder utop DIR --context=4.05.5.

@ghost
Copy link

ghost commented May 8, 2018

Is disabling the generation of the merlin file required to workaround the original issue or for another reason? The original issue, where dune would fail in some cases should be fixed since beta19.

@emillon
Copy link
Collaborator

emillon commented May 14, 2018

Can't speak for others but here's my use case. We have an ocamlbuild project (with several executables and libraries) with a custom written .merlin that's checked in git.

Porting to dune "at once" is not really easy, so for a transition period the project can be built with either ocamlbuild or dune. Since dune is so fast, we tend to use it in development, while our CI and production binaries continue to use ocamlbuild. That's obviously not ideal but as a temporary state it's OK.

The problem is that while developing, dune changes .merlin and it gets picked up by git. While there are some ocamlbuild users we'd like to keep .merlin checked in. Adding the generated .merlin files could be a solution, but they contain absolute paths so it's not possible.

Hopes that give some context. Thanks!

@ghost
Copy link

ghost commented May 14, 2018

Ok, that makes sense yes. I suppose we can allow (disable merlin) or (without merlin) in the dune-project file to disable merlin for a project.

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

No branches or pull requests

4 participants