{"record":{"id":"8ce836fcf9ccef47","repo":"infiniflow/ragflow","slug":"failed-to-create-remote-artifacts-directory-stde","errorCode":null,"errorMessage":"Failed to create remote artifacts directory: {stderr or stdout or 'unknown error'}","messagePattern":"Failed to create remote artifacts directory: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/ssh.py","lineNumber":138,"sourceCode":"        return True\n\n    def create_instance(self, template: str = \"python\") -> SandboxInstance:\n        if not self._initialized:\n            raise RuntimeError(\"Provider not initialized. Call initialize() first.\")\n\n        language = self._normalize_language(template)\n        client = self._create_ssh_client()\n        sftp = client.open_sftp()\n\n        try:\n            remote_work_dir = self._create_remote_workspace(client)\n            stdout, stderr, exit_code = self._run_remote_command(\n                client,\n                f\"mkdir -p {shlex.quote(posixpath.join(remote_work_dir, 'artifacts'))}\",\n                timeout=min(self.timeout, 10),\n            )\n            if exit_code != 0:\n                raise RuntimeError(f\"Failed to create remote artifacts directory: {stderr or stdout or 'unknown error'}\")\n        except Exception:\n            sftp.close()\n            client.close()\n            raise\n\n        instance_id = str(uuid.uuid4())\n        self._instances[instance_id] = {\n            \"client\": client,\n            \"sftp\": sftp,\n            \"remote_work_dir\": remote_work_dir,\n            \"language\": language,\n        }\n\n        return SandboxInstance(\n            instance_id=instance_id,\n            provider=\"ssh\",\n            status=\"running\",\n            metadata={\"language\": language, \"remote_work_dir\": remote_work_dir},","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/ssh.py#L120-L156","documentation":"Raised by SSHProvider.create_instance() when the remote command 'mkdir -p <work_dir>/artifacts' returns a non-zero exit code over the SSH channel. The message embeds the remote stderr (or stdout) so the remote shell's actual complaint is visible. On failure the freshly opened SSH client and SFTP session are closed and the exception propagates; no instance is registered.","triggerScenarios":"work_dir pointing at a path the SSH user cannot create (permission denied, e.g. /root as non-root); work_dir on a read-only filesystem; disk full on the remote host; work_dir containing a component that is a regular file (mkdir fails with 'File exists' for a non-directory); SELinux/AppArmor denials.","commonSituations":"Default work_dir '/tmp' replaced with a restricted path; SSH user chrooted or scoped with limited commands; a stale file occupying the intended directory path; remote host out of inode space.","solutions":["Read the embedded stderr — it names the exact OS-level failure (Permission denied, Read-only file system, No space left on device, Not a directory).","Set 'work_dir' to a location the SSH user can write, e.g. /tmp/ragflow-sandbox or the user's home, in the initialize() config.","Fix the remote side: ensure the parent path exists and is writable, remove a conflicting regular file at that path, free disk space.","Verify manually first: ssh user@host 'mkdir -p <work_dir>/artifacts' should succeed before re-running."],"exampleFix":"# before\nprovider.initialize({..., \"work_dir\": \"/var/lib/sandbox\"})  # not writable\n\n# after\nprovider.initialize({..., \"work_dir\": \"/tmp/ragflow-sandbox\"})","handlingStrategy":"validation","validationCode":"# preflight the exact command the provider runs, over the same credentials:\nimport subprocess\nrc = subprocess.call([\"ssh\", f\"{user}@{host}\", f\"mkdir -p {work_dir}/artifacts\"])\nassert rc == 0, \"remote artifacts dir not creatable\"","typeGuard":null,"tryCatchPattern":"try:\n    instance = provider.create_instance(\"python\")\nexcept RuntimeError as e:\n    if \"Failed to create remote artifacts directory\" in str(e):\n        # stderr inside the message names the OS cause: permissions / read-only / no space\n        raise SandboxWorkspaceError(str(e)) from e\n    raise","preventionTips":["Choose a work_dir the SSH login user can write (its home or /tmp-based path).","Pre-create and chown the workspace directory in host provisioning.","Watch remote disk space — mkdir -p fails on full or read-only filesystems."],"tags":["sandbox","ssh","remote-filesystem","permissions"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}