{"record":{"id":"fce30fb1fa169588","repo":"zed-industries/zed","slug":"failed-to-upload-directory-via-sftp-scp","errorCode":null,"errorMessage":"failed to upload directory via SFTP/SCP {} -> {}: {}","messagePattern":"failed to upload directory via SFTP/SCP (.+?) -> (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/remote/src/transport/ssh.rs","lineNumber":454,"sourceCode":"                if output.status.success() {\n                    return Ok(());\n                }\n\n                let stderr = String::from_utf8_lossy(&output.stderr);\n                log::debug!(\"failed to upload directory via SFTP {src_path_display} -> {dest_path_str}: {stderr}\");\n            }\n\n            log::debug!(\"using SCP for directory upload\");\n            let output = scp_command.output().await?;\n\n            if output.status.success() {\n                return Ok(());\n            }\n\n            let stderr = String::from_utf8_lossy(&output.stderr);\n            log::debug!(\"failed to upload directory via SCP {src_path_display} -> {dest_path_str}: {stderr}\");\n\n            anyhow::bail!(\n                \"failed to upload directory via SFTP/SCP {} -> {}: {}\",\n                src_path_display,\n                dest_path_str,\n                stderr,\n            );\n        })\n    }\n\n    fn start_proxy(\n        &self,\n        unique_identifier: String,\n        reconnect: bool,\n        incoming_tx: UnboundedSender<Envelope>,\n        outgoing_rx: UnboundedReceiver<Envelope>,\n        connection_activity_tx: Sender<()>,\n        delegate: Arc<dyn RemoteClientDelegate>,\n        cx: &mut AsyncApp,\n    ) -> Task<Result<i32>> {","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/remote/src/transport/ssh.rs#L436-L472","documentation":"When uploading a directory (the extracted remote server) over SSH, Zed tries SFTP and falls back to scp -r; this error is the final failure of the scp fallback, embedding the CLI's stderr. Neither SFTP nor SCP managed to copy the directory to the remote host.","triggerScenarios":"The scp -r command built for the directory upload exits non-zero: the remote lacks scp/sftp binaries, the target directory is not writable, the disk is full, or the destination path/arguments trip quoting problems.","commonSituations":"Minimal remotes (containers, embedded boards) without openssh-clients; connecting as a user whose home or .local/share is read-only; full server filesystems; remote shell startup files printing text that corrupts the SFTP protocol channel.","solutions":["Reproduce manually with the paths from the message: `scp -r <src_dir> <user>@<host>:<dest>` and read the stderr Zed embedded","Install the SSH client tools on the remote (apt-get install openssh-client / apk add openssh) so scp and sftp exist","Verify destination writability and free space on the remote: `df -h`, `touch <dest_dir>/probe`","Silence non-interactive shell output (.bashrc guards), since shell chatter breaks SFTP/SCP sessions"],"exampleFix":"# before: remote container without openssh-clients\napk add --no-cache openssh   # run on the remote\n\n# then retry the Zed remote connection; scp fallback now succeeds","handlingStrategy":"retry","validationCode":"async fn remote_supports_scp(socket: &SshSocket, shell: ShellKind) -> bool {\n    socket.run_command(shell, \"which\", &[\"scp\"], true).await.is_ok()\n        && socket.run_command(shell, \"which\", &[\"sftp\"], true).await.is_ok()\n}","typeGuard":null,"tryCatchPattern":"match upload_dir(src, dest).await {\n    Err(e) if e.to_string().contains(\"SFTP/SCP\") && attempts_left() => {\n        // verify remote writability and free space, then retry once\n        retry_after_repair().await\n    }\n    other => other,\n}","preventionTips":["Install openssh-client on remotes used for development","Guard remote rc files against printing during non-interactive sessions","Keep free space monitored on frequently-used dev hosts"],"tags":["ssh","sftp","scp","file-transfer"],"backgroundTag":"scp-upload-failed","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}