Open a Codespace in JupyterLab with gh codespace jupyter
With five Codespaces on the go, gh codespace jupyter can open the wrong notebook environment as easily as the right one. This guide gives you a repeatable command that never guesses. It follows the installed GitHub CLI 2.87.3, packaged as gh here, and takes about ten minutes.
The route
Jump straight to the step you need, or tick off Done means at the end.
You need GitHub CLI, an authenticated GitHub account with access to at least one Codespace, and a desktop session with a browser. These examples start or connect to a remote development environment, so use a repository and Codespace you are authorised to access. No command in this guide needs sudo.
1. Check the installed command
Confirm the binary and inspect the local interface first. It is an ordinary read-only check:
$ command -v gh
/usr/bin/gh
$ gh --version
gh version 2.87.3 (2026-02-23)
$ gh codespace jupyter --help
Open a codespace in JupyterLab
USAGE
gh codespace jupyter [flags]
Your version and installation path may differ. The command has only three useful selectors:
--codespace(or-c). An exact Codespace name.--repo(or-R). Filters byuser/repo.--repo-owner. Filters by a user or organisation.
It does not expose a Jupyter port, kernel or notebook option in this interface.
Checkpoint
If the help output does not show gh codespace jupyter, stop and check the installed CLI version before copying examples from another machine.
2. Check authentication and inventory
Ask the CLI which account is active, then list the Codespaces visible to it:
$ gh auth status
$ gh codespace list
The list is the source for the exact name and repository values you will use. Output is account- and organisation-specific, so do not script against a sample row or assume a Codespace name matches its repository name.
If gh auth status says you are not logged in, authenticate with your normal GitHub CLI process, then rerun both checks. If the account is correct but the Codespace is missing, check the repository, organisation policy and account permissions. Changing accounts can affect later commands, so make that choice deliberately.
Checkpoint
Copy one exact Codespace name from gh codespace list. If several entries have similar names, also record its repository in OWNER/REPOSITORY form.
3. Open an unambiguous Codespace
When you know the name, pass it explicitly. Replace the placeholder with the value from your own list:
$ gh codespace jupyter --codespace CODESPACE_NAME
The command opens the selected Codespace in JupyterLab. Keep the name as one shell argument. Quoting it is harmless and protects names copied from another command:
$ gh codespace jupyter --codespace 'CODESPACE_NAME'
A successful run hands the browser launch to your local environment, and you may see no useful terminal output afterwards. Check in the browser that the JupyterLab page loads and that its file browser shows the workspace you expected. In a script, the exit status is also worth checking:
$ gh codespace jupyter --codespace 'CODESPACE_NAME'
$ printf 'gh exit status: %s\n' "$?"
gh exit status: 0
Tip
An exit status of zero confirms only that the CLI completed its launch. It does not prove the browser finished loading, that a notebook kernel is available, or that a particular file exists in the workspace.
4. Disambiguate by repository or owner
To select by repository, use its full owner and repository name:
$ gh codespace jupyter --repo OWNER/REPOSITORY
For repositories under an organisation, the owner is the organisation name:
$ gh codespace jupyter --repo acme-labs/analysis-notebooks
You can narrow the selection by owner instead:
$ gh codespace jupyter --repo-owner acme-labs
These are filters, not creation commands. They do not create, rename, stop or delete a Codespace. If a filter still matches more than one entry, use --codespace with the exact name. If it matches nothing, compare spelling and capitalisation with gh codespace list and confirm the active account can see the repository.
5. Avoid the common selection traps
- Wrong
--repovalue. Never use a local path, a URL or a short repository name. The documented value isuser/repo, such asacme-labs/analysis-notebooks. - Wrong
--codespacevalue. Do not put an organisation in it. That option expects the Codespace name. - Guessed flags. Do not add flags for the browser, port or notebook. The installed command's documented flags are the three selectors above plus inherited help.
To inspect the commands around it, use:
$ gh codespace --help
A browser window that opens but cannot connect is a different failure from an invalid selector. First confirm the exact Codespace with gh codespace list, then check whether it is running and whether your GitHub account still has access. Avoid launching duplicate browser tabs while you diagnose the same selection.
6. Keep the boundary clear
This command is a launcher. It does not cover notebook execution, package installation or Codespace lifecycle management. Once JupyterLab is open, changes in notebooks, terminals and files happen inside the remote development environment.
Warning
Before running a notebook that writes data, installs packages or calls an external service, inspect the cells and confirm the intended workspace.
There is no undo for opening a browser page. Closing the JupyterLab tab ends your local view, but it does not necessarily stop the Codespace. If you need to stop or delete one, use the separate lifecycle command only after checking its target and the repository state. Deletion can remove an environment and is not part of this guide.
Done means
- Command present.
gh --versionandgh codespace jupyter --helpshow a compatible installed command. - Account right.
gh auth statusidentifies the intended GitHub account. - Selector exact.
gh codespace listsupplied the exact name or repository filter. - Right workspace. JupyterLab opened for the expected Codespace and workspace.
- Limits known. A successful CLI exit does not test browser loading or notebook kernels.
- Nothing touched. No Codespace was created, stopped or deleted while selecting it.