sinelaw/fresh · error
could not open from container
Error message
could not open {} from container: {} What it means
fetch_and_open_container_file runs a command (e.g. docker/kubectl exec cat) to extract a file from a container; when that command exits with an error, the first line of its stderr is surfaced in this bail. It means the container-side read of the requested path failed.
Solutions
- Check the full stderr to see whether the file exists in the container (ls the path via exec).
- Verify the container is running and the exec command/binary name is correct in the URI.
- Correct the container path in the URI and retry opening the file.
Example fix
// before let uri = "container://myapp/etc/hosts"; // file missing // after // verify first: docker exec myapp cat /etc/hosts let uri = "container://myapp//etc/hosts"; // corrected absolute path
Defensive patterns
Strategy: try-catch
Validate before calling
// verify the file exists in the container first // docker exec <container> test -f <path> && echo ok
Try / catch
match editor_open_target(uri) { Err(e) if e.to_string().contains("from container") => show_message(format!("container read failed: {e}")), r => r } Prevention
- Confirm the container is running before resolving container:// URIs
- Use absolute paths inside the container
- Test the exec command manually before wiring it into URIs
When it happens
Trigger: open_lsp_uri_target resolving a container:// URI where the exec command returns non-zero status — file missing in the container, permission denied, container not running, or the exec binary is unavailable.
Common situations: LSP sends a URI for a file inside a container that was restarted or removed; typo'd container path; container image lacks the file; docker exec fails due to stopped container.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Cannot open file: remote connection lost
- ${built.error}
- Cannot save: remote connection lost
- Cannot open files from multiple remote hosts. First
- Cannot mix local and remote files. Use either local paths…
AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13).
Data as JSON: /api/errors/753124a1eafc8383.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fresh-editor/src/app/file_open_orchestrators.rs:765
let path_arg = container_path.to_string_lossy().into_owned();
let result = runtime
.block_on(spawner.spawn("cat".into(), vec![path_arg], None))
.map_err(|e| {
anyhow::anyhow!(
"could not open {} from container: {}",
container_path.display(),
e
)
})?;
if result.exit_code != 0 {
let first_stderr_line = result
.stderr
.lines()
.next()
.unwrap_or("(no error message)")
.trim();
anyhow::bail!(
"could not open {} from container: {}",
container_path.display(),
first_stderr_line
);
}
self.open_container_only_file(container_path, uri, result.stdout.into_bytes())
}
/// Build a buffer from already-fetched container content. The
/// buffer's `file_path` is the in-container path (so further LSP
/// requests carry the right URI) and the buffer is read-only —
/// there is no host writeback path for files that exist only
/// inside the container. LSP stays enabled so a follow-up
/// goto-def from the fetched buffer works.
pub(crate) fn open_container_only_file(
&mut self,
container_path: std::path::PathBuf,View on GitHub (pinned to 67894ca546)