Domain name being injected into build script paths?

Site name: dylankenneally-stg-treewalkers.netlify.app
Custom domain: https://www.treewalkers.com.au

netlify.toml:

[build]
  base = "html5-boilerplate/"
  publish = "dist/"
  command = "npm run build"

After applying the custom domain to this site, I’ve found that build commands have the custom domain injected into the build paths, as in opt/build/repo/html5-boilerplate/“https:/www.treewalkers.com.au/” (note the “quote” marks are also include). This leads to build failures as that directory doesn’t exist.

Updating the build commands to include pwd shows the current directory is what I expect (opt/build/repo/html5-boilerplate/).

What is appending the "site-url" to this? And how can I prevent that?

Full log below, also available at Netlify App

3:55:34 PM: build-image version: f14e228ec2dbb3d6f5ee2f499343e1468b859b97 (focal)
3:55:34 PM: buildbot version: f14e228ec2dbb3d6f5ee2f499343e1468b859b97
3:55:35 PM: Fetching cached dependencies
3:55:35 PM: Failed to fetch cache, continuing with build
3:55:35 PM: Starting to prepare the repo for build
3:55:35 PM: No cached dependencies found. Cloning fresh repo
3:55:35 PM: git clone --filter=blob:none https://github.com/dylankenneally/tree-walkers
3:55:35 PM: Preparing Git Reference pull/7/head
3:55:37 PM: Parsing package.json dependencies
3:55:37 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'html5-boilerplate' versus '' in the Netlify UI
3:55:37 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'html5-boilerplate/dist' versus '' in the Netlify UI
3:55:37 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus '' in the Netlify UI
3:55:38 PM: Starting build script
3:55:38 PM: Installing dependencies
3:55:38 PM: Python version set to 2.7
3:55:38 PM: v16.19.1 is already installed.
3:55:38 PM: Now using node v16.19.1 (npm v8.19.3)
3:55:38 PM: Enabling Node.js Corepack
3:55:38 PM: Started restoring cached build plugins
3:55:38 PM: Finished restoring cached build plugins
3:55:38 PM: Attempting Ruby version 2.7.2, read from environment
3:55:39 PM: Using Ruby version 2.7.2
3:55:39 PM: Using PHP version 8.0
3:55:39 PM: Started restoring cached corepack dependencies
3:55:39 PM: Finished restoring cached corepack dependencies
3:55:39 PM: No npm workspaces detected
3:55:39 PM: Started restoring cached node modules
3:55:39 PM: Finished restoring cached node modules
3:55:40 PM: Installing npm packages using npm version 8.19.3
3:55:42 PM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
3:55:42 PM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
3:55:42 PM: npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
3:55:42 PM: npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
3:55:42 PM: npm WARN deprecated request-promise-native@1.0.8: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
3:55:42 PM: npm WARN deprecated source-map-url@0.4.0: See https://github.com/lydell/source-map-url#deprecated
3:55:42 PM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
3:55:43 PM: npm WARN deprecated har-validator@5.1.3: this library is no longer supported
3:55:43 PM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
3:55:43 PM: npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
3:55:43 PM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
3:55:44 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
3:55:44 PM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
3:55:44 PM: npm WARN deprecated parcel-bundler@1.12.5: Parcel v1 is no longer maintained. Please migrate to v2, which is published under the 'parcel' package. See https://v2.parceljs.org/getting-started/migration for details.
3:55:45 PM: npm WARN deprecated core-js@2.6.11: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
3:55:47 PM: added 753 packages, and audited 754 packages in 8s
3:55:47 PM: 26 packages are looking for funding
3:55:47 PM:   run `npm fund` for details
3:55:47 PM: 39 vulnerabilities (1 low, 13 moderate, 22 high, 3 critical)
3:55:47 PM: To address issues that do not require attention, run:
3:55:47 PM:   npm audit fix
3:55:47 PM: To address all issues (including breaking changes), run:
3:55:47 PM:   npm audit fix --force
3:55:47 PM: Run `npm audit` for details.
3:55:47 PM: npm packages installed
3:55:48 PM: Started restoring cached go cache
3:55:48 PM: Finished restoring cached go cache
3:55:48 PM: go version go1.19.7 linux/amd64
3:55:48 PM: Detected 1 framework(s)
3:55:48 PM: "parcel" at version "1.12.5"
3:55:48 PM: Section completed: initializing
3:55:50 PM: ​
3:55:50 PM:   Netlify Build                                                 
3:55:50 PM: ────────────────────────────────────────────────────────────────
3:55:50 PM: ​
3:55:50 PM: ❯ Version
3:55:50 PM:   @netlify/build 29.6.4
3:55:50 PM: ​
3:55:50 PM: ❯ Flags
3:55:50 PM:   baseRelDir: true
3:55:50 PM:   buildId: 640966c51001d900086c2c71
3:55:50 PM:   deployId: 640966c51001d900086c2c73
3:55:50 PM: ​
3:55:50 PM: ❯ Current directory
3:55:50 PM:   /opt/build/repo/html5-boilerplate
3:55:50 PM: ​
3:55:50 PM: ❯ Config file
3:55:50 PM:   /opt/build/repo/netlify.toml
3:55:50 PM: ​
3:55:50 PM: ❯ Context
3:55:50 PM:   deploy-preview
3:55:50 PM: ​
3:55:50 PM:   1. build.command from netlify.toml                            
3:55:50 PM: ────────────────────────────────────────────────────────────────
3:55:50 PM: ​
3:55:50 PM: $ npm run build
3:55:50 PM: > tree-walkers@0.0.1 build
3:55:50 PM: > pwd && npm run clean && parcel build index.html services/index.html about/index.html && cp favicon.ico dist/favicon.ico && cp robots.txt dist/robots.txt && cp sitemap.xml dist/sitemap.xml && cp img/social-meta.jpeg dist/social-meta.jpeg
3:55:50 PM: /opt/build/repo/html5-boilerplate
3:55:50 PM: > tree-walkers@0.0.1 clean
3:55:50 PM: > rimraf dist && rimraf .cache
3:55:52 PM: 🚨  /opt/build/repo/html5-boilerplate/“https:/www.treewalkers.com.au/”: ENOENT: no such file or directory, open '/opt/build/repo/html5-boilerplate/“https:/www.treewalkers.com.au/”'
3:55:52 PM: Error: ENOENT: no such file or directory, open '/opt/build/repo/html5-boilerplate/“https:/www.treewalkers.com.au/”'
3:55:52 PM: ​
3:55:52 PM:   "build.command" failed                                        
3:55:52 PM: ────────────────────────────────────────────────────────────────
3:55:52 PM: ​
3:55:52 PM:   Error message
3:55:52 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
3:55:52 PM: ​
3:55:52 PM:   Error location
3:55:52 PM:   In build.command from netlify.toml:
3:55:52 PM:   npm run build
3:55:52 PM: ​
3:55:52 PM:   Resolved config
3:55:52 PM:   build:
3:55:52 PM:     base: /opt/build/repo/html5-boilerplate
3:55:52 PM:     command: npm run build
3:55:52 PM:     commandOrigin: config
3:55:52 PM:     environment:
3:55:52 PM:       - REVIEW_ID
3:55:52 PM:     publish: /opt/build/repo/html5-boilerplate/dist
3:55:52 PM:     publishOrigin: config
3:55:53 PM: Caching artifacts
3:55:53 PM: Started saving node modules
3:55:53 PM: Finished saving node modules
3:55:53 PM: Started saving build plugins
3:55:53 PM: Finished saving build plugins
3:55:53 PM: Started saving corepack cache
3:55:53 PM: Finished saving corepack cache
3:55:53 PM: Started saving pip cache
3:55:53 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
3:55:53 PM: Finished saving pip cache
3:55:53 PM: Started saving emacs cask dependencies
3:55:53 PM: Finished saving emacs cask dependencies
3:55:53 PM: Started saving maven dependencies
3:55:53 PM: Finished saving maven dependencies
3:55:53 PM: Started saving boot dependencies
3:55:53 PM: Finished saving boot dependencies
3:55:53 PM: Started saving rust rustup cache
3:55:53 PM: Finished saving rust rustup cache
3:55:53 PM: Started saving go dependencies
3:55:53 PM: Finished saving go dependencies
3:55:53 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:55:53 PM: Failing build: Failed to build site
3:55:53 PM: Finished processing build request in 18.876s

