Deploy directory 'target' does not exist

After running my build script, my build has started to fail with the error “Deploy directory ‘target’ does not exist”. While debugging this, I added an ls to my build script which shows that the target directory does exist, so I’m confused. I also tried re-deploying the last commit that resulted in a successful build, but now that fails too. Below, find my build settings and build log (less interesting parts removed to stay under the new-user character and link limits). Please let me know if I can provide any other info.

build settings:

build log:

    2:55:31 PM: Build ready to start
2:55:33 PM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
2:55:33 PM: build-image tag: v3.6.0
2:55:33 PM: buildbot version: dc0a2b81d00d8f0151c0b6d6eab301febfb9ab68
2:55:33 PM: Fetching cached dependencies
2:55:33 PM: Starting to download cache of 154.3MB
2:55:36 PM: Finished downloading cache in 3.077149095s
2:55:36 PM: Starting to extract cache
2:55:40 PM: Finished extracting cache in 4.140700854s
2:55:41 PM: Finished fetching cache in 7.312324085s
2:55:41 PM: Starting to prepare the repo for build
2:55:41 PM: Preparing Git Reference refs/heads/main
2:55:43 PM: Starting build script
2:55:43 PM: Installing dependencies
2:55:43 PM: Python version set to 2.7
2:55:44 PM: Started restoring cached node version
2:55:47 PM: Finished restoring cached node version
2:55:47 PM: v12.18.0 is already installed.
2:55:48 PM: Now using node v12.18.0 (npm v6.14.4)
2:55:48 PM: Started restoring cached build plugins
2:55:48 PM: Finished restoring cached build plugins
2:55:48 PM: Attempting ruby version 2.7.1, read from environment
2:55:50 PM: Using ruby version 2.7.1
2:55:50 PM: Using PHP version 5.6
2:55:50 PM: Started restoring cached node modules
2:55:50 PM: Finished restoring cached node modules
2:55:50 PM: Installing NPM modules using NPM version 6.14.4
2:55:55 PM: added 13 packages from 7 contributors, removed 21 packages, updated 22 packages and audited 194 packages in 3.405s
2:55:55 PM: 13 packages are looking for funding
2:55:55 PM:   run `npm fund` for details
2:55:55 PM: found 0 vulnerabilities
2:55:55 PM: NPM modules installed
2:55:55 PM: Started restoring cached go cache
2:55:55 PM: Finished restoring cached go cache
2:55:55 PM: go version go1.14.4 linux/amd64
2:55:55 PM: go version go1.14.4 linux/amd64
2:55:55 PM: Installing missing commands
2:55:55 PM: Verify run directory
2:55:57 PM: ​
2:55:57 PM: ────────────────────────────────────────────────────────────────
2:55:57 PM:   Netlify Build                                                 
2:55:57 PM: ────────────────────────────────────────────────────────────────
2:55:57 PM: ​
2:55:57 PM: ❯ Version
2:55:57 PM:   @netlify/build 8.0.0
2:55:57 PM: ​
2:55:57 PM: ❯ Flags
2:55:57 PM:   deployId: 5fd93ee377bf32000726caf1
2:55:57 PM:   mode: buildbot
2:55:57 PM: ​
2:55:57 PM: ❯ Current directory
2:55:57 PM:   /opt/build/repo
2:55:57 PM: ​
2:55:57 PM: ❯ Config file
2:55:57 PM:   No config file was defined: using default values.
2:55:57 PM: ​
2:55:57 PM: ❯ Context
2:55:57 PM:   production
2:55:57 PM: ​
2:55:57 PM: ────────────────────────────────────────────────────────────────
2:55:57 PM:   1. Build command from Netlify app                             
2:55:57 PM: ────────────────────────────────────────────────────────────────
2:55:57 PM: ​
2:55:57 PM: $ bin/release-assets
2:55:57 PM: + bin/release-clean
2:55:57 PM: + bin/release-html
2:55:57 PM: + bin/release-css
2:55:58 PM:    tailwindcss 2.0.2
2:55:58 PM:    🚀 Building: resources/public/css/styles.css
2:56:05 PM:    ✅ Finished in 7.42 s
2:56:05 PM:    📦 Size: 17.98KB
2:56:05 PM:    💾 Saved to target/css/compiled/styles.css
2:56:05 PM: + bin/release-js
2:56:05 PM: shadow-cljs - config: /opt/build/repo/shadow-cljs.edn
2:56:05 PM: shadow-cljs - starting via "clojure"
2:56:10 PM: Downloading: org/clojure/clojure/1.10.1/clojure-1.10.1.pom from ...
2:56:10 PM: Downloading: org/clojure/data.csv/1.0.0/data.csv-1.0.0.pom from ...
2:56:10 PM: Downloading: org/clojure/pom.contrib/0.2.2/pom.contrib-0.2.2.pom from ...
...
2:56:22 PM: Downloading: org/ow2/asm/asm-tree/7.1/asm-tree-7.1.jar from ...
2:56:22 PM: Downloading: org/clojure/core.async/1.3.610/core.async-1.3.610.jar from ...
2:56:22 PM: Downloading: javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar from ...
2:56:22 PM: Downloading: com/google/code/gson/gson/2.7/gson-2.7.jar from ...
2:56:39 PM: NPM dependency "react" has installed version "16.14.0"
2:56:39 PM: "16.13.0" was required by jar:file:/opt/buildhome/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
2:56:39 PM: NPM dependency "react-dom" has installed version "16.14.0"
2:56:39 PM: "16.13.0" was required by jar:file:/opt/buildhome/.m2/repository/reagent/reagent/0.10.0/reagent-0.10.0.jar!/deps.cljs
2:56:48 PM: :app Compiling ...
2:57:23 PM: :app Build completed. (117 files, 53 compiled, 0 warnings, 34.83s)
2:57:24 PM: + ls -la .
2:57:24 PM: total 140
2:57:24 PM: drwxr-xr-x  12 buildbot root     4096 Dec 15 22:56 .
2:57:24 PM: drwxr-xr-x   4 buildbot root     4096 Dec 15 22:55 ..
2:57:24 PM: drwxr-xr-x   2 buildbot root     4096 Dec 15 22:55 bin
2:57:24 PM: drwxr-xr-x   2 buildbot nogroup  4096 Dec 15 22:56 .cpcache
2:57:24 PM: drwxr-xr-x   2 buildbot root     4096 Dec 15 22:55 data
2:57:24 PM: -rw-r--r--   1 buildbot root      358 Dec 15 22:55 deps.edn
2:57:24 PM: drwxr-xr-x   7 buildbot root     4096 Dec 15 22:55 .git
2:57:24 PM: -rw-r--r--   1 buildbot root       94 Dec 15 22:55 .gitignore
2:57:24 PM: -rw-r--r--   1 buildbot root     1288 Dec 15 22:55 Makefile
2:57:24 PM: drwxr-xr-x   3 buildbot nogroup  4096 Dec 15 22:55 .netlify
2:57:24 PM: drwxr-xr-x 168 buildbot nogroup  4096 Dec 15 22:55 node_modules
2:57:24 PM: -rw-r--r--   1 buildbot root      405 Dec 15 22:55 package.json
2:57:24 PM: -rw-r--r--   1 buildbot root    63685 Dec 15 22:55 package-lock.json
2:57:24 PM: -rw-r--r--   1 buildbot root      108 Dec 15 22:55 postcss.config.js
2:57:24 PM: drwxr-xr-x   3 buildbot root     4096 Oct 28 08:30 resources
2:57:24 PM: drwxr-xr-x   4 buildbot nogroup  4096 Dec 15 22:56 .shadow-cljs
2:57:24 PM: -rw-r--r--   1 buildbot root      386 Dec 15 22:55 shadow-cljs.edn
2:57:24 PM: drwxr-xr-x   3 buildbot root     4096 Oct 28 08:30 src
2:57:24 PM: -rw-r--r--   1 buildbot root     1778 Dec 15 22:55 tailwind.config.js
2:57:24 PM: drwxr-xr-x   4 buildbot root     4096 Dec 15 22:57 target
2:57:24 PM: + ls -la target
2:57:24 PM: total 20
2:57:24 PM: drwxr-xr-x  4 buildbot root    4096 Dec 15 22:57 .
2:57:24 PM: drwxr-xr-x 12 buildbot root    4096 Dec 15 22:56 ..
2:57:24 PM: drwxr-xr-x  3 buildbot nogroup 4096 Dec 15 22:56 css
2:57:24 PM: -rw-r--r--  1 buildbot root       0 Dec 15 22:55 .gitkeep
2:57:24 PM: -rw-r--r--  1 buildbot nogroup  488 Dec 15 22:55 index.html
2:57:24 PM: drwxr-xr-x  3 buildbot nogroup 4096 Dec 15 22:57 js
2:57:24 PM: ​
2:57:24 PM: (build.command completed in 1m 26.7s)
2:57:24 PM: ​
2:57:24 PM: ────────────────────────────────────────────────────────────────
2:57:24 PM:   Netlify Build Complete                                        
2:57:24 PM: ────────────────────────────────────────────────────────────────
2:57:24 PM: ​
2:57:24 PM: (Netlify Build completed in 1m 26.8s)
2:57:24 PM: Caching artifacts
2:57:24 PM: Started saving node modules
2:57:24 PM: Finished saving node modules
2:57:24 PM: Started saving build plugins
2:57:24 PM: Finished saving build plugins
2:57:24 PM: Started saving rust compile output
2:57:24 PM: Finished saving rust compile output
2:57:24 PM: Started saving pip cache
2:57:24 PM: Finished saving pip cache
2:57:24 PM: Started saving emacs cask dependencies
2:57:24 PM: Finished saving emacs cask dependencies
2:57:24 PM: Started saving maven dependencies
2:57:24 PM: Finished saving maven dependencies
2:57:24 PM: Started saving boot dependencies
2:57:24 PM: Finished saving boot dependencies
2:57:24 PM: Started saving rust rustup cache
2:57:24 PM: Finished saving rust rustup cache
2:57:24 PM: Started saving rust cargo bin cache
2:57:24 PM: Finished saving rust cargo bin cache
2:57:24 PM: Started saving go dependencies
2:57:24 PM: Finished saving go dependencies
2:57:25 PM: Build script success
2:57:25 PM: Deploy directory 'target' does not exist
2:57:25 PM: Failing build: Failed to build site
2:57:25 PM: Failed during stage 'building site': Deploy directory 'target' does not exist
2:57:25 PM: Finished processing build request in 1m51.548011184s

