Turborepo + SvelteKit deployment build directory not found error

I’m trying to deploy the official Turborepo + SvelteKit boilerplate from Vercel, found here, their repo here

Error Excerpt

3:35:37 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:35:37 PM: Failing build: Failed to build site
3:35:37 PM: Finished processing build request in 26.034s

…Deploy directory ‘build’ does not exist

Context

  • I’ve added netlify.toml pages to /web and /docs
  • My repo source code is here
  • My Netlify site name is svelte-turbo-ex-deployme
  • I read that the build command can give strange errors if it’s used. I’ve tried to rename the build command to buildme, but I got the same error either way.
  • I’ve downloaded netlify-cli locally and tested running netlify build locally. The apps/web/build and apps/docs/build directory are created correctly.
  • I’ve tried to change publish = "apps/docs/build" and publish = "apps/web/build" in the respective netlify.toml files, but got the same error

Logs

3:35:11 PM: build-image version: 73f16e520fdddf409be6f578c8c2c8941bdf32d3 (focal)
3:35:11 PM: buildbot version: a11acbb405af91d225b392f15bc00822dbffb366
3:35:11 PM: Fetching cached dependencies
3:35:11 PM: Failed to fetch cache, continuing with build
3:35:11 PM: Starting to prepare the repo for build
3:35:11 PM: No cached dependencies found. Cloning fresh repo
3:35:11 PM: git clone --filter=blob:none https://github.com/thebrianbug/svelte-turbo
3:35:11 PM: Preparing Git Reference refs/heads/main
3:35:13 PM: Starting to install dependencies
3:35:13 PM: Python version set to 3.8
3:35:13 PM: Attempting Ruby version 2.7.2, read from environment
3:35:14 PM: Using Ruby version 2.7.2
3:35:14 PM: Started restoring cached go cache
3:35:14 PM: Finished restoring cached go cache
3:35:15 PM: Installing Go version 1.19.13 (requested 1.19.x)
3:35:22 PM: go version go1.19.13 linux/amd64
3:35:22 PM: Using PHP version 8.0
3:35:23 PM: v18.17.1 is already installed.
3:35:23 PM: Now using node v18.17.1 (npm v9.6.7)
3:35:23 PM: Enabling Node.js Corepack
3:35:23 PM: Started restoring cached build plugins
3:35:23 PM: Finished restoring cached build plugins
3:35:23 PM: Started restoring cached corepack dependencies
3:35:23 PM: Finished restoring cached corepack dependencies
3:35:23 PM: npm workspaces detected
3:35:24 PM: Installing npm packages using npm version 9.6.7
3:35:25 PM: npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
3:35:25 PM: npm WARN deprecated @types/sass@1.45.0: This is a stub types definition. sass provides its own type definitions, so you do not need this installed.
3:35:27 PM: added 211 packages, and audited 216 packages in 3s
3:35:27 PM: 39 packages are looking for funding
3:35:27 PM:   run `npm fund` for details
3:35:27 PM: found 0 vulnerabilities
3:35:27 PM: npm packages installed
3:35:28 PM: Install dependencies script success
3:35:28 PM: Starting build script
3:35:28 PM: Detected 0 framework(s)
3:35:28 PM: Section completed: initializing
3:35:30 PM: ​
3:35:30 PM: Netlify Build                                                 
3:35:30 PM: ────────────────────────────────────────────────────────────────
3:35:30 PM: ​
3:35:30 PM: ❯ Version
3:35:30 PM:   @netlify/build 29.20.12
3:35:30 PM: ​
3:35:30 PM: ❯ Flags
3:35:30 PM:   baseRelDir: true
3:35:30 PM:   buildId: 65037c8d5e219f00089a23c0
3:35:30 PM:   deployId: 65037c8d5e219f00089a23c2
3:35:30 PM:   packagePath: apps/web
3:35:30 PM: ​
3:35:30 PM: ❯ Current directory
3:35:30 PM:   /opt/build/repo
3:35:30 PM: ​
3:35:30 PM: ❯ Config file
3:35:30 PM:   /opt/build/repo/apps/web/netlify.toml
3:35:30 PM: ​
3:35:30 PM: ❯ Context
3:35:30 PM:   production
3:35:30 PM: ​
3:35:30 PM: build.command from netlify.toml                               
3:35:30 PM: ────────────────────────────────────────────────────────────────
3:35:30 PM: ​
3:35:30 PM: $ npm run check && npm run build
3:35:30 PM: > check
3:35:30 PM: > turbo run check
3:35:30 PM: • Packages in scope: docs, eslint-config-custom, ui, web
3:35:30 PM: • Running check in 4 packages
3:35:30 PM: • Remote caching disabled
3:35:30 PM: docs:check: cache miss, executing 0c41624f937800c9
3:35:30 PM: web:check: cache miss, executing bb8f528ff6919a43
3:35:30 PM: docs:check: 
3:35:30 PM: docs:check: > docs@0.0.0 check
3:35:30 PM: docs:check: > svelte-check --tsconfig ./tsconfig.json
3:35:30 PM: docs:check: 
3:35:30 PM: web:check: 
3:35:30 PM: web:check: > web@0.0.0 check
3:35:30 PM: web:check: > svelte-check --tsconfig ./tsconfig.json
3:35:30 PM: web:check: 
3:35:31 PM: web:check: 
3:35:31 PM: web:check: ====================================
3:35:31 PM: web:check: Loading svelte-check in workspace: /opt/build/repo/apps/web
3:35:31 PM: web:check: Getting Svelte diagnostics...
3:35:31 PM: web:check: 
3:35:31 PM: docs:check: 
3:35:31 PM: docs:check: ====================================
3:35:31 PM: docs:check: Loading svelte-check in workspace: /opt/build/repo/apps/docs
3:35:31 PM: docs:check: Getting Svelte diagnostics...
3:35:31 PM: docs:check: 
3:35:32 PM: web:check: ====================================
3:35:32 PM: web:check: svelte-check found 0 errors, 0 warnings, and 0 hints
3:35:32 PM: web:check: 
3:35:32 PM: docs:check: ====================================
3:35:32 PM: docs:check: svelte-check found 0 errors, 0 warnings, and 0 hints
3:35:32 PM: docs:check: 
3:35:32 PM:  Tasks:    2 successful, 2 total
3:35:32 PM: Cached:    0 cached, 2 total
3:35:32 PM:   Time:    1.887s
3:35:32 PM: > build
3:35:32 PM: > turbo run build
3:35:32 PM: • Packages in scope: docs, eslint-config-custom, ui, web
3:35:32 PM: • Running build in 4 packages
3:35:32 PM: • Remote caching disabled
3:35:32 PM: docs:build: cache miss, executing 03244739048ba980
3:35:32 PM: web:build: cache miss, executing bfbff4f5be7cc228
3:35:32 PM: docs:build: 
3:35:32 PM: docs:build: > docs@0.0.0 build
3:35:32 PM: docs:build: > vite build
3:35:32 PM: docs:build: 
3:35:32 PM: web:build: 
3:35:32 PM: web:build: > web@0.0.0 build
3:35:32 PM: web:build: > vite build
3:35:32 PM: web:build: 
3:35:33 PM: web:build: 
3:35:33 PM: web:build: vite v4.4.9 building SSR bundle for production...
3:35:33 PM: docs:build: 
3:35:33 PM: docs:build: vite v4.4.9 building SSR bundle for production...
3:35:33 PM: web:build: transforming...
3:35:33 PM: docs:build: transforming...
3:35:34 PM: web:build: ✓ 53 modules transformed.
3:35:34 PM: docs:build: ✓ 53 modules transformed.
3:35:34 PM: web:build: rendering chunks...
3:35:34 PM: docs:build: rendering chunks...
3:35:34 PM: web:build: 
3:35:34 PM: web:build: vite v4.4.9 building for production...
3:35:34 PM: web:build: transforming...
3:35:34 PM: docs:build: 
3:35:34 PM: docs:build: vite v4.4.9 building for production...
3:35:34 PM: docs:build: transforming...
3:35:34 PM: web:build: ✓ 42 modules transformed.
3:35:34 PM: docs:build: ✓ 42 modules transformed.
3:35:34 PM: web:build: rendering chunks...
3:35:34 PM: docs:build: rendering chunks...
3:35:34 PM: docs:build: computing gzip size...
3:35:34 PM: web:build: computing gzip size...
3:35:34 PM: docs:build: .svelte-kit/output/client/_app/version.json                              0.03 kB │ gzip: 0.05 kB
3:35:34 PM: docs:build: .svelte-kit/output/client/vite-manifest.json                             1.85 kB │ gzip: 0.37 kB
3:35:34 PM: docs:build: .svelte-kit/output/client/_app/immutable/nodes/0.0d30871a.js             0.55 kB │ gzip: 0.37 kB
3:35:34 PM: docs:build: .svelte-kit/output/client/_app/immutable/nodes/1.f67b4ccb.js             0.98 kB │ gzip: 0.57 kB
3:35:34 PM: docs:build: .svelte-kit/output/client/_app/immutable/nodes/2.df00dbae.js             1.41 kB │ gzip: 0.74 kB
3:35:34 PM: docs:build: .svelte-kit/output/client/_app/immutable/chunks/singletons.074f1319.js   2.85 kB │ gzip: 1.46 kB
3:35:34 PM: docs:build: .svelte-kit/output/client/_app/immutable/entry/app.fba91eec.js           5.65 kB │ gzip: 2.27 kB
3:35:34 PM: docs:build: .svelte-kit/output/client/_app/immutable/chunks/index.20fe1016.js        7.15 kB │ gzip: 2.89 kB
3:35:34 PM: docs:build: .svelte-kit/output/client/_app/immutable/entry/start.01093f70.js        24.82 kB │ gzip: 9.78 kB
3:35:34 PM: web:build: .svelte-kit/output/client/_app/version.json                              0.03 kB │ gzip: 0.05 kB
3:35:34 PM: docs:build: ✓ built in 435ms
3:35:34 PM: web:build: .svelte-kit/output/client/vite-manifest.json                             1.85 kB │ gzip: 0.37 kB
3:35:34 PM: web:build: .svelte-kit/output/client/_app/immutable/nodes/0.0d30871a.js             0.55 kB │ gzip: 0.37 kB
3:35:34 PM: web:build: .svelte-kit/output/client/_app/immutable/nodes/1.95ca57c8.js             0.98 kB │ gzip: 0.57 kB
3:35:34 PM: web:build: .svelte-kit/output/client/_app/immutable/nodes/2.d418a360.js             1.41 kB │ gzip: 0.74 kB
3:35:34 PM: web:build: .svelte-kit/output/client/_app/immutable/chunks/singletons.e88881af.js   2.85 kB │ gzip: 1.46 kB
3:35:34 PM: web:build: .svelte-kit/output/client/_app/immutable/entry/app.137f8785.js           5.65 kB │ gzip: 2.27 kB
3:35:34 PM: web:build: .svelte-kit/output/client/_app/immutable/chunks/index.20fe1016.js        7.15 kB │ gzip: 2.89 kB
3:35:34 PM: web:build: .svelte-kit/output/client/_app/immutable/entry/start.adae03ed.js        24.82 kB │ gzip: 9.78 kB
3:35:34 PM: web:build: ✓ built in 448ms
3:35:34 PM: web:build: .svelte-kit/output/server/vite-manifest.json                   1.34 kB
3:35:34 PM: web:build: .svelte-kit/output/server/internal.js                          0.19 kB
3:35:34 PM: web:build: .svelte-kit/output/server/entries/fallbacks/layout.svelte.js   0.24 kB
3:35:34 PM: web:build: .svelte-kit/output/server/entries/pages/_page.svelte.js        0.59 kB
3:35:34 PM: web:build: .svelte-kit/output/server/entries/fallbacks/error.svelte.js    0.89 kB
3:35:34 PM: web:build: .svelte-kit/output/server/chunks/index.js                      3.27 kB
3:35:34 PM: web:build: .svelte-kit/output/server/chunks/internal.js                   5.37 kB
3:35:34 PM: web:build: .svelte-kit/output/server/index.js                            89.51 kB
3:35:34 PM: web:build: 
3:35:34 PM: web:build: Run npm run preview to preview your production build locally.
3:35:34 PM: web:build: 
3:35:34 PM: web:build: > Using @sveltejs/adapter-netlify
3:35:34 PM: web:build:   ✔ done
3:35:34 PM: web:build: ✓ built in 1.35s
3:35:34 PM: docs:build: .svelte-kit/output/server/vite-manifest.json                   1.34 kB
3:35:34 PM: docs:build: .svelte-kit/output/server/internal.js                          0.19 kB
3:35:34 PM: docs:build: .svelte-kit/output/server/entries/fallbacks/layout.svelte.js   0.24 kB
3:35:34 PM: docs:build: .svelte-kit/output/server/entries/pages/_page.svelte.js        0.59 kB
3:35:34 PM: docs:build: .svelte-kit/output/server/entries/fallbacks/error.svelte.js    0.89 kB
3:35:34 PM: docs:build: .svelte-kit/output/server/chunks/index.js                      3.27 kB
3:35:34 PM: docs:build: .svelte-kit/output/server/chunks/internal.js                   5.37 kB
3:35:34 PM: docs:build: .svelte-kit/output/server/index.js                            89.51 kB
3:35:34 PM: docs:build: 
3:35:34 PM: docs:build: Run npm run preview to preview your production build locally.
3:35:34 PM: docs:build: 
3:35:34 PM: docs:build: > Using @sveltejs/adapter-netlify
3:35:35 PM: docs:build:   ✔ done
3:35:35 PM: docs:build: ✓ built in 1.36s
3:35:35 PM:  Tasks:    2 successful, 2 total
3:35:35 PM: Cached:    0 cached, 2 total
3:35:35 PM:   Time:    2.315s
3:35:35 PM: ​
3:35:35 PM: (build.command completed in 4.7s)
3:35:35 PM: ​
3:35:35 PM: Functions bundling                                            
3:35:35 PM: ────────────────────────────────────────────────────────────────
3:35:35 PM: ​
3:35:35 PM: Packaging Functions from apps/web/.netlify/functions-internal directory:
3:35:35 PM:  - sveltekit-render.mjs
3:35:35 PM: ​
3:35:35 PM: ​
3:35:35 PM: (Functions bundling completed in 522ms)
3:35:35 PM: ​
3:35:35 PM: Deploy site                                                   
3:35:35 PM: ────────────────────────────────────────────────────────────────
3:35:35 PM: ​
3:35:35 PM: Section completed: deploying
3:35:35 PM: ​
3:35:35 PM: Configuration error                                           
3:35:35 PM: ────────────────────────────────────────────────────────────────
3:35:35 PM: ​
3:35:35 PM:   Error message
3:35:35 PM:   Deploy did not succeed: Deploy directory 'build' does not exist
3:35:35 PM: ​
3:35:35 PM:   Resolved config
3:35:35 PM:   build:
3:35:35 PM:     command: npm run check && npm run build
3:35:35 PM:     commandOrigin: config
3:35:35 PM:     publish: /opt/build/repo/build
3:35:35 PM:     publishOrigin: config
3:35:36 PM: Caching artifacts
3:35:36 PM: Started saving workspace root node modules
3:35:36 PM: Finished saving workspace root node modules
3:35:36 PM: Started saving build plugins
3:35:36 PM: Finished saving build plugins
3:35:36 PM: Started saving corepack cache
3:35:36 PM: Finished saving corepack cache
3:35:36 PM: Started saving pip cache
3:35:36 PM: Finished saving pip cache
3:35:36 PM: Started saving emacs cask dependencies
3:35:36 PM: Finished saving emacs cask dependencies
3:35:36 PM: Started saving maven dependencies
3:35:36 PM: Finished saving maven dependencies
3:35:36 PM: Started saving boot dependencies
3:35:36 PM: Finished saving boot dependencies
3:35:36 PM: Started saving rust rustup cache
3:35:36 PM: Finished saving rust rustup cache
3:35:36 PM: Started saving go dependencies
3:35:36 PM: Finished saving go dependencies
3:35:37 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:35:37 PM: Failing build: Failed to build site
3:35:37 PM: Finished processing build request in 26.034s