Hi, @dylankenneally. The answer to that question is best answered by examining the source code for the build command. However, that repo is private so I cannot do that. If you want to make your repo public, then I will be able to tell you the answer with more certainty.

Without the repo access, I can still make a best guess. It looks like you are using the Parcel framework and I tried to find documentation about how Parcel can be controlled using environment variables. While I found some information, I did not fine anything about environment variables modifying file paths.

Our build system does set an environment variable named URL which will include the custom domain used for the site it the build is for a production deploy. There is more about that in our public docs here.

What I cannot find is Parcel documentation about why it might be using that environment variable. Despite not being able to find that documentation, that does appear to be what is happening here.

I do see Parcel has a --public-url option. Does your code perhaps use that option and an environment variable named URL?

Thanks for getting back to me @luke.

I’ve made the repo public.

I don’t believe the issue related to parcel or environment variables at the repo level, as the issue happens before parcel is called or any env. vars are used. The build command (via npm run build) is as follows:

npm run clean && parcel build index.html services/index.html about/index.html && cp favicon.ico dist/favicon.ico && cp robots.txt dist/robots.txt && cp sitemap.xml dist/sitemap.xml && cp img/social-meta.jpeg dist/social-meta.jpeg

And the clean call is defined as rimraf dist && rimraf .cache - this deletes the dist and .cache directories via rimraf. It’s this call that fails, i.e. pre parcel being involved.

I also don’t believe it it is due to an issue with rimraf (a wrapper on rm -rf) as a previous comment removed that call - same issue happens.

The branch dylankenneally-patch-1 has the pwd call I mentioned that confirms the directory is what I expect (i.e. without the “site-url”) as part of the build command.

Note that the package file is in the html5-boilerplate subdirectory.

Any guidance would be appreciated.

Hi @dylankenneally,

The repo still appears to be private.

My bad! It’s definitely public now. Sorry about that.

hi @dylankenneally

I was able to fork and replicate this behaviour. Super weird!

I searched for places where you have https://www.treewalkers.com.au hardcoded and there are a few metatags. Maybe parcel is picking that up on the /about or /services routes?

I removed all references to https://www.treewalkers.com.au and it builds! so this is something related to the fact that you have that domain hardcoded in your code. Maybe parcel does not play well with it?

Here’s my fork for reference: GitHub - gualterandre/tree-walkers: Arborist company in Melbourne - client project

Hope this helps!

Thank you for the effort you’ve put in to looking at this - it’s much appreciated.

I have been able to replicate this locally as a result, and can confirm this isn’t based on anything netlify related.

Awesome! Glad I could help. What was it at the end, are you able to share? Curious me is asking :smile:

Parcel JS is doing something based on a canonical tag being present. I’ve not been able to establish what it’s doing, or why. Their logging system doesn’t help (it barfs before login happens).

I’ve removed the canonical tags for now to keep moving forward.

Others have found the same issue, also without resolution…

1 Like