OpenCode (and similar code editors or IDEs) often run tools and commands within a sandboxed environment to prevent unintended or malicious changes to the host system. However, the exact constraints depend on how the environment is configured and the permissions granted to the tools or processes running inside it.
Sandboxing:
/workspace or /home/user), and commands like bash cannot access or modify files outside this directory unless explicitly allowed.Permissions:
bash command is run, it inherits the permissions of the user or process executing it.bash commands cannot write to those locations.OpenCode-Specific:
git, npm, bash) may be allowed, but their actions are scoped to the workspace./etc, /usr, or other system directories may be blocked.Bash Workarounds:
bash but restricts file system access, commands like cd / && ls might fail or show only a subset of directories.touch /tmp/test or echo "test" > /etc/cron.d/test would fail if the user lacks permissions or the directory is mounted as read-only.Software Constraints:
open() or write() to certain paths).bash in OpenCode and try:
It will likely fail with a permission denied error, because:bashecho "test" > /etc/test
/etc.Try running:
bashls -ld / /etc /usr /tmp
This will show the permissions for critical directories. If they are read-only (drwxr-xr-x instead of drwxrwxrwx), then bash cannot modify them.
Test writing to a system directory:
bashtouch /tmp/test # Likely works (if /tmp is writable) touch /etc/test # Likely fails
Yes, there are software constraints (containerization, permissions, security modules) that prevent bash or other tools from modifying directories outside the allowed workspace, even if the command itself is technically executable. The exact behavior depends on OpenCode's configuration, but most modern development environments enforce such restrictions by default.