Build settings

1 Like

Could you share a link to the deploys of these attempts?

I have quite a similar setup and am facing the same issue.

My stack is:

Pnpm + Workspaces + SvelteKit + Netlify Adapter

I also tried relative and absolute paths. Does not help.

With an absolute path as “publish” dir

5:11:36 PM: build-image version: e70ad4c6ce38c2b84143366f988574c7090c7a66 (focal)
5:11:36 PM: buildbot version: 772f37e89357306aa6b5e4cd44b7e7caa3511258
5:11:36 PM: Fetching cached dependencies
5:11:36 PM: Starting to download cache of 1.1GB
5:11:53 PM: Finished downloading cache in 16.848s
5:11:53 PM: Starting to extract cache
5:12:00 PM: Finished extracting cache in 7.673s
5:12:00 PM: Finished fetching cache in 24.63s
5:12:00 PM: Starting to prepare the repo for build
5:12:01 PM: Preparing Git Reference refs/heads/main
5:12:02 PM: Custom publish path detected. Proceeding with the specified path: "apps/webspace/build"
5:12:02 PM: Custom build command detected. Proceeding with the specified command: "pnpm build:webspace"
5:12:03 PM: Starting to install dependencies
5:12:03 PM: Python version set to 3.8
5:12:03 PM: Attempting Ruby version 2.7.2, read from environment
5:12:04 PM: Using Ruby version 2.7.2
5:12:04 PM: Started restoring cached go cache
5:12:04 PM: Finished restoring cached go cache
5:12:04 PM: go version go1.19.13 linux/amd64
5:12:04 PM: Using PHP version 8.0
5:12:05 PM: Started restoring cached Node.js version
5:12:06 PM: Finished restoring cached Node.js version
5:12:07 PM: v18.18.0 is already installed.
5:12:07 PM: Now using node v18.18.0 (npm v9.8.1)
5:12:07 PM: Enabling Node.js Corepack
5:12:07 PM: Started restoring cached build plugins
5:12:07 PM: Finished restoring cached build plugins
5:12:07 PM: Started restoring cached corepack dependencies
5:12:07 PM: Finished restoring cached corepack dependencies
5:12:07 PM: pnpm workspaces detected
5:12:07 PM: Started restoring workspace apps/webspace node modules
5:12:07 PM: Finished restoring workspace apps/webspace node modules
5:12:07 PM: Started restoring workspace root node modules
5:12:07 PM: Finished restoring workspace root node modules
5:12:07 PM: Installing npm packages using pnpm version 8.7.6
5:12:08 PM: Scope: all 2 workspace projects
5:12:08 PM: Lockfile is up to date, resolution step is skipped
5:12:08 PM: Already up to date
5:12:08 PM: . prepare$ husky install
5:12:08 PM: . prepare: husky - Git hooks installed
5:12:08 PM: . prepare: Done
5:12:08 PM: Done in 1s
5:12:08 PM: npm packages installed using pnpm
5:12:09 PM: Install dependencies script success
5:12:09 PM: Starting build script
5:12:10 PM: Detected 0 framework(s)
5:12:10 PM: Section completed: initializing
5:12:11 PM: ​
5:12:11 PM: Netlify Build                                                 
5:12:11 PM: ────────────────────────────────────────────────────────────────
5:12:11 PM: ​
5:12:11 PM: ❯ Version
5:12:11 PM:   @netlify/build 29.22.1
5:12:11 PM: ​
5:12:11 PM: ❯ Flags
5:12:11 PM:   baseRelDir: true
5:12:11 PM:   buildId: 652569a62d1ecf00075b4ed3
5:12:11 PM:   deployId: 652569a62d1ecf00075b4ed5
5:12:11 PM:   packagePath: apps/webspace
5:12:11 PM: ​
5:12:11 PM: ❯ Current directory
5:12:11 PM:   /opt/build/repo
5:12:11 PM: ​
5:12:11 PM: ❯ Config file
5:12:11 PM:   /opt/build/repo/apps/webspace/netlify.toml
5:12:11 PM: ​
5:12:11 PM: ❯ Context
5:12:11 PM:   production
5:12:11 PM: ​
5:12:11 PM: ❯ Installing plugins
5:12:11 PM:    - @netlify/plugin-lighthouse@5.0.0
5:12:21 PM: ​
5:12:21 PM: ❯ Loading plugins
5:12:21 PM:    - @netlify/plugin-lighthouse@5.0.0 from Netlify app
5:12:22 PM: ​
5:12:22 PM: build.command from netlify.toml                               
5:12:22 PM: ────────────────────────────────────────────────────────────────
5:12:22 PM: ​
5:12:22 PM: $ pnpm build:webspace
5:12:23 PM: > xxxxxxx@1.0.0 build:webspace /opt/build/repo
5:12:23 PM: > pnpm --filter "./apps/webspace" build
5:12:23 PM: >xxxxxxx@0.0.1 build /opt/build/repo/apps/webspace
5:12:23 PM: > svelte-kit sync && vite build
5:12:25 PM: vite v4.4.11 building SSR bundle for production...
5:12:25 PM: transforming...
5:12:26 PM: ✓ 185 modules transformed.
5:12:26 PM: rendering chunks...
5:12:27 PM: vite v4.4.11 building for production...
5:12:27 PM: transforming...
5:12:28 PM: ✓ 158 modules transformed.
5:12:28 PM: rendering chunks...
5:12:28 PM: computing gzip size...
....
5:12:28 PM: ✓ built in 1.43s
....
5:12:29 PM: Run npm run preview to preview your production build locally.
5:12:29 PM: 
5:12:29 PM: > Using @sveltejs/adapter-netlify
5:12:29 PM:   ✔ done
5:12:29 PM: ✓ built in 4.56s
5:12:29 PM: ​
5:12:29 PM: (build.command completed in 6.7s)
5:12:29 PM: ​
5:12:29 PM: Functions bundling                                            
5:12:29 PM: ────────────────────────────────────────────────────────────────
5:12:29 PM: ​
5:12:29 PM: Packaging Functions from apps/webspace/.netlify/functions-internal directory:
5:12:29 PM:  - sveltekit-render.mjs
5:12:29 PM: ​
5:12:32 PM: ​
5:12:32 PM: (Functions bundling completed in 2.5s)
5:12:32 PM: ​
5:12:32 PM: Deploy site                                                   
5:12:32 PM: ────────────────────────────────────────────────────────────────
5:12:32 PM: ​
5:12:32 PM: Section completed: deploying
5:12:32 PM: ​
5:12:32 PM: Configuration error                                           
5:12:32 PM: ────────────────────────────────────────────────────────────────
5:12:32 PM: ​
5:12:32 PM:   Error message
5:12:32 PM:   Deploy did not succeed: Deploy directory "apps/webspace/build" does not exist
5:12:32 PM: ​
5:12:32 PM:   Resolved config
5:12:32 PM:   build:
5:12:32 PM:     command: pnpm build:webspace
5:12:32 PM:     commandOrigin: config
5:12:32 PM:     environment:
5:12:32 PM:       - xxxxxxx
5:12:32 PM:       - xxxxxxx
5:12:32 PM:       - xxxxxxx
5:12:32 PM:     publish: /opt/build/repo/apps/webspace/build
5:12:32 PM:     publishOrigin: config
5:12:32 PM:   plugins:
5:12:32 PM:     - inputs: {}
5:12:32 PM:       origin: ui
5:12:32 PM:       package: "@netlify/plugin-lighthouse"
5:12:32 PM: Caching artifacts
5:12:32 PM: Started saving workspace apps/webspace node modules
5:12:32 PM: Finished saving workspace apps/webspace node modules
5:12:32 PM: Started saving workspace root node modules
5:12:32 PM: Finished saving workspace root node modules
5:12:32 PM: Started saving build plugins
5:12:33 PM: Failed during stage "building site": Build script returned non-zero exit code: 2
5:12:33 PM: Finished saving build plugins
5:12:33 PM: Started saving corepack cache
5:12:33 PM: Finished saving corepack cache
5:12:33 PM: Started saving pip cache
5:12:33 PM: Finished saving pip cache
5:12:33 PM: Started saving emacs cask dependencies
5:12:33 PM: Finished saving emacs cask dependencies
5:12:33 PM: Started saving maven dependencies
5:12:33 PM: Finished saving maven dependencies
5:12:33 PM: Started saving boot dependencies
5:12:33 PM: Finished saving boot dependencies
5:12:33 PM: Started saving rust rustup cache
5:12:33 PM: Finished saving rust rustup cache
5:12:33 PM: Started saving go dependencies
5:12:33 PM: Finished saving go dependencies
5:12:33 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:12:33 PM: Failing build: Failed to build site
5:12:33 PM: Finished processing build request in 57.223s

