Is 'overwrite' an error?

I’m a fairly new user, trying to make a site with Pelican. I have managed to get my site to deploy for a first test, but subsequent attempts have failed. Specifically, when an add a second test post, I get a build error that seems to be related to overwrite. For this most recent attempt, I modified the destination in the Makefile and netlify.toml to use “output2” instead of “output”, and I still get a build failure and a complaint about overwrite.

I initially had the output directory and its content in git and GitHub, but it has been removed.

Current repository
github.com/BTMeeks/BartonMeeks.com

My working deploy is at https://64ab555c93bb6a000787fa51--warm-dolphin-895a48.netlify.app/
and also at BartonMeeks.com

Build setting screenshot is attached, but I also have a netlify.toml that overrides some of that. My netlify.toml file is

[build]
  command = "make publish"
  publish = "output2"

Build log follows:

9:39:16 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
9:39:00 PM: build-image version: bf8734810854fd35d8b037fbb8a8d437d818b7b5 (focal)
9:39:00 PM: buildbot version: bf8734810854fd35d8b037fbb8a8d437d818b7b5
9:39:00 PM: Fetching cached dependencies
9:39:00 PM: Starting to download cache of 60.7MB
9:39:01 PM: Finished downloading cache in 1.463s
9:39:01 PM: Starting to extract cache
9:39:02 PM: Finished extracting cache in 554ms
9:39:02 PM: Finished fetching cache in 2.059s
9:39:02 PM: Starting to prepare the repo for build
9:39:02 PM: Preparing Git Reference refs/heads/main
9:39:03 PM: Custom publish path detected. Proceeding with the specified path: ‘output2’
9:39:03 PM: Custom build command detected. Proceeding with the specified command: ‘make publish’
9:39:04 PM: Starting to install dependencies
9:39:04 PM: Python version set to 3.8
9:39:04 PM: Installing pip dependencies
9:39:04 PM: Started restoring cached pip cache
9:39:04 PM: Finished restoring cached pip cache
9:39:05 PM: Collecting blinker==1.6.2
9:39:05 PM: Using cached blinker-1.6.2-py3-none-any.whl (13 kB)
9:39:05 PM: Collecting docutils==0.20.1
9:39:05 PM: Using cached docutils-0.20.1-py3-none-any.whl (572 kB)
9:39:05 PM: Collecting feedgenerator==2.1.0
9:39:05 PM: Using cached feedgenerator-2.1.0-py3-none-any.whl (21 kB)
9:39:05 PM: Collecting Jinja2==3.1.2
9:39:05 PM: Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
9:39:05 PM: Collecting Markdown==3.4.3
9:39:05 PM: Using cached Markdown-3.4.3-py3-none-any.whl (93 kB)
9:39:05 PM: Collecting markdown-it-py==3.0.0
9:39:05 PM: Using cached markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
9:39:05 PM: Collecting MarkupSafe==2.1.3
9:39:05 PM: Using cached MarkupSafe-2.1.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
9:39:05 PM: Collecting mdurl==0.1.2
9:39:05 PM: Using cached mdurl-0.1.2-py3-none-any.whl (10.0 kB)
9:39:05 PM: Collecting pelican==4.8.0
9:39:05 PM: Using cached pelican-4.8.0-py3-none-any.whl (1.4 MB)
9:39:06 PM: Collecting Pygments==2.15.1
9:39:06 PM: Using cached Pygments-2.15.1-py3-none-any.whl (1.1 MB)
9:39:06 PM: Collecting python-dateutil==2.8.2
9:39:06 PM: Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
9:39:06 PM: Collecting pytz==2023.3
9:39:06 PM: Using cached pytz-2023.3-py2.py3-none-any.whl (502 kB)
9:39:06 PM: Collecting rich==13.4.2
9:39:06 PM: Using cached rich-13.4.2-py3-none-any.whl (239 kB)
9:39:06 PM: Collecting six==1.16.0
9:39:06 PM: Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
9:39:06 PM: Collecting Unidecode==1.3.6
9:39:06 PM: Using cached Unidecode-1.3.6-py3-none-any.whl (235 kB)
9:39:06 PM: Collecting importlib-metadata>=4.4; python_version < 3.10
9:39:06 PM: Using cached importlib_metadata-6.8.0-py3-none-any.whl (22 kB)
9:39:06 PM: Collecting typing-extensions<5.0,>=4.0.0; python_version < 3.9
9:39:06 PM: Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
9:39:06 PM: Collecting zipp>=0.5
9:39:06 PM: Using cached zipp-3.16.0-py3-none-any.whl (6.7 kB)
9:39:07 PM: Installing collected packages: blinker, docutils, pytz, feedgenerator, MarkupSafe, Jinja2, zipp, importlib-metadata, Markdown, mdurl, markdown-it-py, Pygments, six, python-dateutil, Unidecode, typing-extensions, rich, pelican
9:39:08 PM: Successfully installed Jinja2-3.1.2 Markdown-3.4.3 MarkupSafe-2.1.3 Pygments-2.15.1 Unidecode-1.3.6 blinker-1.6.2 docutils-0.20.1 feedgenerator-2.1.0 importlib-metadata-6.8.0 markdown-it-py-3.0.0 mdurl-0.1.2 pelican-4.8.0 python-dateutil-2.8.2 pytz-2023.3 rich-13.4.2 six-1.16.0 typing-extensions-4.7.1 zipp-3.16.0
9:39:08 PM: Pip dependencies installed
9:39:08 PM: Attempting Ruby version 2.7.2, read from environment
9:39:09 PM: Using Ruby version 2.7.2
9:39:09 PM: Started restoring cached go cache
9:39:09 PM: Finished restoring cached go cache
9:39:10 PM: go version go1.19.10 linux/amd64
9:39:10 PM: Using PHP version 8.0
9:39:10 PM: Started restoring cached Node.js version
9:39:11 PM: Finished restoring cached Node.js version
9:39:11 PM: v18.16.1 is already installed.
9:39:12 PM: Now using node v18.16.1 (npm v9.5.1)
9:39:12 PM: Enabling Node.js Corepack
9:39:12 PM: Started restoring cached build plugins
9:39:12 PM: Finished restoring cached build plugins
9:39:12 PM: Install dependencies script success
9:39:12 PM: Starting build script
9:39:13 PM: Detected 0 framework(s)
9:39:13 PM: Section completed: initializing
9:39:14 PM: ​
9:39:14 PM: Netlify Build
9:39:14 PM: ────────────────────────────────────────────────────────────────
9:39:14 PM: ​
9:39:14 PM: ❯ Version
9:39:14 PM: @netlify/build 29.15.6
9:39:14 PM: ​
9:39:14 PM: ❯ Flags
9:39:14 PM: baseRelDir: true
9:39:14 PM: buildId: 64ae042cb5e9440008ca2ff9
9:39:14 PM: deployId: 64ae042cb5e9440008ca2ffb
9:39:14 PM: ​
9:39:14 PM: ❯ Current directory
9:39:14 PM: /opt/build/repo
9:39:14 PM: ​
9:39:14 PM: ❯ Config file
9:39:14 PM: /opt/build/repo/netlify.toml
9:39:14 PM: ​
9:39:14 PM: ❯ Context
9:39:14 PM: production
9:39:14 PM: ​
9:39:14 PM: build.command from netlify.toml
9:39:14 PM: ────────────────────────────────────────────────────────────────
9:39:14 PM: ​
9:39:14 PM: $ make publish
9:39:14 PM: pelican /opt/build/repo/content -o /opt/build/repo/output2 -s /opt/build/repo/publishconf.py
9:39:15 PM: /opt/build/repo/content/images
9:39:15 PM: lang en:
9:39:15 PM: /opt/build/repo/content/tests/second.md
9:39:15 PM: /opt/build/repo/content/tests/first.md
9:39:15 PM: ⠋ Generating…
9:39:15 PM: slug my-first-post:
9:39:15 PM: /opt/build/repo/content/tests/second.md
9:39:15 PM: /opt/build/repo/content/tests/first.md
9:39:15 PM: ⠋ Generating…
9:39:15 PM: ⠋ Generating…
9:39:15 PM:
9:39:15 PM: /opt/build/repo/output2/my-first-post.html
9:39:15 PM: is to be overwritten
9:39:15 PM: make: *** [Makefile:72: publish] Error 1
9:39:15 PM: ​
9:39:15 PM: build.command failed
9:39:15 PM: ────────────────────────────────────────────────────────────────
9:39:15 PM: ​
9:39:15 PM: Error message
9:39:15 PM: Command failed with exit code 2: make publish (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
9:39:15 PM: ​
9:39:15 PM: Error location
9:39:15 PM: In build.command from netlify.toml:
9:39:15 PM: make publish
9:39:15 PM: ​
9:39:15 PM: Resolved config
9:39:15 PM: build:
9:39:15 PM: command: make publish
9:39:15 PM: commandOrigin: config
9:39:15 PM: publish: /opt/build/repo/output2
9:39:15 PM: publishOrigin: config
9:39:15 PM: Caching artifacts
9:39:15 PM: Started saving build plugins
9:39:15 PM: Finished saving build plugins
9:39:15 PM: Started saving pip cache
9:39:15 PM: Finished saving pip cache
9:39:15 PM: Started saving emacs cask dependencies
9:39:15 PM: Finished saving emacs cask dependencies
9:39:15 PM: Started saving maven dependencies
9:39:15 PM: Finished saving maven dependencies
9:39:15 PM: Started saving boot dependencies
9:39:15 PM: Finished saving boot dependencies
9:39:15 PM: Started saving rust rustup cache
9:39:15 PM: Finished saving rust rustup cache
9:39:15 PM: Started saving go dependencies
9:39:15 PM: Finished saving go dependencies
9:39:15 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:39:15 PM: Failing build: Failed to build site
9:39:16 PM: Finished processing build request in 16.131s

I’m surprised that changing the output directory from ‘output’ to ‘output2’ didn’t get the build to work once more. I would expect it to fail again after the first build after the change, but the first build after the change failed also.

Hmm, so what happens when I build locally?

make publish
"pelican" "/Users/barton/Developer/Web/Pelican/BartonMeeks.com/content" -o "/Users/barton/Developer/Web/Pelican/BartonMeeks.com/output2" -s "/Users/barton/Developer/Web/Pelican/BartonMeeks.com/publishconf.py"
[19:17:22] WARNING  Watched path does not exist: /Users/barton/Developer/Web/Pelican/BartonMeeks.com/content/images         log.py:91
           WARNING  There are 2 items "with slug "my-first-post"" with lang en:                                             log.py:91
                    /Users/barton/Developer/Web/Pelican/BartonMeeks.com/content/tests/second.md
                    /Users/barton/Developer/Web/Pelican/BartonMeeks.com/content/tests/first.md
           WARNING  There are 2 original (not translated) items with slug "my-first-post":                                  log.py:91
                    /Users/barton/Developer/Web/Pelican/BartonMeeks.com/content/tests/second.md
                    /Users/barton/Developer/Web/Pelican/BartonMeeks.com/content/tests/first.md
           CRITICAL RuntimeError: File /Users/barton/Developer/Web/Pelican/BartonMeeks.com/output2/my-first-post.html __init__.py:566
                    is to be overwritten
make: *** [publish] Error 1

So fix the slug that says “my-first-post” in the second test post.

Yea! That fixed it; by copying the first test post to the second test post, I had the same Title: in both, and therefore the same slug for both. That was the cause of the overwrite.

One of the lessons learned: try the build locally, you may get extra warnings or error descriptions that you don’t get (or I don’t know how to get) from Netlify.

This is basically the golden rule of working with “static sites”.

In most cases trying to run the same thing locally as on Netlify will reveal the problem, and it’s far easier to debug with repeated local executions than it is to keep pushing changes and waiting for Netlify’s build.

Excellent job self solving!