cli/cli · error

there are no available machine types for this repository

Error message

there are no available machine types for this repository

What it means

This inline error in pkg/cmd/codespace/create.go is returned after getMachineName resolves to an empty string while creating a codespace. getMachineName prompts or matches the machine types returned by the API for the repository; an empty result means the API offered no machine types for this repository/branch/location/devcontainer combination. The check is skipped only when --web is used without an explicit --machine, because the web UI performs its own selection.

Source

Thrown at pkg/cmd/codespace/create.go:291

		if devContainerPath == DEVCONTAINER_PROMPT_DEFAULT {
			// special arg allows users to opt out of devcontainer.json selection
			devContainerPath = ""
		}
	}

	machine := opts.machine
	// skip this if we have useWeb and no machine name provided,
	// because web UI will select default machine type if none is provided
	// web UI also provide a way to select machine type
	// therefore we let the user choose from the web UI instead of prompting from CLI
	if !(opts.useWeb && opts.machine == "") {
		machine, err = getMachineName(ctx, a.apiClient, prompter, repository.ID, opts.machine, branch, userInputs.Location, devContainerPath)
		if err != nil {
			return fmt.Errorf("error getting machine type: %w", err)
		}
		if machine == "" {
			return errors.New("there are no available machine types for this repository")
		}
	}

	if len(opts.displayName) > displayNameMaxLength {
		return fmt.Errorf("error creating codespace: display name should contain a maximum of %d characters", displayNameMaxLength)
	}

	createParams := &api.CreateCodespaceParams{
		RepositoryID:           repository.ID,
		Branch:                 branch,
		Machine:                machine,
		Location:               userInputs.Location,
		VSCSTarget:             vscsTarget,
		VSCSTargetURL:          vscsTargetUrl,
		IdleTimeoutMinutes:     int(opts.idleTimeout.Minutes()),
		RetentionPeriodMinutes: opts.retentionPeriod.Minutes(),
		DevContainerPath:       devContainerPath,
		PermissionsOptOut:      opts.permissionsOptOut,

View on GitHub (pinned to 0eeec0b92e)

Solutions

  1. Add a valid .devcontainer/devcontainer.json to the repo and target a branch that contains it.
  2. Check org/user settings: Settings > Codespaces; ensure machine access and spending limits allow allocation.
  3. Try a different --location or omit it to let the API pick a default region.
  4. As a workaround, create via the web UI (gh codespace create --web) which surfaces richer errors.

Example fix

# before
gh codespace create -R octocat/no-devcontainer-repo
# error: error creating codespace: there are no available machine types for this repository

# after
# add .devcontainer/devcontainer.json to the repo, then:
gh codespace create -R octocat/no-devcontainer-repo
Defensive patterns

Strategy: validation

Validate before calling

# sanity-check the repo exposes machine types before creating
gh api /repos/owner/repo 2>/dev/null | grep -q '"id"' || { echo 'repo unreachable'; exit 1; }
# and ensure a devcontainer exists on the target branch
git ls-remote --heads origin main >/dev/null

Try / catch

if err := runCreate(); err != nil {
    if strings.Contains(err.Error(), "no available machine types") {
        return fmt.Errorf("add .devcontainer/devcontainer.json and check codespaces org policy/spending limits")
    }
    return err
}

Prevention

When it happens

Trigger: Running gh codespace create for a repository where GetCodespacesMachines returns an empty list: commonly the repo is not codespace-enabled, the branch lacks a devcontainer the API can size, the chosen --location has no available capacity, or org policy/limits block machine allocation.

Common situations: Repository without a devcontainer.json or a .devcontainer that fails evaluation; organization disabled codespaces or set machine access to 'none'; region capacity issues; private repo where the user's plan grants no machine types; billing/spending limit exhausted.

Related errors


AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15). Data as JSON: /api/errors/159b0345f787f908. Report an issue: GitHub.