Permission denied after using a newly created directory
If you create a new directory with our SDK and then try to move a file into the newly created directory, you receive a permission denied error.
Reproducible Python example
from e2b import Sandbox
with Sandbox() as sandbox:
sandbox.filesystem.make_dir("/new-dir")
sandbox.filesystem.write("/file.txt", "hello")
proc = sandbox.process.start_and_wait("mv /file.txt /new-dir/file.txt")
print(proc)
Output
messages=[ProcessMessage(line="mv: cannot move '/file.txt' to '/new-dir/file.txt': Permission denied", error=True, timestamp=1713826346687143416)] error=True exit_code=1
This is a problem with filesystem permissions — we don't expose user and use root for fs operations by default (so you have access to all files). When you then try to modify file as default user via process the permissions block this.
I'm taking this into account when thinking about new version of the API (https://github.com/e2b-dev/infra/blob/grpc/packages/envd/spec/filesystem.proto), but it might be possible to add this without breaking to the current API too.
This is fixed in the new beta SDK (https://e2b.dev/docs/guide/beta-migration) — by default, all operations are executed as user.