---
title: "Run Codex in a Cohub Space: Local Runtime vs cloud CLI"
description: "Decide where to run Codex in a Cohub Space: compare Local Runtime on your host with a cloud CLI install, sign-in options, and cloud namespace limits."
lang: "en"
canonical: "https://cohub.live/guides/codex-in-a-space"
image: "https://cohub.live/_seo/covers/codex-in-a-space/og.webp"
updated: "2026-12-02"
---

# Run Codex in a Cohub Space via Local Runtime or cloud CLI

If your task needs Codex to run shell commands, connect a trusted project host through Cohub Local Runtime and keep Codex’s sandbox enabled. Installing the CLI in a cloud Space puts it next to the cloud files, but even a working login won’t help if the host cannot start the inner sandbox.

- **Who:** For developers deciding which machine should run Codex commands for a shared project.
- **When:** You want to use your Codex login from a Space, or the cloud CLI starts but its shell tools do not.
- **Why:** The host determines which files Codex works on and whether it can isolate a command.

![An orange folder rests on a white page opposite a matching recess cut into charcoal board.](https://cohub.live/_seo/covers/codex-in-a-space/hero.webp)

![The local Runtime uses Codex installed and signed in on its host. In the tested cloud Space, a zero user namespace limit stopped the CLI’s inner sandbox. Move the task to a host that supports it.](https://cohub.live/_seo/covers/codex-in-a-space/flow-en.svg)

Two places to run Codex. The cloud result comes from one Space tested in November 2026.

Choosing where to run Codex in a Cohub Space comes down to two facts: which machine holds the files, and whether that host can start Codex’s own Linux command sandbox. If Codex needs to run shell commands on a project folder, connect a trusted host through Cohub Local Runtime; if you install the CLI inside a cloud Space, check host namespace support before supplying credentials.

## Local Runtime vs cloud CLI: what changes for you
| Dimension | Local Runtime (`--harness codex`) | Codex CLI in a cloud Space |
|---|---|---|
| Target files | A local project directory on the connected host | Cloud project files under `/workspace` |
| Chat harness picker | Select Codex directly in the Space chat | Does not add Codex to the cloud chat harness picker |
| Session model | Space messages execute on your machine while connected | Standalone CLI inside the Space Linux environment, not an OpenAI-hosted Codex cloud session |
| Command isolation | Uses the connected host’s normal Codex sandbox | In the tested cloud Space, `max_user_namespaces` was `0`, blocking `bwrap` |

A harness is the program that executes a Space chat turn. With Local Runtime, the Space forwards turns to the connected machine, so that host must stay online while you work.

## Attach a trusted host with Local Runtime
Prepare a trusted machine with the Cohub CLI, Node.js 24 or later, and an authenticated Codex CLI on `PATH`, pointed at a folder you are comfortable sharing with Space collaborators. Cohub login and Codex login stay completely separate; [ai agent cli](https://cohub.live/guides/ai-agent-cli) covers installing and signing in to the Cohub CLI. Start the Runtime from your project directory:

```bash
cohub auth login
cd ~/projects/my-project
codex --version
codex login status
cohub runtime up --harness codex
```

Keep that terminal running, verify the link from another terminal with `cohub runtime status`, and pick Codex in the Space chat. For an initial code review pass, pick **Read only** where offered (documented for Codex app-server 0.162.1 and newer). Before allowing edits, configure the host for workspace-scoped writes and approvals. If an explicitly requested harness fails startup checks, Runtime refuses to fall back silently to a different executor. These steps follow official documentation; we did not execute an authenticated local chat turn for this page.

## Separate interactive login from unattended API keys
**Interactive host sessions:** Run `codex login` on the project machine to sign in with an eligible ChatGPT account (using your plan’s Codex access), or supply an OpenAI API key billed separately to your API account. Signing in to Cohub handles neither step. For headless machines without a browser, OpenAI documents device-code sign-in where the account or workspace allows it; that flow was not tested here.

**Non-interactive runs:** `codex exec` normally expects a Git repository. OpenAI documents setting `CODEX_API_KEY` for a headless invocation—scope that variable strictly to the single command on a trusted runner. Space environment variables are readable by other processes in the sandbox, so keep personal keys out of shared Spaces and never copy login files into the project folder. Confirm the host can execute the task before handing it any secret.

## What blocked shell commands in the tested cloud sandbox
**Recorded on November 17, 2026:** Inside one Cohub cloud sandbox, Codex CLI 0.169.0 answered `--version`, and a placeholder key reached OpenAI and returned HTTP 401. In a separate check, when Codex attempted to launch its Linux command sandbox, `bwrap` failed with `Creating new namespace failed` (`ENOSPC`) while the host reported `max_user_namespaces` equal to `0`. Receiving 401 only confirmed outbound reachability to OpenAI—it proved neither valid authentication nor working command execution.

Check these three facts on Linux without sending prompts or exposing keys:

```bash
codex --version
codex login status
cat /proc/sys/user/max_user_namespaces
```

**Checked again on November 18, 2026:** Inside our worker sandbox, the same 0.169.0 binary started cleanly, a clean profile reported `Not logged in`, and `max_user_namespaces` still read `0`. We did not re-run the inner sandbox or any model turn, and a nonzero number on a different host does not by itself guarantee compatibility.

Swapping accounts or API keys cannot bypass a zero user-namespace limit. Move shell-executing Codex work to a Local Runtime host that supports Codex’s normal sandbox, or—when code must stay in the cloud—ask your administrator for a supported environment that preserves both isolation layers.

## Evaluating Claude Code for cloud-only headless runs
If your cloud workflow only needs a headless CLI against `/workspace` and does not depend on Codex-specific behavior, Claude Code is worth testing. In the [cloud setup walkthrough](https://cohub.live/guides/run-claude-code-in-cloud), Claude Code 2.1.326 installed, started in print mode reporting a missing login, and returned `Invalid API key` with a placeholder Anthropic key. That check stopped at authentication; it did not test authenticated file edits, tool permissions, or equivalent isolation. Validate your required commands and permissions inside a disposable project first.

## Reference in the docs

**This page:** Whether to connect your project host, use an administrator-provided environment, or evaluate Claude Code for a cloud-only task.

- [Files & Sandbox](https://cohub.live/docs/workspace/files-and-sandbox): where a cloud process finds the project's files
- [CLI](https://cohub.live/docs/developers/cli): how the Cohub CLI connects to a Space

## Related

- [How to run Claude Code in the cloud inside a Cohub Space](https://cohub.live/guides/run-claude-code-in-cloud): To run Claude Code in the cloud on Cohub, install it in a Space's sandbox with a startup script. The walkthrough checks CLI authentication with placeholder keys, then shows how to publish a server and recover project files with Saves.
- [Picking a Claude Code alternative across terminal CLIs, vendor cloud, and Cohub](https://cohub.live/compare/claude-code-alternative): Both Claude Code and Codex CLI now offer official cloud sessions. Cohub works as a Claude Code alternative when you need multi-user collaboration, published web Apps, or Apache-2.0 self-hosting—and pairs with local CLIs via Local Runtime.
- [Use the Cohub AI agent CLI to run commands and prompt Spaces from your terminal](https://cohub.live/guides/ai-agent-cli): The Cohub CLI is a terminal for Cohub Spaces. It does not run a model by itself: it sends prompts to the agent in a Space and lists or runs what the Space holds. A Local Runtime on your computer can run a harness such as Codex or Claude Code.

## Sources

- [OpenAI: Codex CLI](https://learn.chatgpt.com/docs/codex/cli)
- [OpenAI: Authentication](https://learn.chatgpt.com/docs/auth)
- [OpenAI: Non-interactive mode and API key handling](https://learn.chatgpt.com/docs/non-interactive-mode)
- [OpenAI: Agent approvals and security](https://learn.chatgpt.com/docs/agent-approvals-security)
- [Anthropic: Run Claude Code programmatically](https://code.claude.com/docs/en/headless)

Updated Dec 2, 2026
