Skip to content

fix: only generate @ocaml-index alias for merlin-enabled contexts#14137

Merged
rgrinberg merged 2 commits intoocaml:mainfrom
robinbb:robinbb-fix-ocaml-index-builds-too-much-12007
Apr 11, 2026
Merged

fix: only generate @ocaml-index alias for merlin-enabled contexts#14137
rgrinberg merged 2 commits intoocaml:mainfrom
robinbb:robinbb-fix-ocaml-index-builds-too-much-12007

Conversation

@robinbb
Copy link
Copy Markdown
Collaborator

@robinbb robinbb commented Apr 11, 2026

Summary

Partially addresses #12007.

@ocaml-index was generating indexing rules for all contexts, including alternative contexts where some libraries may be disabled by enabled_if. This caused build errors when a stanza in an alt context depended on a library only available in the default context:

Error: Library "defaultlib" in _build/alt/defaultlib is hidden (unsatisfied
'enabled_if').
-> required by _build/alt/.main.eobjs/cctx.ocaml-index
-> required by alias ocaml-index (context alt)

The fix guards Ocaml_index.project_rule with Context.merlin, so the @ocaml-index alias is only created for the context that has merlin support enabled (typically the default context). This matches the intent of the indexing feature, which exists to support editor tooling in the primary development context.

The second part of #12007 (indexing unreferenced files not linked by any stanza) is not addressed here, as it shares a root cause with #9724 and requires deeper changes to how context_indexes collects stanzas.

@robinbb robinbb force-pushed the robinbb-fix-ocaml-index-builds-too-much-12007 branch 2 times, most recently from cede35d to cf1865b Compare April 11, 2026 04:01
@Alizter Alizter requested review from rgrinberg and voodoos April 11, 2026 07:19
Copy link
Copy Markdown
Member

@rgrinberg rgrinberg left a comment

Choose a reason for hiding this comment

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

A change log entry would be appropriate

Copy link
Copy Markdown
Collaborator

@voodoos voodoos left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a small style nitpick that you can ignore.

@robinbb robinbb force-pushed the robinbb-fix-ocaml-index-builds-too-much-12007 branch 2 times, most recently from b4035d4 to 126f418 Compare April 11, 2026 13:36
robinbb added 2 commits April 11, 2026 09:46
@ocaml-index indexes stanzas in all contexts, including alternative
contexts where some libraries may be disabled. This causes errors
when a stanza in an alt context depends on a library only enabled in
the default context.

Test 1 shows the failure: @ocaml-index errors trying to index the
alt context where defaultlib is hidden by enabled_if.

Test 2 confirms that (enabled_if false) libraries are already
correctly excluded from indexing within a single context.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
…aml#12007)

@ocaml-index was generating indexing rules for all contexts, including
alternative contexts where some libraries may be disabled. This caused
errors when a stanza in an alt context depended on a library only
available in the default context.

Fix by guarding project_rule with Context.merlin, so the @ocaml-index
alias is only created for the context that has merlin support enabled
(typically the default context).

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-fix-ocaml-index-builds-too-much-12007 branch from 126f418 to fe71a78 Compare April 11, 2026 13:46
@rgrinberg rgrinberg merged commit b70feda into ocaml:main Apr 11, 2026
21 of 22 checks passed
@robinbb robinbb deleted the robinbb-fix-ocaml-index-builds-too-much-12007 branch April 11, 2026 20:56
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