{"record":{"id":"6fb7d885b7e6e11e","repo":"sxyazi/yazi","slug":"no-yazi-id-environment-variable-found","errorCode":null,"errorMessage":"No `YAZI_ID` environment variable found.","messagePattern":"No `YAZI_ID` environment variable found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-cli/src/args.rs","lineNumber":131,"sourceCode":"\tpub(super) kind: String,\n\t/// Send the message with a string body.\n\t#[arg(long)]\n\tpub(super) str:  Option<String>,\n\t/// Send the message with a JSON body.\n\t#[arg(long)]\n\tpub(super) json: Option<String>,\n\t/// Send the message as a list of strings.\n\t#[arg(long, num_args = 0..)]\n\tpub(super) list: Vec<String>,\n}\n\nimpl CommandPub {\n\t#[allow(dead_code)]\n\tpub(super) fn receiver() -> Result<Id> {\n\t\tif let Some(s) = std::env::var(\"YAZI_PID\").ok().filter(|s| !s.is_empty()) {\n\t\t\tOk(s.parse()?)\n\t\t} else {\n\t\t\tbail!(\"No `YAZI_ID` environment variable found.\")\n\t\t}\n\t}\n}\n\n#[derive(clap::Args)]\npub(super) struct CommandPubTo {\n\t/// Receiver ID.\n\t#[arg(index = 1)]\n\tpub(super) receiver: Id,\n\t/// Kind of message.\n\t#[arg(index = 2)]\n\tpub(super) kind:     String,\n\t/// Send the message with a string body.\n\t#[arg(long)]\n\tpub(super) str:      Option<String>,\n\t/// Send the message with a JSON body.\n\t#[arg(long)]\n\tpub(super) json:     Option<String>,","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-cli/src/args.rs#L113-L149","documentation":"`CommandPub::receiver` resolves the target Yazi instance's id from the `YAZI_PID` environment variable (despite the error mentioning `YAZI_ID`). When `YAZI_PID` is unset or empty, it bails because there is no receiver to send the `ya` command to.","triggerScenarios":"Invoking a `ya pub`/`ya pub-to` command outside of a Yazi-spawned shell where `YAZI_PID` was never exported; running `ya` from a separate terminal that Yazi did not start; the env var being emptied by a wrapper script.","commonSituations":"Running `ya` commands in a fresh terminal instead of the one hosting Yazi; using tmux panes not spawned by Yazi; testing the CLI standalone.","solutions":["Run `ya` from within the shell/terminal session launched by a running Yazi instance, which exports `YAZI_PID`.","Manually export `YAZI_PID=<pid of yazi>` before calling `ya`.","Verify a Yazi instance is actually running (`pgrep yazi`) and that it is a version that exports `YAZI_PID`."],"exampleFix":"// before (bare shell)\nya mount\n// after\nexport YAZI_PID=$(pgrep -x yazi | head -1)\nya mount","handlingStrategy":"try-catch","validationCode":"if [ -z \"$YAZI_PID\" ]; then echo \"not inside a yazi session (YAZI_PID unset)\" >&2; exit 1; fi","typeGuard":null,"tryCatchPattern":"match CommandPub::receiver() {\n  Ok(id) => id,\n  Err(_) => { eprintln!(\"run `ya` inside a shell launched by yazi, or export YAZI_PID\"); return; }\n}","preventionTips":["Only run `ya` commands from the shell/terminal spawned by Yazi.","Export YAZI_PID manually when scripting against a known instance.","Check `pgrep yazi` before invoking `ya` in automation."],"tags":["environment","ipc","missing-env-var"],"backgroundTag":"missing-env-var","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}