fix: Termux IPC compatibility and config model sync robustness#57
Open
qris-plus wants to merge 1 commit into
Open
fix: Termux IPC compatibility and config model sync robustness#57qris-plus wants to merge 1 commit into
qris-plus wants to merge 1 commit into
Conversation
Two fixes:
1. IPC socket fallback (crates/runtime/src/ipc.rs):
On Termux (Android), /tmp is owned by shell:shell and not writable
by the Termux user. Added a fallback chain for Unix domain socket
directories: $XDG_RUNTIME_DIR → $TMPDIR → $TMP → $PREFIX/tmp
→ /tmp. This ensures nca works out-of-the-box on Termux.
2. Config model sync (crates/common/src/config.rs):
- Added a safety net in merge() that syncs default_model from the
active provider's model even when neither provider nor model
section changed but the values diverged.
- Added two tests:
* merge_syncs_default_model_from_provider_model: verifies that
setting [provider.openai] model = "..." propagates to
default_model without needing explicit [model] default_model.
* merge_syncs_default_model_when_no_provider_section: verifies
that setting [model] default_model updates the active
provider's model.
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/runtime/src/ipc.rs">
<violation number="1" location="crates/runtime/src/ipc.rs:22">
P2: Empty environment variable values accepted as valid runtime directories, causing relative socket paths and defeating the fallback chain</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| /// 3. `$TMP` (general fallback) | ||
| /// 4. `$PREFIX/tmp` (Termux-specific, e.g. `/data/data/com.termux/files/usr/tmp`) | ||
| /// 5. `/tmp` (POSIX default, may not be writable on Android/Termux) | ||
| fn resolve_runtime_dir() -> PathBuf { |
There was a problem hiding this comment.
P2: Empty environment variable values accepted as valid runtime directories, causing relative socket paths and defeating the fallback chain
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/runtime/src/ipc.rs, line 22:
<comment>Empty environment variable values accepted as valid runtime directories, causing relative socket paths and defeating the fallback chain</comment>
<file context>
@@ -11,10 +11,31 @@ pub struct IpcServer {
+ /// 3. `$TMP` (general fallback)
+ /// 4. `$PREFIX/tmp` (Termux-specific, e.g. `/data/data/com.termux/files/usr/tmp`)
+ /// 5. `/tmp` (POSIX default, may not be writable on Android/Termux)
+ fn resolve_runtime_dir() -> PathBuf {
+ std::env::var("XDG_RUNTIME_DIR")
+ .ok()
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes addressing issues discovered when running nca on Termux (Android/aarch64).
Fix 1: IPC socket fallback — Termux compatibility
Problem: On Termux,
/tmpis owned byshell:shellwith restricted permissions — the Termux user cannot write to it. nca's IPC socket directory falls back to/tmpwhen$XDG_RUNTIME_DIRis unset, causingPermission denied (os error 13).Fix: Add a fallback chain for Unix domain socket directories:
$XDG_RUNTIME_DIR(XDG Base Directory)$TMPDIR(macOS / BSD / Termux convention)$TMP(general fallback)$PREFIX/tmp(Termux-specific, e.g./data/data/com.termux/files/usr/tmp)/tmp(POSIX default)Extracted into a dedicated
resolve_runtime_dir()method for clarity.Files changed:
crates/runtime/src/ipc.rsFix 2: Config model sync robustness
Problem: When a user configures
[provider.openai] model = \"...\"without an explicit[model] default_model, the model may not propagate to the activedefault_modelin all edge cases.Fix:
merge()that re-syncsdefault_modelfrom the active provider's model when the two values diverge (even if neither the provider section nor the model section was explicitly changed in the partial).merge_syncs_default_model_from_provider_model: verifies that[provider.openai] modelcorrectly propagates todefault_modelwithout needing[model] default_model.merge_syncs_default_model_when_no_provider_section: verifies that setting[model] default_modelalso updates the active provider's model.Files changed:
crates/common/src/config.rsTesting
Summary by cubic
Fixes IPC socket directory resolution to work on Termux and makes model config syncing more reliable. Ensures the active provider’s model and
default_modelstay in sync.$XDG_RUNTIME_DIR → $TMPDIR → $TMP → $PREFIX/tmp → /tmpto avoid permission errors on/tmp.model.default_modelsynced with the active provider’s model, including a safety net for edge cases. Added tests for provider→default and default→provider sync.Written for commit 9ad647e. Summary will update on new commits.