Skip to main content
Nu runs shell commands and file edits in a separate sandbox container. It can see Nu’s workspace, ~/.nu/workspace, and read its skills and packages. It can’t see Nu’s secrets, policy, or database. The container’s filesystem is read-only outside the workspace, it runs without Linux capabilities, and it has 4 GB of memory.

Installing tools

The sandbox has node, npm, git, gh, curl, and rg. Nu can install other tools into its home folder, ~/.nu/workspace/.home, where they last across restarts. npm install -g installs there, and ~/.local/bin is on the PATH. To build tools into the sandbox instead, give it your own image in ~/.nu/compose.override.yaml:
Run docker compose build sandbox after each update so the image picks up the new version.

Working on other folders

To let Nu work on a folder outside the workspace, mount it into the sandbox at the same path it has on your machine. Add it to the sandbox’s volumes in ~/.nu/compose.override.yaml:
Then restart:

Sharing secrets

Secrets stay out of the sandbox, and work that needs one runs as a tool instead. When a command does need a secret, such as a GitHub token for git push, share it:
Commands see a shared secret as an environment variable. They use it without asking and can send it anywhere the sandbox can reach, so share narrowly scoped tokens, such as a fine-grained GitHub token for a few repositories. With GITHUB_TOKEN or GH_TOKEN shared, git and gh work against GitHub. Commits are authored as the token’s GitHub account, using its private noreply email address.

Other sandboxes

An extension can run the workspace somewhere else, such as a cloud sandbox provider, by registering a sandbox:
Each of Nu’s services loads the extension, so the sandbox must reach the same workspace from all of them. Nu reads skills and long command output from its own disk, wherever the sandbox runs. Packages in a sandbox like this are saved with package_write, since Nu can’t install them from a path it can’t see.

Without Docker

Nu has no sandbox when it runs without Docker. Shell commands run as your user, and file edits are limited to the workspace.