vercel/turborepo · error · ConvertError

bun-workspace_glob_error

bun-workspace_glob_error

Error message

Unable to convert project to bun - workspace globs unsupported

What it means

The bun manager's create() validates the project's workspace globs with isCompatibleWithBunWorkspaces(), which mirrors bun's own lockfile glob rules: no '**' recursive segments, '*' only in the final path segment, and none of the characters '!', '[', ']', '{', '}'. If any glob violates a rule, conversion aborts with ConvertError type bun-workspace_glob_error before files are written. Turborepo deliberately will not rewrite globs to make a project fit.

Source

Thrown at packages/turbo-workspaces/src/managers/bun.ts:101

  };
}

/**
 * Create bun workspaces from generic format
 *
 * Creating bun workspaces involves:
 *  1. Validating that the project can be converted to bun workspace
 *  2. Adding the workspaces field in package.json
 *  3. Setting the devEngines.packageManager field in package.json
 *  4. Updating all workspace package.json dependencies to ensure correct format
 */
// eslint-disable-next-line @typescript-eslint/require-await -- must match the create type signature
async function create(args: CreateArgs): Promise<void> {
  const { project, to, logger, options } = args;
  const hasWorkspaces = project.workspaceData.globs.length > 0;

  if (!isCompatibleWithBunWorkspaces({ project })) {
    throw new ConvertError(
      "Unable to convert project to bun - workspace globs unsupported",
      {
        type: "bun-workspace_glob_error"
      }
    );
  }

  logger.mainStep(
    getMainStep({
      packageManager: PACKAGE_MANAGER_DETAILS.name,
      action: "create",
      project
    })
  );
  const packageJson = getPackageJson({ workspaceRoot: project.paths.root });
  logger.rootHeader();

  // package manager

View on GitHub (pinned to 9f94a7d215)

Solutions

  1. Restructure globs so '*' appears only in the last segment: 'packages/*' instead of 'packages/**'
  2. Remove brace expansion ('{a,b}') and negation ('!pkg') patterns; enumerate members explicitly or relocate excluded packages
  3. If restructuring is impossible, convert manually: write a bun-compatible workspaces field and devEngines.packageManager yourself

Example fix

// before (pnpm-workspace.yaml)
packages:
  - 'packages/**'
  - '!packages/**/dist'

// after (bun-compatible)
packages:
  - 'apps/*'
  - 'packages/*'
Defensive patterns

Strategy: validation

Validate before calling

function isBunCompatibleGlob(glob: string): boolean {
  if (glob.includes("*")) {
    if (glob.includes("**")) return false;
    const beforeLastSegment = glob.split("/").slice(0, -1).join("/");
    if (beforeLastSegment.includes("*")) return false;
  }
  return !["!", "[", "]", "{", "}"].some((c) => glob.includes(c));
}

const incompatible = project.workspaceData.globs.filter((g) => !isBunCompatibleGlob(g));
if (incompatible.length) {
  throw new Error(`Fix globs before bun conversion: ${incompatible.join(", ")}`);
}

Type guard

function isBunGlobError(e: unknown): boolean {
  return e instanceof ConvertError && e.type === "bun-workspace_glob_error";
}

Try / catch

try {
  await convertProject({ project, convertTo: bunDetails, logger });
} catch (e) {
  if (e instanceof ConvertError && e.type === "bun-workspace_glob_error") {
    // flatten globs (packages/** -> packages/*) or enumerate workspaces explicitly, then retry
  } else throw e;
}

Prevention

When it happens

Trigger: Converting to bun a workspace whose globs include 'packages/**', 'apps/*/lib', 'packages/{a,b}', or '!excluded-pkg' — patterns legal in pnpm/yarn workspaces but rejected by bun's implementation.

Common situations: pnpm-workspace.yaml with recursive globs for nested packages; monorepos using brace expansion or negation; yarn workspaces arrays with multiple levels.

Related errors


AI-assisted analysis of vercel/turborepo@9f94a7d215 (2026-08-16). Data as JSON: /api/errors/ea87eb3492a92cbc. Report an issue: GitHub.