{"record":{"id":"0a6ad1a887466928","repo":"jesseduffield/lazydocker","slug":"override-docker-host-to-tunneled-socket-w","errorCode":null,"errorMessage":"override DOCKER_HOST to tunneled socket: %w","messagePattern":"override DOCKER_HOST to tunneled socket: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/ssh/ssh.go","lineNumber":64,"sourceCode":"// to point towards a local unix socket tunneled over SSH to the specified ssh host.\nfunc (self *SSHHandler) HandleSSHDockerHost() (io.Closer, error) {\n\tconst key = \"DOCKER_HOST\"\n\tctx := context.Background()\n\tu, err := url.Parse(self.getenv(key))\n\tif err != nil {\n\t\t// if no or an invalid docker host is specified, continue nominally\n\t\treturn noopCloser{}, nil\n\t}\n\n\t// if the docker host scheme is \"ssh\", forward the docker socket before creating the client\n\tif u.Scheme == \"ssh\" {\n\t\ttunnel, err := self.createDockerHostTunnel(ctx, u.Host)\n\t\tif err != nil {\n\t\t\treturn noopCloser{}, fmt.Errorf(\"tunnel ssh docker host: %w\", err)\n\t\t}\n\t\terr = self.setenv(key, tunnel.socketPath)\n\t\tif err != nil {\n\t\t\treturn noopCloser{}, fmt.Errorf(\"override DOCKER_HOST to tunneled socket: %w\", err)\n\t\t}\n\n\t\treturn tunnel, nil\n\t}\n\treturn noopCloser{}, nil\n}\n\ntype noopCloser struct{}\n\nfunc (noopCloser) Close() error { return nil }\n\ntype tunneledDockerHost struct {\n\tsocketPath string\n\tcmd        *exec.Cmd\n\toSCommand  CmdKiller\n}\n\nvar _ io.Closer = (*tunneledDockerHost)(nil)","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/jesseduffield/lazydocker/blob/7e7aadc2071d58031bf2daafca1fbd4093efc23f/pkg/commands/ssh/ssh.go#L46-L82","documentation":"After the ssh tunnel is successfully created, lazydocker rewrites DOCKER_HOST (via os.Setenv through self.setenv) to unix://<localSocket> so the docker client connects through the tunnel. This error means the tunnel itself worked but setting the environment variable failed — an extremely rare environment-level failure chained with %w.","triggerScenarios":"createDockerHostTunnel succeeds and self.setenv(\"DOCKER_HOST\", tunnel.socketPath) returns an error. In the real handler setenv is os.Setenv, which essentially never fails on desktop OSes; it can only fail on exotic platforms or if a test double injects a failure.","commonSituations":"Almost exclusively seen in unit tests where setenv is mocked to fail; hypothetically a broken libc environment on unusual Unix variants. End users should treat this as 'unreachable in practice' and look at the chained error for clarity.","solutions":["Look at the %w-chained cause — if it is a mock/test failure, fix the test double rather than the environment.","As a workaround, create the tunnel manually with ssh -L and set DOCKER_HOST yourself, bypassing the setenv step.","Report a bug if this fires on a normal desktop OS — it indicates an environmental defect worth investigating upstream."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := sshHandler.LearnDockerHostShim(); err != nil {\n    if strings.Contains(err.Error(), \"override DOCKER_HOST\") {\n        // tunnel is up but env write failed: close it and fall back to direct DOCKER_HOST\n        // (in practice this only fires from injected test doubles)\n    }\n}","preventionTips":["In tests, make setenv doubles succeed unless you are specifically testing this branch.","Treat occurrence outside tests as an environment defect: report it upstream with the %w chain."],"tags":["docker","ssh","environment-variables","rare","tunnel"],"backgroundTag":null,"analyzedSha":"7e7aadc2071d58031bf2daafca1fbd4093efc23f","analyzedAt":"2026-08-15T09:51:48.093Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}