Hiya, sorry you are having trouble with your build.

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile:

We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!

If you are still having problems, please provide as much information as you can on what you have already tried, what your build settings are, your package.json, etc. Thanks!

Thanks for the pointer to the Support Guide. I had tried to follow it before posting my question. Most of that guide is written for people who have errors while their build command is running. My build command completes successfully; the error happens after that, when Netlify is trying to deploy the directory created by the build. The Support Guide mentions that problems can happen if the file contents are too large, but the entire directory (du) is only about 580K, when I build locally.

I have searched the forum for similar questions. As suggested in this post and in several others, I removed the deploy directory from .gitignore, though that did not help. (Suggestion: Netlify should include that advice in the deploy logs, if it’s really important. I don’t think it is though, because I have had many successful deploys in the past when the deploy directory was included in .gitignore. The advice make sense for projects that version-control the entire deploy directory, but not for ones like mine which create that directory during the build.) I also found another support request (posted 1 day ago) for a similar issue, which is still unresolved (though that user may be having different problems.)

As I mentioned, I have tried re-building without a cache, and tried rolling back to a commit that deployed successfully before, but those both fail in the same way.

I included my build settings and build log in the original post. My package.json follows:

{
  "name": "mm",
  "version": "0.0.1",
  "private": true,
  "devDependencies": {
    "@tailwindcss/forms": "0.2.1",
    "autoprefixer": "10.1.0",
    "postcss": "8.2.1",
    "shadow-cljs": "2.11.6",
    "tailwindcss": "2.0.2"
  },
  "dependencies": {
    "@js-joda/core": "1.12.0",
    "highlight.js": "9.18.1",
    "react": "16.14.0",
    "react-dom": "16.14.0",
    "react-highlight.js": "1.0.7"
  }
}

Let me know what other information would be helpful.

Also, apologies… I’ve been using the term “deploy directory”, because that’s what the deploy logs call it. But elsewhere, including in the deploy config, it’s called the “publish directory”. Sorry if that’s confusing.

I’ve tracked down the issue to (what I consider to be) a bug in the build-image scripts: Bug: 'target' can't be a deploy directory anymore · Issue #508 · netlify/build-image · GitHub

This support request can be closed. Please track further progress in that issue.

1 Like