wavetermdev/waveterm · error
error getting environment with PTY: %w
Error message
error getting environment with PTY: %w
What it means
The second probe of GetEnvironmentMaps runs the same environment capture WITH a PTY allocated. Failures in that PTY session (command error, PTY request denied, connection drop) are wrapped as 'error getting environment with PTY'.
Source
Thrown at pkg/remote/conncontroller/conncontroller.go:346
}
return true, clientVersion, "", nil
}
// for testing only -- trying to determine the env difference when attaching or not attaching a pty to an ssh session
func (conn *SSHConn) GetEnvironmentMaps(ctx context.Context) (map[string]string, map[string]string, error) {
client := conn.GetClient()
if client == nil {
return nil, nil, fmt.Errorf("ssh client is not connected")
}
noPtyEnv, err := conn.getEnvironmentNoPty(ctx, client)
if err != nil {
return nil, nil, fmt.Errorf("error getting environment without PTY: %w", err)
}
ptyEnv, err := conn.getEnvironmentWithPty(ctx, client)
if err != nil {
return nil, nil, fmt.Errorf("error getting environment with PTY: %w", err)
}
return noPtyEnv, ptyEnv, nil
}
func runSessionWithContext(ctx context.Context, session *ssh.Session, cmd string) error {
errCh := make(chan error, 1)
go func() {
errCh <- session.Run(cmd)
}()
select {
case <-ctx.Done():
session.Close()
return ctx.Err()
case err := <-errCh:
return errView on GitHub (pinned to a4447c1563)
Solutions
- Check sshd_config on the remote allows PTY allocation (PermitTTY yes) and ptys are available
- Inspect the wrapped inner error for the session/PTY failure detail
- Reproduce with ssh -t host 'env' to see the PTY-mode failure directly
- Fix interactive shell startup files that fail under PTY
Example fix
// server (sshd_config) // before PermitTTY no // after PermitTTY yes
Defensive patterns
Strategy: try-catch
Validate before calling
// pty availability precheck
out, err := client.CombinedOutput("ssh -T host true") // or test RequestPty
if err != nil {
return fmt.Errorf("pty allocation may be unavailable: %v", err)
} Try / catch
noPty, pty, err := conn.GetEnvironmentMaps(ctx)
if err != nil && strings.Contains(err.Error(), "environment with PTY") {
log.Printf("env probe (pty) failed: %v", err) // fall back to noPty env
} Prevention
- Ensure sshd allows PTY allocation (PermitTTY yes) on remotes
- Keep interactive shell startup scripts error-free
- Fall back to the no-PTY environment when the PTY probe fails
When it happens
Trigger: conn.getEnvironmentWithPty returns an error — PTY allocation is refused by sshd, the shell fails under PTY, or the session errors before the env dump completes.
Common situations: sshd configured with PermitTTY no or limited ptys; shell profile that errors only in interactive/PTY mode; connection instability during interactive session setup; pty allocation limits hit (out of ptys).
Related errors
- error getting environment without PTY: %w
- setting auth key: %v
- cannot parse connection name: %w
- getting ssh connection status: %w
- connecting connection: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/eb57229a7b7049e1.
Report an issue: GitHub.