With a relative path as “publish” dir

4:43:23 PM: build-image version: e70ad4c6ce38c2b84143366f988574c7090c7a66 (focal)
4:43:23 PM: buildbot version: 772f37e89357306aa6b5e4cd44b7e7caa3511258
4:43:23 PM: Fetching cached dependencies
4:43:23 PM: Starting to download cache of 1.1GB
4:43:39 PM: Finished downloading cache in 16.397s
4:43:39 PM: Starting to extract cache
4:43:46 PM: Finished extracting cache in 6.63s
4:43:46 PM: Finished fetching cache in 23.144s
4:43:46 PM: Starting to prepare the repo for build
4:43:46 PM: Preparing Git Reference refs/heads/main
4:43:48 PM: Custom build command detected. Proceeding with the specified command: "pnpm build:webspace"
4:43:48 PM: Starting to install dependencies
4:43:48 PM: Python version set to 3.8
4:43:48 PM: Attempting Ruby version 2.7.2, read from environment
4:43:49 PM: Using Ruby version 2.7.2
4:43:49 PM: Started restoring cached go cache
4:43:49 PM: Finished restoring cached go cache
4:43:50 PM: go version go1.19.13 linux/amd64
4:43:50 PM: Using PHP version 8.0
4:43:51 PM: Started restoring cached Node.js version
4:43:52 PM: Finished restoring cached Node.js version
4:43:52 PM: v18.18.0 is already installed.
4:43:52 PM: Now using node v18.18.0 (npm v9.8.1)
4:43:52 PM: Enabling Node.js Corepack
4:43:52 PM: Started restoring cached build plugins
4:43:52 PM: Finished restoring cached build plugins
4:43:52 PM: Started restoring cached corepack dependencies
4:43:52 PM: Finished restoring cached corepack dependencies
4:43:52 PM: pnpm workspaces detected
4:43:52 PM: Started restoring workspace apps/webspace node modules
4:43:52 PM: Finished restoring workspace apps/webspace node modules
4:43:52 PM: Started restoring workspace root node modules
4:43:52 PM: Finished restoring workspace root node modules
4:43:53 PM: Installing npm packages using pnpm version 8.7.6
4:43:53 PM: Scope: all 2 workspace projects
4:43:53 PM: Lockfile is up to date, resolution step is skipped
4:43:53 PM: Already up to date
4:43:54 PM: . prepare$ husky install
4:43:54 PM: . prepare: husky - Git hooks installed
4:43:54 PM: . prepare: Done
4:43:54 PM: Done in 1s
4:43:54 PM: npm packages installed using pnpm
4:43:54 PM: Install dependencies script success
4:43:54 PM: Starting build script
4:43:55 PM: Detected 0 framework(s)
4:43:55 PM: Section completed: initializing
4:43:57 PM: ​
4:43:57 PM: Netlify Build                                                 
4:43:57 PM: ────────────────────────────────────────────────────────────────
4:43:57 PM: ​
4:43:57 PM: ❯ Version
4:43:57 PM:   @netlify/build 29.22.1
4:43:57 PM: ​
4:43:57 PM: ❯ Flags
4:43:57 PM:   baseRelDir: true
4:43:57 PM:   buildId: 652563092366ab0008d18eb1
4:43:57 PM:   deployId: 652563092366ab0008d18eb3
4:43:57 PM:   packagePath: apps/webspace
4:43:57 PM: ​
4:43:57 PM: ❯ Current directory
4:43:57 PM:   /opt/build/repo
4:43:57 PM: ​
4:43:57 PM: ❯ Config file
4:43:57 PM:   /opt/build/repo/apps/webspace/netlify.toml
4:43:57 PM: ​
4:43:57 PM: ❯ Context
4:43:57 PM:   production
4:43:57 PM: ​
4:43:57 PM: ❯ Installing plugins
4:43:57 PM:    - @netlify/plugin-lighthouse@5.0.0
4:44:07 PM: ​
4:44:07 PM: ❯ Loading plugins
4:44:07 PM:    - @netlify/plugin-lighthouse@5.0.0 from Netlify app
4:44:08 PM: ​
4:44:08 PM: build.command from netlify.toml                               
4:44:08 PM: ────────────────────────────────────────────────────────────────
4:44:08 PM: ​
4:44:08 PM: $ pnpm build:webspace
4:44:09 PM: > xxxxxxx@1.0.0 build:webspace /opt/build/repo
4:44:09 PM: > pnpm --filter "./apps/webspace" build
4:44:09 PM: > xxxxxxx@0.0.1 build /opt/build/repo/apps/webspace
4:44:09 PM: > svelte-kit sync && vite build
4:44:11 PM: vite v4.4.11 building SSR bundle for production...
4:44:11 PM: transforming...
4:44:13 PM: ✓ 185 modules transformed.
4:44:13 PM: rendering chunks...
4:44:14 PM: vite v4.4.11 building for production...
4:44:14 PM: transforming...
4:44:15 PM: ✓ 158 modules transformed.
4:44:15 PM: rendering chunks...
4:44:15 PM: computing gzip size...
....
4:44:15 PM: ✓ built in 1.46s
....
4:44:16 PM: Run npm run preview to preview your production build locally.
4:44:16 PM: 
4:44:16 PM: > Using @sveltejs/adapter-netlify
4:44:16 PM:   ✔ done
4:44:16 PM: ✓ built in 5.22s
4:44:16 PM: ​
4:44:16 PM: (build.command completed in 7.7s)
4:44:16 PM: ​
4:44:16 PM: Functions bundling                                            
4:44:16 PM: ────────────────────────────────────────────────────────────────
4:44:16 PM: ​
4:44:16 PM: Packaging Functions from apps/webspace/.netlify/functions-internal directory:
4:44:16 PM:  - sveltekit-render.mjs
4:44:16 PM: ​
4:44:19 PM: ​
4:44:19 PM: (Functions bundling completed in 2.8s)
4:44:19 PM: ​
4:44:19 PM: Deploy site                                                   
4:44:19 PM: ────────────────────────────────────────────────────────────────
4:44:19 PM: ​
4:44:19 PM: Section completed: deploying
4:44:19 PM: ​
4:44:19 PM: Configuration error                                           
4:44:19 PM: ────────────────────────────────────────────────────────────────
4:44:19 PM: ​
4:44:19 PM:   Error message
4:44:19 PM:   Deploy did not succeed: Deploy directory "build" does not exist
4:44:19 PM: ​
4:44:19 PM:   Resolved config
4:44:19 PM:   build:
4:44:19 PM:     command: pnpm build:webspace
4:44:19 PM:     commandOrigin: config
4:44:19 PM:     environment:
4:44:19 PM:       - xxxxxxx
4:44:19 PM:       - xxxxxxx
4:44:19 PM:       - xxxxxxx
4:44:19 PM:     publish: /opt/build/repo/build
4:44:19 PM:     publishOrigin: config
4:44:19 PM:   plugins:
4:44:19 PM:     - inputs: {}
4:44:19 PM:       origin: ui
4:44:19 PM:       package: "@netlify/plugin-lighthouse"
4:44:20 PM: Failed during stage "building site": Build script returned non-zero exit code: 2
4:44:20 PM: Caching artifacts
4:44:20 PM: Started saving workspace apps/webspace node modules
4:44:20 PM: Finished saving workspace apps/webspace node modules
4:44:20 PM: Started saving workspace root node modules
4:44:20 PM: Finished saving workspace root node modules
4:44:20 PM: Started saving build plugins
4:44:20 PM: Finished saving build plugins
4:44:20 PM: Started saving corepack cache
4:44:20 PM: Finished saving corepack cache
4:44:20 PM: Started saving pip cache
4:44:20 PM: Finished saving pip cache
4:44:20 PM: Started saving emacs cask dependencies
4:44:20 PM: Finished saving emacs cask dependencies
4:44:20 PM: Started saving maven dependencies
4:44:20 PM: Finished saving maven dependencies
4:44:20 PM: Started saving boot dependencies
4:44:20 PM: Finished saving boot dependencies
4:44:20 PM: Started saving rust rustup cache
4:44:20 PM: Finished saving rust rustup cache
4:44:20 PM: Started saving go dependencies
4:44:20 PM: Finished saving go dependencies
4:44:20 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:44:20 PM: Failing build: Failed to build site
4:44:20 PM: Finished processing build request in 57.501s

