jdx/mise · error
cannot nest relay sessions
Error message
cannot nest relay sessions
What it means
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.
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.
Example fix
// before mise ssh --relay-session host # inside an existing relay session // after exit # leave the outer relay session mise ssh --relay-session host
Defensive patterns
Strategy: validation
Validate before calling
if (process.env.MISE_RELAY_SESSION_ACTIVE) { throw new Error('already inside a relay session; do not pass --relay-session again'); } Try / catch
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 */ } } Prevention
- Track relay-session state in your shell environment
- Do not wrap relay commands inside relay-launched shells
- Strip --relay-session from nested invocations
When it happens
Trigger: Invoking `mise ssh --relay-session ...` (the `relay_session` flag) while `scope` (an outer relay scope) is already set.
Common situations: 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.
Related errors
- GitHub relay requires a POSIX target
- a repository preview directory requires a dry run
- cannot set up from a setup repository
- GitHub relay requires Linux or macOS
- GitHub relay socket forwarding failed
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/7434f00d1e1b8ad0.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/ssh.rs:156
self.repository_dry_run,
)?;
return Ok(());
}
let scope = crate::github_relay::Scope::from_flags(
self.github_relay_read_only,
&self.github_relay_repo,
self.github_relay_all_repos,
)?;
let scope = crate::github_relay::configure(
scope,
self.github_relay_log_requests,
self.github_relay_no_log_requests,
self.github_relay_log_format.as_deref(),
self.github_relay_max_duration.as_deref(),
)?;
if let Some(socket) = self.relay_session {
if scope.is_some() {
bail!("cannot nest relay sessions");
}
#[cfg(unix)]
{
crate::ui::ctrlc::exit_on_ctrl_c(false);
let mut command = self.command;
if let Some(first) = self.destination {
command.insert(0, first);
}
return crate::system::remote::interruptible(crate::github_relay::unix::session(
&socket, command,
))
.await;
}
#[cfg(not(unix))]
bail!("GitHub relay requires a POSIX target: {}", socket.display());
}
let destination = self
.destinationView on GitHub (pinned to 533346cc37)