ad4b882bff
This PR fixes 2 bugs that made the follow option in `e2b sbx logs` not work: 1. `e2b sbx logs -f <id>` failed to follow because the `isRunning` function was always returning false due to the API call being unauthenticated if you dont have the `E2B_API_KEY` environment variable set. This follows the existing pattern from other API calls: https://github.com/e2b-dev/E2B/blob/c4ce97e9b9a1809e3419d64499c1e56f9138e3d0/packages/cli/src/commands/sandbox/list.ts#L138-L152 Eventually it would make sense to handle the error here, for now just a hotfix to fix the --follow usage 2. Once it actually followed, it never stopped following because `isRunning` was not inside the loop and always true. Now when you kill the sandbox follow actually stops following <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Fixes `e2b sbx logs -f` by authenticating `isRunning` and re-checking sandbox state each loop so following works and stops when closed. > > - **CLI — `packages/cli/src/commands/sandbox`**: > - **Logs follow behavior (`logs.ts`)**: > - Re-check `isRunning(sandboxID)` inside the loop (`isSandboxRunning`) instead of using a cached promise, ensuring follow stops when sandbox is closed or not found. > - **Sandbox state check auth (`utils.ts`)**: > - Use `ensureAPIKey()` and pass `apiKey` to `Sandbox.getInfo(getShortID(sandboxID), { apiKey })` so `isRunning` is authenticated. > - **Release**: > - Changeset adds patch for `@e2b/cli` with note: fix sbx logs follow option. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5fbd87166b70aca7229ccc1ff8fa2c27f12b1641. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
E2B CLI
This CLI tool allows you to build manager your running E2B sandbox and sandbox templates. Learn more in our documentation.
1. Install the CLI
Using Homebrew (on macOS)
brew install e2b
Using NPM
npm install -g @e2b/cli
2. Authenticate
e2b auth login
Note
To authenticate without the ability to open the browser, provide
E2B_ACCESS_TOKENas an environment variable. You can find your token in Account Settings under the Team selector at e2b.dev/dashboard. Then use the CLI like this:E2B_ACCESS_TOKEN=sk_e2b_... e2b template build.
Important
Note the distinction between
E2B_ACCESS_TOKENandE2B_API_KEY.
3. Check out docs
Visit our CLI documentation to learn more.
