vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.21k stars 1.81k forks source link

[turborepo] Getting "Missing public directory" error on *cache hit* #6489

Closed thomasmost closed 11 months ago

thomasmost commented 11 months ago

What version of Turborepo are you using?

1.10.16

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Describe the Bug

I am getting a "Missing public directory" error on cache hits for my newly added CRA app

The error is: Error: No Output Directory named "build" found after the Build completed. You can configure the Output Directory in your Project Settings.

It seems like Turbo doesn't know to cache the build directory — is there a way to specify this?

Full logs:


Running build in Washington, D.C., USA (East) – iad1 (Hive)
16:44:01.700 | Cloning github.com/Bend-Green/web (Branch: main, Commit: 4e20825)
16:44:04.099 | Cloning completed: 2.399s
16:44:14.549 | Restored build cache
16:44:14.623 | Running "vercel build"
16:44:15.185 | Vercel CLI 32.5.5
16:44:15.369 | > Detected Turbo. Adjusting default settings...
16:44:16.227 | Detected `pnpm-lock.yaml` version 6 generated by pnpm 8
16:44:16.228 | Running "install" command: `pnpm install`...
16:44:17.142 | Scope: all 12 workspace projects
16:44:17.263 |  
16:44:17.263 | ╭──────────────────────────────────────────────────────────────────╮
16:44:17.263 | │                                                                  │
16:44:17.263 | │                Update available! 8.10.2 → 8.10.5.                │
16:44:17.263 | │   Changelog: https://github.com/pnpm/pnpm/releases/tag/v8.10.5   │
16:44:17.264 | │                Run "pnpm add -g pnpm" to update.                 │
16:44:17.264 | │                                                                  │
16:44:17.264 | │      Follow @pnpmjs for updates: https://twitter.com/pnpmjs      │
16:44:17.264 | │                                                                  │
16:44:17.264 | ╰──────────────────────────────────────────────────────────────────╯
16:44:17.264 |  
16:44:19.125 | ../..                                    \|    +1871 ++++++++++++++++++++++++++++
16:44:20.685 |  
16:44:20.705 | ../.. prepare$ husky install
16:44:20.996 | ../.. prepare: husky - Git hooks installed
16:44:21.001 | ../.. prepare: Done
16:44:21.055 | Done in 4.6s
16:44:21.258 | • Packages in scope: docs
16:44:21.258 | • Running build in 1 packages
16:44:21.258 | • Remote caching enabled
16:44:21.445 | docs:build: cache hit, replaying logs e1b89f7b7185efa9
16:44:21.445 | docs:build:
16:44:21.445 | docs:build: > docs@0.0.0 build /vercel/path0/apps/docs
16:44:21.445 | docs:build: > react-scripts build
16:44:21.445 | docs:build:
16:44:21.445 | docs:build: Creating an optimized production build...
16:44:21.446 | docs:build: Compiled successfully.
16:44:21.446 | docs:build:
16:44:21.446 | docs:build: File sizes after gzip:
16:44:21.446 | docs:build:
16:44:21.446 | docs:build:   334.19 kB  build/static/js/main.a11304da.js
16:44:21.446 | docs:build:   1.77 kB    build/static/js/948.7059921e.chunk.js
16:44:21.446 | docs:build:
16:44:21.446 | docs:build: The project was built assuming it is hosted at /.
16:44:21.446 | docs:build: You can control this with the homepage field in your package.json.
16:44:21.446 | docs:build:
16:44:21.446 | docs:build: The build folder is ready to be deployed.
16:44:21.446 | docs:build: You may serve it with a static server:
16:44:21.446 | docs:build:
16:44:21.446 | docs:build:   npm install -g serve
16:44:21.446 | docs:build:   serve -s build
16:44:21.446 | docs:build:
16:44:21.446 | docs:build: Find out more about deployment here:
16:44:21.446 | docs:build:
16:44:21.446 | docs:build:   https://cra.link/deployment
16:44:21.447 | docs:build:
16:44:21.447 |  
16:44:21.447 | Tasks:    1 successful, 1 total
16:44:21.447 | Cached:    1 cached, 1 total
16:44:21.447 | Time:    292ms >>> FULL TURBO
16:44:21.447 | Summary:    /vercel/path0/.turbo/runs/2YH8I4YEB7ErM7l22txqSOnaVZa.json
16:44:21.447 |  
16:44:21.509 | Error: No Output Directory named "build" found after the Build completed. You can configure the Output Directory in your Project Settings.
16:44:21.509 | Learn More: https://vercel.link/missing-public-directory
16:44:22.634

Expected Behavior

On a cache hit, the output directory (build) from the cache should be used

To Reproduce

Deploy a turbo repo with a Create React App member?

Reproduction Repo

No response

anhtuanlee commented 8 months ago

how to use fix this ? i have same issue

Ifunanyacollins commented 4 months ago

@thomasmost how did you resolve this error?

awesome-pro commented 1 week ago

@thomasmost I am having same issue, how did you solve it

wooiliang commented 1 week ago

Not sure if it helps. Please try this https://turbo.build/repo/docs/reference/configuration#outputs

jeevanpillay commented 3 days ago

in vercel project settings set root directory to apps/web or whichever app you trying to deploy.

ps if you havent already; select nextjs as framework preset. build command is turbo run build.