Skip to content

fix: handle unwritable $HOME in UpdateCheck gracefully - #9075

Merged
timosachsenberg merged 6 commits into
OpenMS:developfrom
ypriverol:fix/updatecheck-crash-unwritable-home
Apr 3, 2026
Merged

timosachsenberg merged 6 commits into
OpenMS:developfrom
ypriverol:fix/updatecheck-crash-unwritable-home

Conversation

@ypriverol

@ypriverol ypriverol commented Apr 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix crash in UpdateCheck::run() when $HOME/.config/OpenMS cannot be created (e.g., in containers where $HOME=/).

Problem

All TOPP tools crash with exit code 134 when running in container environments where $HOME points to a non-writable directory:

terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
  what():  filesystem error: cannot create directories: Permission denied [//.config/OpenMS]

This is caused by UpdateCheck.cpp line 86 using the throwing overload of std::filesystem::create_directories() with no error handling.

Fix

Use the std::error_code overload (consistent with File.cpp lines 241, 316) and skip the update check gracefully when the config directory cannot be created.

std::error_code ec;
fs::create_directories(to_path(config_path), ec);
if (ec)
{
  OPENMS_LOG_WARN << "Warning: Could not create config directory '"
                  << config_path << "': " << ec.message()
                  << ". Skipping update check." << std::endl;
  return;
}

The update check is optional functionality — a failure to write the version file should never crash the tool.

Impact

This fix unblocks CI pipelines for downstream tools (e.g., quantms, bigbio/quantms#691) that run OpenMS in containerized environments.

Fixes #9074

Test plan

  • Existing tests pass (no behavioral change when $HOME is writable)
  • Tools run successfully in containers where $HOME=/ (currently crashes)
  • Warning message is logged when config directory cannot be created

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Update-check now fails gracefully when it cannot prepare the user config location, emitting a clear warning and stopping further update logic to avoid errors.
  • Chores
    • Container/runtime environment adjusted so tools run with a writable home/config location, preventing failures when writing user config files.

UpdateCheck::run() calls fs::create_directories() with the throwing
overload to create $HOME/.config/OpenMS. In container environments
where $HOME=/ (not writable), this crashes all TOPP tools with:

  terminate called after throwing an instance of
  'std::filesystem::filesystem_error': cannot create directories:
  Permission denied [//.config/OpenMS]

Use the std::error_code overload (consistent with File.cpp lines
241, 316) and skip the update check gracefully when the config
directory cannot be created.

Fixes OpenMS#9074

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

coderabbitai Bot commented Apr 3, 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: aa4e6c90-a3b8-4379-a95f-6813a8fa7904

📥 Commits

Reviewing files that changed from the base of the PR and between ae36cc3 and a2cd823.

📒 Files selected for processing (1)
  • dockerfiles/Dockerfile
✅ Files skipped from review due to trivial changes (1)
  • dockerfiles/Dockerfile

📝 Walkthrough

Walkthrough

UpdateCheck::run now uses the non-throwing std::filesystem::create_directories overload and returns early with a logged warning if directory creation fails. The Docker tools runtime stage creates a writable /app and sets HOME=/app, affecting where tools write user/config data.

Changes

Cohort / File(s) Summary
Update check filesystem handling
src/openms/source/SYSTEM/UpdateCheck.cpp
Use non-throwing create_directories(..., std::error_code&); on failure log a warning containing config_path and ec.message() and return early (skip creating .ver and the network update check).
Docker runtime HOME setup
dockerfiles/Dockerfile
Ensure writable /app (mkdir -p /app && chmod -R 755 /app) and set ENV HOME=/app in the tools stage so subsequent stages/tools use /app for $HOME-based config paths.

Possibly related issues

Poem

🐰 I nudged the folders, found a snag,
I logged the hiccup, closed the bag.
A tiny /app became my nest,
No sudden throws to break our quest.
Hop on — configs safe, and tests can rest. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: handle unwritable $HOME in UpdateCheck gracefully' accurately describes the main change: adding graceful error handling to UpdateCheck when the configuration directory cannot be created due to unwritable $HOME.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

🧹 Nitpick comments (1)
src/openms/source/SYSTEM/UpdateCheck.cpp (1)

90-92: Use \n instead of std::endl in the new warning log.

Line 92 introduces std::endl; please switch to '\n' to match project C++ performance/style rules.

Proposed patch
-        OPENMS_LOG_WARN << "Warning: Could not create config directory '"
-                        << config_path << "': " << ec.message()
-                        << ". Skipping update check." << std::endl;
+        OPENMS_LOG_WARN << "Warning: Could not create config directory '"
+                        << config_path << "': " << ec.message()
+                        << ". Skipping update check.\n";

As per coding guidelines: "Avoid std::endl; prefer \n for performance in C++".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openms/source/SYSTEM/UpdateCheck.cpp` around lines 90 - 92, Replace the
use of std::endl in the warning logging statement so it uses '\n' instead;
specifically update the OPENMS_LOG_WARN call that prints config_path and
ec.message() to terminate with '\n' instead of std::endl to follow project C++
style/performance rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/openms/source/SYSTEM/UpdateCheck.cpp`:
- Around line 90-92: Replace the use of std::endl in the warning logging
statement so it uses '\n' instead; specifically update the OPENMS_LOG_WARN call
that prints config_path and ec.message() to terminate with '\n' instead of
std::endl to follow project C++ style/performance rules.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f048cca-6b58-44ca-b6a3-f54dd3b2b271

📥 Commits

Reviewing files that changed from the base of the PR and between c876742 and c493093.

📒 Files selected for processing (1)
  • src/openms/source/SYSTEM/UpdateCheck.cpp

ypriverol and others added 4 commits April 3, 2026 09:50
…Check

Two complementary fixes for the crash when $HOME is not writable:

1. dockerfiles/Dockerfile: Set ENV HOME=/tmp in the tools-thirdparty
   stage so containers always have a writable home directory for
   config files (.config/OpenMS/*.ver).

2. src/openms/source/SYSTEM/UpdateCheck.cpp: Use the non-throwing
   std::error_code overload of create_directories (consistent with
   File.cpp) and skip the update check gracefully when the config
   directory cannot be created. This provides defense-in-depth for
   environments where $HOME is overridden to a non-writable path.

Fixes OpenMS#9074

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Follow the pattern from quantms-rescoring: create a dedicated writable
directory and set HOME to it, rather than using /tmp. This ensures
.config/OpenMS and other home-relative paths work correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Comment thread dockerfiles/Dockerfile Resolved
Julianus noted the HOME setting should be in the tools stage (not just
tools-thirdparty) since the tools image is also published separately.
Docker ENV directives propagate through FROM inheritance, so setting it
in tools covers tools, tools-thirdparty, and test stages.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@ypriverol
ypriverol requested a review from jpfeuffer April 3, 2026 10:00
@timosachsenberg
timosachsenberg merged commit b57ae6c into OpenMS:develop Apr 3, 2026
38 checks passed
github-actions Bot pushed a commit that referenced this pull request Apr 4, 2026
Add two missing changelog entries for the OpenMS 3.6.0 under-development section:

- General: Fix UpdateCheck crash when $HOME is not writable in containers (#9075)
- TOPP tools / MSstatsConverter: new -remove_shared_peptides parameter (#9068)

Co-authored-by: Copilot <[email protected]>
timosachsenberg added a commit that referenced this pull request Apr 4, 2026
Add two missing changelog entries for the OpenMS 3.6.0 under-development section:

- General: Fix UpdateCheck crash when $HOME is not writable in containers (#9075)
- TOPP tools / MSstatsConverter: new -remove_shared_peptides parameter (#9068)

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Timo Sachsenberg <[email protected]>
@timosachsenberg timosachsenberg mentioned this pull request Jun 8, 2026
timosachsenberg added a commit that referenced this pull request Jul 9, 2026
… external CMakeLists to LF

- Remove external tracker/issue references (#9460 §1, #9452, #9204, #9075, Lxx)
  from added test comments; comments now describe the durable behavior under test.
- Normalize src/tests/external/CMakeLists.txt to LF (matches .gitattributes eol=lf),
  which also clears the trailing-whitespace (CR) that git diff --check flagged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
timosachsenberg added a commit that referenced this pull request Jul 10, 2026
…only config, downstream Qt contract (#9460) (#9603)

* [TEST] Infrastructure (§1): non-ASCII paths, exit-code mapping, read-only config, downstream Qt contract (#9460)

Close the remaining §1 [AUTO] gaps of the OpenMS 3.6.0 pre-release testing plan (#9460). Tests only.

- PathUtils_test: Windows-only UNC + ANSI-codepage to_path() cases under #ifdef _WIN32 (L35).
- TOPP FileConverter: read AND write through a non-ASCII (UTF-8) path, materialized at test time
  via `cmake -E copy` (the permanent #9452 regression) (L37).
- File_test: pin the "siblings only, no PATH fallback" contract of findSiblingTOPPExecutable
  (its TODO / #9204) plus a negative findExecutable case (L40).
- THIRDPARTY: assert a present-but-failing external program returns EXTERNAL_PROGRAM_ERROR (9),
  distinct from the EXTERNAL_PROGRAM_NOTFOUND (14) of a missing binary (L41).
- UpdateCheck_test (new): an unwritable config dir logs a warning and returns gracefully -- no
  network request, no crash (the $HOME-not-writable fix #9075) (L45).
- external/: a second downstream target that finds Qt6 itself and links Qt6::Core, proving
  OpenMS exports no transitive Qt6 (L56).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* [TEST] Make CometAdapter failing-executable test portable

* [TEST] Address review: drop tracker IDs from test comments, normalize external CMakeLists to LF

- Remove external tracker/issue references (#9460 §1, #9452, #9204, #9075, Lxx)
  from added test comments; comments now describe the durable behavior under test.
- Normalize src/tests/external/CMakeLists.txt to LF (matches .gitattributes eol=lf),
  which also clears the trailing-whitespace (CR) that git diff --check flagged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

OpenMS tools crash when $HOME/.config is not writable

3 participants