Hive Hive
Sign in

fix(cli): stop SIGTRAP on missing session logs.txt and bare tuist invocation

GitHub issue · Closed

Metadata
Source
tuist/tuist #11230
Updated
Jun 24, 2026
Domains
CLI
Details

Resolves no tracked issue.

Two adjacent fixes for fatal traps reported by CI users on recent CLI releases.

What changed

1. withLoggerForNoora in the tuist executable target now degrades gracefully when the session log file is missing.

PR #9324 added a safe re-touch + do/catch to withLoggerForNoora in cli/Sources/TuistKit/Utils/Dependencies.swift. The tuist executable target (cli/Sources/tuist/Dependencies.swift) redeclares the same function, and Swift name resolution picked the local unguarded copy for every call from TuistCommand — so the TuistKit fix never took effect at the call site that actually fires. When the session directory disappeared mid-run (cleanup races, host workspace pruning), SimpleFileLogHandler.init threw NSCocoaErrorDomain Code=4 "The file logs.txt doesn't exist", which propagated to swift_errorInMain and trapped the CLI with SIGTRAP. PR #11083 patched the cleanup race at the SessionController layer, but did not close the call-site exposure.

This PR mirrors the TuistKit-side pattern in both the macOS and Linux variants of the executable’s withLoggerForNoora: re-touch the log path via FileSystem, and fall back to a logger-less action on failure. Also adds fileSystemDependency to tuistDependencies in Package.swift so import FileSystem resolves under SPM (Project.swift already declared it).

2. TuistService.run guards against empty arguments.

When tuist is invoked with no subcommand, parseAsRoot throws and TuistCommand.executeTask calls TuistService().run(arguments: [], …). The first line builds "tuist-\(arguments[0])", which traps with index-out-of-range before the outer catch can show the ArgumentParser help. The guard throws TuistServiceError.taskUnavailable instead so the parsing error surfaces normally.

How to test locally

For the withLoggerForNoora fix:

# In any tuist-using project workspace
tuist install &
sleep 0.1
rm -rf "$XDG_STATE_HOME/tuist/sessions/"*/logs.txt 2>/dev/null \
|| rm -rf ~/.local/state/tuist/sessions/*/logs.txt
wait

Before this change the process terminates with Fatal error: Error raised at top level: Error Domain=NSCocoaErrorDomain Code=4 "The file "logs.txt" doesn't exist.". After, the command finishes cleanly (with logging disabled for that invocation).

For the TuistService.run guard, just run tuist with no arguments — it now prints help/usage instead of trace trap.

Compile-verified via swift build --target tuist --replace-scm-with-registry and an end-to-end bundle (CLI + dynamic ProjectDescription.framework) successfully ran a --tuist-dump JIT load against the project’s own Tuist.swift.

Comments
T
tuist[bot] Jun 11, 2026

🛠️ Tuist Run Report 🛠️

Previews 📦
App Commit Open on device
Tuist bada37357
Tests 🧪
Scheme Status Cache hit rate Tests Skipped Ran Commit
TuistAcceptanceTests 0 % 0 0 0 bada37357
TuistUnitTests 0 % 662 37 625 bada37357
Builds 🔨
Scheme Status Duration Commit
TuistAcceptanceTests 6m 58s bada37357
TuistApp 3m 17s bada37357
TuistUnitTests 7m 45s bada37357
Bundles 🧰
Bundle Commit Install size Download size
Tuist bada37357 19.5 MBΔ -451.2 KB (-2.27%) 14.7 MBΔ -200.2 KB (-1.35%)
TA
tuist-atlas[bot] Jun 12, 2026

The changes from this pull request are now available in version 4.199.1. Update to get the fixes for SIGTRAP on missing session logs.txt and bare tuist invocation.