{"record":{"id":"7434f00d1e1b8ad0","repo":"jdx/mise","slug":"cannot-nest-relay-sessions","errorCode":null,"errorMessage":"cannot nest relay sessions","messagePattern":"cannot nest relay sessions","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/ssh.rs","lineNumber":156,"sourceCode":"                self.repository_dry_run,\n            )?;\n            return Ok(());\n        }\n        let scope = crate::github_relay::Scope::from_flags(\n            self.github_relay_read_only,\n            &self.github_relay_repo,\n            self.github_relay_all_repos,\n        )?;\n        let scope = crate::github_relay::configure(\n            scope,\n            self.github_relay_log_requests,\n            self.github_relay_no_log_requests,\n            self.github_relay_log_format.as_deref(),\n            self.github_relay_max_duration.as_deref(),\n        )?;\n        if let Some(socket) = self.relay_session {\n            if scope.is_some() {\n                bail!(\"cannot nest relay sessions\");\n            }\n            #[cfg(unix)]\n            {\n                crate::ui::ctrlc::exit_on_ctrl_c(false);\n                let mut command = self.command;\n                if let Some(first) = self.destination {\n                    command.insert(0, first);\n                }\n                return crate::system::remote::interruptible(crate::github_relay::unix::session(\n                    &socket, command,\n                ))\n                .await;\n            }\n            #[cfg(not(unix))]\n            bail!(\"GitHub relay requires a POSIX target: {}\", socket.display());\n        }\n        let destination = self\n            .destination","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/ssh.rs#L138-L174","documentation":"The `mise ssh` command was asked to start a relay session (`--relay-session`) while already inside a scoped relay session. Relay sessions use a socket and cannot be stacked, so mise bails instead of creating a nested session.","triggerScenarios":"Invoking `mise ssh --relay-session ...` (the `relay_session` flag) while `scope` (an outer relay scope) is already set.","commonSituations":"Running a second `mise ssh` relay command inside a shell already launched through a relay session; wrapping relay invocations in scripts that execute within an existing relay.","solutions":["Exit the current relay session before starting a new one.","Drop the --relay-session flag and run the command inside the existing session.","Use a fresh shell that is not inside a relay session."],"exampleFix":"// before\nmise ssh --relay-session host  # inside an existing relay session\n// after\nexit   # leave the outer relay session\nmise ssh --relay-session host","handlingStrategy":"validation","validationCode":"if (process.env.MISE_RELAY_SESSION_ACTIVE) { throw new Error('already inside a relay session; do not pass --relay-session again'); }","typeGuard":null,"tryCatchPattern":"try { await run('mise ssh --relay-session host') } catch (e) { if (String(e).includes('cannot nest relay sessions')) { /* run without the flag or alert the user */ } }","preventionTips":["Track relay-session state in your shell environment","Do not wrap relay commands inside relay-launched shells","Strip --relay-session from nested invocations"],"tags":["cli","ssh","relay","nesting"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}