So after countless attempts to fix an issue using the toml file, I found a workaround.

You have to define the “publish path” at Netlify UI and remove it from toml file.

I think the issue is related to the conflict between sveltejs/adapter-netlify and the toml file.

let’s say the general monorepo setup is:

---/ monorepo
  ---/ apps
      ---/ my-fancy-svelte-kit-app
          ---/ netlify.toml

Since Netlify demands to define a “publish path” relative to “base dir” the toml file might look like this

[build]
    command = "pnpm --filter "./apps/my-fancy-svelte-kit-app" build"
    publish = "apps/my-fancy-svelte-kit-app/build"

if you are (most probably are) using sveltejs/adapter-netlify, then during app build step it reads the workspace toml file and takes “publish path” to define a “build” folder path relative to workspace itself.

---/ monorepo
  ---/ apps
      ---/ my-fancy-svelte-kit-app
          ---/ apps
              ---/ my-fancy-svelte-kit-app
                  ---/ build
          ---/ netlify.toml

that’s why Netlify failed to find the “build” folder by searching: “apps/my-fancy-svelte-kit-app/build”.

I’m not sure which team is responsible for addressing the issue. Most probably sveltekit.
I’ll try to submit a GitHub issue to their repo.

Can you explain your work around? I am having this same issue.

TL:DR

Do not set publish path using netlify.toml file. Instead login into netlify app UI and set it there.

The reason: svelte-kit netlify adapter reads toml file during the build process. That outputs the bundle dist folder to the wrong destination. Therefore deploy could not find it.

I decided to step out of GitHub integration and deploy my app using netlify cli.

Runtime: Not set
Base directory: /
Package directory: apps/my-site
Build command: turbo run build --filter=my-site
Publish directory: build (or) apps/my-site/build
Functions directory: netlify/functions
Build status: Active

what would you change the build dir to to fix this issue?

It would be hard to say without seeing a repo.

Do you think this is on the svelte plugin side or the netlify side?

My reply would still be the same… hard to say anything without seeing a repo that we can check.