Skip to content

fix: resolve nlohmann_json target conflict in Docker build - #8996

Merged
timosachsenberg merged 2 commits into
developfrom
fix/docker-nlohmann-json-conflict
Mar 25, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
fix/docker-nlohmann-json-conflict

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fix Docker container build failure caused by Arrow 23's CMake config importing nlohmann_json as a system target, which then conflicts with OpenMS's bundled copy trying to add_library(nlohmann_json ...)
  • Detect pre-existing imported target and reuse it instead of building the bundled copy
  • Remove stale superpowers plan/spec documents

Root cause

The deploy-docker CI job installs Arrow 23 via apt, which pulls in system nlohmann_json (3.10.5). Arrow's ArrowConfig.cmake creates an imported nlohmann_json::nlohmann_json target. Later, src/openms/extern/nlohmann_json/CMakeLists.txt:106 calls add_library(nlohmann_json INTERFACE) which fails because the target name is already taken.

Test plan

  • deploy-docker CI job passes
  • Regular CMake builds (without system Arrow/nlohmann_json) still use the bundled copy
  • USE_EXTERNAL_JSON=ON path still works as before

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Removed internal planning and design specification documents.
  • Chores

    • Updated CMake build configuration to optimize JSON library dependency handling during the build process.

Arrow 23's CMake config imports nlohmann_json as a system target.
When USE_EXTERNAL_JSON is OFF (default), the bundled copy then fails
with "add_library cannot create target because an imported target with
the same name already exists". Detect the pre-existing imported target
and reuse it instead of building the bundled copy.

Also remove superpowers plan/spec documents.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 47d1a74b-5e2c-48b7-962d-4add3eb91bf4

📥 Commits

Reviewing files that changed from the base of the PR and between 000f262 and 606ae54.

📒 Files selected for processing (1)
  • cmake/cmake_findExternalLibs.cmake

📝 Walkthrough

Walkthrough

This PR removes documentation for a planned Biosaur2 seeding feature in ProteomicsLFQ (plan and design specification files) and adds a CMake guard to prevent duplicate nlohmann_json target imports when Arrow/Parquet packages are configured.

Changes

Cohort / File(s) Summary
Documentation Removals
docs/superpowers/plans/2026-03-24-biosaur2-seeding-in-proteomicslfq.md, docs/superpowers/specs/2026-03-24-biosaur2-seeding-in-proteomicslfq-design.md
Deleted plan and design specification documents describing user-selectable seeding algorithm parameter (Seeding:algorithm) implementation for ProteomicsLFQ with Biosaur2Algorithm support.
CMake Configuration
cmake/cmake_findExternalLibs.cmake
Added guard to detect and force-set USE_EXTERNAL_JSON to ON when Arrow/Parquet targets are imported with nlohmann_json already available, preventing duplicate vendored target creation.

Possibly related PRs

Poem

🐰 Plans and specs drift away like clouds,
While CMake guards stand tall and proud,
No duplicate targets shall appear,
The Arrow flies with json clear!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: resolve nlohmann_json target conflict in Docker build' accurately describes the primary change—fixing a CMake build conflict where Arrow brings in a system nlohmann_json that conflicts with the bundled copy, which is addressed by detecting and reusing the pre-existing imported target.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/docker-nlohmann-json-conflict

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/openms/extern/CMakeLists.txt`:
- Around line 41-44: The conflict-avoidance logic using USE_EXTERNAL_JSON and
TARGET nlohmann_json::nlohmann_json must not live inside the vendored
CMakeLists; remove or revert the if-block from the vendored extern CMake file
and instead set or derive the USE_EXTERNAL_JSON variable and call
find_package(nlohmann_json REQUIRED GLOBAL) from a non-vendored CMake entry
point (e.g., the top-level project CMake before including the extern subtree) so
the vendored code remains untouched while preserving the same resolution
behavior for nlohmann_json::nlohmann_json.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 58045e69-f7a9-4383-a68d-6cec628709c7

📥 Commits

Reviewing files that changed from the base of the PR and between 573199f and 000f262.

📒 Files selected for processing (3)
  • docs/superpowers/plans/2026-03-24-biosaur2-seeding-in-proteomicslfq.md
  • docs/superpowers/specs/2026-03-24-biosaur2-seeding-in-proteomicslfq-design.md
  • src/openms/extern/CMakeLists.txt
💤 Files with no reviewable changes (2)
  • docs/superpowers/plans/2026-03-24-biosaur2-seeding-in-proteomicslfq.md
  • docs/superpowers/specs/2026-03-24-biosaur2-seeding-in-proteomicslfq-design.md

Comment thread src/openms/extern/CMakeLists.txt Resolved
…Libs

Move the TARGET nlohmann_json::nlohmann_json detection out of the
vendored extern/CMakeLists.txt and into cmake/cmake_findExternalLibs.cmake
right after find_package(Arrow). When Arrow imports nlohmann_json as a
transitive dependency, USE_EXTERNAL_JSON is forced ON so the vendored
code takes its existing external-library path without modification.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@jpfeuffer

Copy link
Copy Markdown
Contributor

Yes. Any other deps that we could reuse for the ones we build inside our own CMake?

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

did not see any

@timosachsenberg
timosachsenberg merged commit fdf7aba into develop Mar 25, 2026
19 checks passed
@timosachsenberg
timosachsenberg deleted the fix/docker-nlohmann-json-conflict branch March 25, 2026 14:45
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.

2 participants