Skip to content

google.nodejs.turborepo buildpack ignores GOOGLE_BUILDABLE and targets root package #623

Description

@thecannabisapp

Describe the bug

The google.nodejs.turborepo buildpack (v0.0.1) fails to respect the GOOGLE_BUILDABLE environment variable when running in Firebase App Hosting, causing it to target the root package name instead of the intended workspace application.

Additional context
How are you using GCP buildpacks?

  • pack and the gcr.io/buildpacks/builder
  • Cloud Functions
  • Cloud Run
  • Cloud Build
  • App Engine Standard
  • App Engine Flex
  • Firebase App Hosting

Did this used to work?
No. The bug is reproducible every time the turborepo buildpack participates in a Firebase App Hosting build where GOOGLE_BUILDABLE points to a sub-directory workspace application.

What language is your project primarily written in?
Node.js (Next.js 16.2.3, Turborepo 2.9.6, npm workspaces)

Steps To Reproduce

  1. Create a standard npm-workspace Turborepo monorepo:
    workspaces: ["apps/*", "packages/*"]
  2. Place turbo.json at the repo root.
  3. Create a Next.js app in apps/web with package.json name @meandma/web.
  4. Ensure the root package.json has a different name (e.g. meandma) and is not included in workspaces.
  5. Configure Firebase App Hosting with:
    • firebase.json: rootDir: "."
    • apphosting.yaml: GOOGLE_BUILDABLE=apps/web
  6. Push to trigger a deployment.

Expected behavior

The turborepo buildpack should read GOOGLE_BUILDABLE=apps/web, resolve the package.json at apps/web/package.json, and execute:

turbo run build --filter=@meandma/web --env-mode=loose

Actual behavior

The buildpack targets the root package name instead:

• turbo 2.9.6
  x No package found with name 'meandma' in workspace

It appears to be running turbo run build --filter=meandma, ignoring the GOOGLE_BUILDABLE value entirely.

Build Log Excerpt

Step #1 - "preparer": - variable: GOOGLE_BUILDABLE
Step #1 - "preparer":   value: apps/web
...
Step #3 - "build": === Node.js - Turborepo Using Runner (google.nodejs.turborepo@0.0.1) ===
...
Step #3 - "build": • turbo 2.9.6
Step #3 - "build":   x No package found with name 'meandma' in workspace

Full error from Cloud Build:

Error: Build process exited with error code 1.

Root Cause Analysis

Looking at the buildpack source (cmd/nodejs/turborepo/lib/lib.go), BuildFn calls util.ApplicationDirectory(ctx), which is supposed to check env.Buildable (GOOGLE_BUILDABLE) and return the subdirectory path. However, ApplicationDirectory uses os.LookupEnv, which only reads the OS process environment. In Firebase App Hosting, GOOGLE_BUILDABLE is injected via the buildpack platform environment (BuildContext.Platform.Environment), so the resolution falls back to ctx.ApplicationRoot(). This causes appPackageJSON to be read from the root package.json (name: meandma) rather than apps/web/package.json (name: @meandma/web).

Workaround

Rename turbo.json to turbo.jsonc (which Turbo CLI supports but the buildpack does not detect). This prevents google.nodejs.turborepo from participating in the build. The google.nodejs.firebasenextjs buildpack then falls back to the root build script, which can handle the monorepo build correctly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions