My site name is neon-caramel-178e8b.netlify.app and I’m building from a private repo. I’m able to leverage the .env
file on my local and am able to run my gatsby site there.
For the life of me, I cannot figure out why it won’t work with Netlify. I added all of them in the Environment Variables in the Netlify UI before deploying. What am I doing wrong?
9:55:36 AM: Build ready to start
9:55:38 AM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)
9:55:38 AM: build-image tag: v4.8.0
9:55:38 AM: buildbot version: 13616ca0f4280331d49967e190a04e108291d30c
9:55:39 AM: Building without cache
9:55:39 AM: Starting to prepare the repo for build
9:55:39 AM: No cached dependencies found. Cloning fresh repo
9:55:39 AM: git clone https://github.com/ganesh-iyer/portfolio
9:55:40 AM: Preparing Git Reference refs/heads/staging
9:55:40 AM: Parsing package.json dependencies
9:55:41 AM:
❯ Initial build environment
baseRelDir: true
branch: staging
context: production
cwd: /opt/build/repo
featureFlags: []
mode: buildbot
repositoryRoot: /opt/build/repo
siteId: 9b88d948-2913-49cc-b03b-14bc302d5973
❯ UI build settings
baseRelDir: true
build:
command: npm run build
environment:
- CMS_ACCESS_TOKEN_DELIVERY
- CMS_ACCESS_TOKEN_PREVIEW
- CMS_INSTANCE_ID
- GATSBY_GRAPHQL_IDE
- NETLIFY_BUILD_DEBUG
publish: public
plugins:
- inputs: {}
package: '@netlify/plugin-gatsby'
❯ Resolved build environment
branch: staging
buildDir: /opt/build/repo
context: production
env: []
❯ Resolved config
build:
command: npm run build
commandOrigin: ui
environment:
- CMS_ACCESS_TOKEN_DELIVERY
- CMS_ACCESS_TOKEN_PREVIEW
- CMS_INSTANCE_ID
- GATSBY_GRAPHQL_IDE
- NETLIFY_BUILD_DEBUG
publish: /opt/build/repo/public
publishOrigin: ui
plugins:
- inputs: {}
origin: ui
package: '@netlify/plugin-gatsby'
9:55:41 AM: Starting build script
9:55:41 AM: Installing dependencies
9:55:41 AM: Python version set to 2.7
9:55:42 AM: Attempting node version 'v16.5.0' from .nvmrc
9:55:42 AM: Downloading and installing node v16.5.0...
9:55:42 AM: Downloading https://nodejs.org/dist/v16.5.0/node-v16.5.0-linux-x64.tar.xz...
9:55:42 AM: Computing checksum with sha256sum
9:55:43 AM: Checksums matched!
9:55:45 AM: Now using node v16.5.0 (npm v7.19.1)
9:55:45 AM: Started restoring cached build plugins
9:55:45 AM: Finished restoring cached build plugins
9:55:45 AM: Attempting ruby version 2.7.2, read from environment
9:55:46 AM: Using ruby version 2.7.2
9:55:47 AM: Using PHP version 8.0
9:55:47 AM: No npm workspaces detected
9:55:47 AM: Started restoring cached node modules
9:55:47 AM: Finished restoring cached node modules
9:55:47 AM: Installing NPM modules using NPM version 7.19.1
9:56:01 AM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
9:56:01 AM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
9:56:01 AM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
9:56:02 AM: 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.
9:56:02 AM: 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.
9:56:02 AM: 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.
9:56:02 AM: 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.
9:56:02 AM: 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.
9:56:02 AM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
9:56:05 AM: npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
9:56:16 AM: npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
9:56:17 AM: npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
9:56:17 AM: npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
9:56:18 AM: npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
9:56:19 AM: npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
9:56:19 AM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
9:56:20 AM: npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
9:56:25 AM: npm WARN deprecated core-js@2.6.12: core-js@<3.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. Please, upgrade your dependencies to the actual version of core-js.
9:56:36 AM: added 2269 packages, and audited 2270 packages in 48s
9:56:36 AM: 354 packages are looking for funding
9:56:36 AM: run `npm fund` for details
9:56:36 AM: 49 vulnerabilities (13 moderate, 33 high, 3 critical)
9:56:36 AM: To address issues that do not require attention, run:
9:56:36 AM: npm audit fix
9:56:36 AM: To address all issues possible (including breaking changes), run:
9:56:36 AM: npm audit fix --force
9:56:36 AM: Some issues need review, and may require choosing
9:56:36 AM: a different dependency.
9:56:36 AM: Run `npm audit` for details.
9:56:36 AM: NPM modules installed
9:56:37 AM: Started restoring cached go cache
9:56:37 AM: Finished restoring cached go cache
9:56:37 AM: go version go1.16.5 linux/amd64
9:56:37 AM: go version go1.16.5 linux/amd64
9:56:37 AM: Installing missing commands
9:56:37 AM: Verify run directory
9:56:38 AM:
9:56:38 AM: ────────────────────────────────────────────────────────────────
9:56:38 AM: Netlify Build
9:56:38 AM: ────────────────────────────────────────────────────────────────
9:56:38 AM:
9:56:38 AM: ❯ Version
9:56:38 AM: @netlify/build 27.1.1
9:56:38 AM:
9:56:38 AM: ❯ Flags
9:56:38 AM: apiHost: api.netlify.com
9:56:38 AM: baseRelDir: true
9:56:38 AM: branch: staging
9:56:38 AM: buildId: 6285c6c0840a0516af52a406
9:56:38 AM: buildbotServerSocket: /tmp/netlify-buildbot-socket
9:56:38 AM: cacheDir: /opt/build/cache
9:56:38 AM: cachedConfigPath: /tmp/netlify_config.json
9:56:38 AM: context: production
9:56:38 AM: cwd: /opt/build/repo
9:56:38 AM: deployId: 6285c6c0840a0516af52a408
9:56:38 AM: edgeFunctionsDistDir: /tmp/edge-6285c6c0840a0516af52a408
9:56:38 AM: featureFlags:
9:56:38 AM: - buildbot_build_go_functions
9:56:38 AM: - edge_functions_cache_cli
9:56:38 AM: - zisi_parse_isc
9:56:38 AM: framework: gatsby
9:56:38 AM: functionsDistDir: /tmp/zisi-6285c6c0840a0516af52a408
9:56:38 AM: mode: buildbot
9:56:38 AM: nodePath: /opt/buildhome/.nvm/versions/node/v16.5.0/bin/node
9:56:38 AM: repositoryRoot: /opt/build/repo
9:56:38 AM: saveConfig: true
9:56:38 AM: sendStatus: true
9:56:38 AM: siteId: 9b88d948-2913-49cc-b03b-14bc302d5973
9:56:38 AM: statsd:
9:56:38 AM: host: 10.65.78.162
9:56:38 AM: port: 8125
9:56:38 AM: testOpts:
9:56:38 AM: silentLingeringProcesses: ''
9:56:38 AM:
9:56:38 AM: ❯ Current directory
9:56:38 AM: /opt/build/repo
9:56:38 AM:
9:56:38 AM: ❯ Config file
9:56:38 AM: No config file was defined: using default values.
9:56:38 AM:
9:56:38 AM: ❯ Resolved config
9:56:38 AM: build:
9:56:38 AM: command: npm run build
9:56:38 AM: commandOrigin: ui
9:56:38 AM: environment:
9:56:38 AM: - CMS_ACCESS_TOKEN_DELIVERY
9:56:38 AM: - CMS_ACCESS_TOKEN_PREVIEW
9:56:38 AM: - CMS_INSTANCE_ID
9:56:38 AM: - GATSBY_GRAPHQL_IDE
9:56:38 AM: - NETLIFY_BUILD_DEBUG
9:56:38 AM: publish: /opt/build/repo/public
9:56:38 AM: publishOrigin: ui
9:56:38 AM: plugins:
9:56:38 AM: - inputs: {}
9:56:38 AM: origin: ui
9:56:38 AM: package: '@netlify/plugin-gatsby'
9:56:38 AM:
9:56:38 AM: ❯ Context
9:56:38 AM: production
9:56:38 AM:
9:56:38 AM: ❯ Available plugins
9:56:38 AM: - @algolia/netlify-plugin-crawler@1.0.0
9:56:38 AM: - @bharathvaj/netlify-plugin-airbrake@1.0.2
9:56:38 AM: - @commandbar/netlify-plugin-commandbar@0.0.4
9:56:38 AM: - @helloample/netlify-plugin-replace@1.1.4
9:56:38 AM: - @netlify/plugin-angular-universal@1.0.1
9:56:38 AM: - @netlify/plugin-gatsby@3.0.0
9:56:38 AM: - @netlify/plugin-lighthouse@2.1.3
9:56:38 AM: - @netlify/plugin-nextjs@4.7.0
9:56:38 AM: - @netlify/plugin-sitemap@0.8.1
9:56:38 AM: - @newrelic/netlify-plugin@1.0.1
9:56:38 AM: - @sentry/netlify-build-plugin@1.1.1
9:56:38 AM: - @takeshape/netlify-plugin-takeshape@1.0.0
9:56:38 AM: - @vgs/netlify-plugin-vgs@0.0.2
9:56:38 AM: - netlify-build-plugin-dareboost@1.2.1
9:56:38 AM: - netlify-build-plugin-debugbear@1.0.6
9:56:38 AM: - netlify-build-plugin-perfbeacon@1.0.3
9:56:38 AM: - netlify-build-plugin-speedcurve@2.0.0
9:56:38 AM: - netlify-deployment-hours-plugin@0.0.10
9:56:38 AM: - netlify-plugin-a11y@0.0.12
9:56:38 AM: - netlify-plugin-add-instagram@0.2.2
9:56:38 AM: - netlify-plugin-algolia-index@0.3.0
9:56:38 AM: - netlify-plugin-amp-server-side-rendering@1.0.2
9:56:38 AM: - netlify-plugin-brand-guardian@1.0.1
9:56:38 AM: - netlify-plugin-build-logger@1.0.3
9:56:38 AM: - netlify-plugin-cache-nextjs@1.4.0
9:56:38 AM: - netlify-plugin-cecil-cache@0.2.5
9:56:38 AM: - netlify-plugin-checklinks@4.1.1
9:56:38 AM: - netlify-plugin-chromium@1.1.4
9:56:38 AM: - netlify-plugin-cloudinary@1.0.3
9:56:38 AM: - netlify-plugin-contextual-env@0.3.0
9:56:38 AM: - netlify-plugin-cypress@2.2.0
9:56:38 AM: - netlify-plugin-debug-cache@1.0.4
9:56:38 AM: - netlify-plugin-encrypted-files@0.0.5
9:56:38 AM: - netlify-plugin-fetch-feeds@0.2.3
9:56:38 AM: - netlify-plugin-gatsby-cache@0.3.0
9:56:38 AM: - netlify-plugin-get-env-vars@1.0.0
9:56:38 AM: - netlify-plugin-ghost-inspector@1.0.1
9:56:38 AM: - netlify-plugin-ghost-markdown@3.0.3
9:56:38 AM: - netlify-plugin-gmail@1.1.0
9:56:38 AM: - netlify-plugin-gridsome-cache@1.0.3
9:56:38 AM: - netlify-plugin-hashfiles@4.0.2
9:56:38 AM: - netlify-plugin-html-validate@1.0.0
9:56:38 AM: - netlify-plugin-hugo-cache-resources@0.2.1
9:56:38 AM: - netlify-plugin-image-optim@0.4.0
9:56:38 AM: - netlify-plugin-inline-critical-css@2.0.0
9:56:38 AM: - netlify-plugin-inline-functions-env@1.0.8
9:56:38 AM: - netlify-plugin-inline-source@1.0.4
9:56:38 AM: - netlify-plugin-is-website-vulnerable@2.0.3
9:56:38 AM: - netlify-plugin-jekyll-cache@1.0.0
9:56:38 AM: - netlify-plugin-js-obfuscator@1.0.20
9:56:38 AM: - netlify-plugin-minify-html@0.3.1
9:56:38 AM: - netlify-plugin-next-dynamic@1.0.9
9:56:38 AM: - netlify-plugin-nimbella@2.1.0
9:56:38 AM: - netlify-plugin-no-more-404@0.0.15
9:56:38 AM: - netlify-plugin-nx-skip-build@0.0.5
9:56:38 AM: - netlify-plugin-pagewatch@1.0.4
9:56:38 AM: - netlify-plugin-prerender-spa@1.0.1
9:56:38 AM: - netlify-plugin-prisma-provider@0.3.0
9:56:38 AM: - netlify-plugin-pushover@0.1.1
9:56:38 AM: - netlify-plugin-qawolf@1.2.0
9:56:38 AM: - netlify-plugin-rss@0.0.8
9:56:38 AM: - netlify-plugin-search-index@0.1.5
9:56:38 AM: - netlify-plugin-snyk@1.2.0
9:56:38 AM: - netlify-plugin-stepzen@1.0.4
9:56:38 AM: - netlify-plugin-subfont@6.0.0
9:56:38 AM: - netlify-plugin-submit-sitemap@0.3.0
9:56:38 AM: - netlify-plugin-to-all-events@1.3.1
9:56:38 AM: - netlify-plugin-use-env-in-runtime@1.2.1
9:56:38 AM: - netlify-plugin-visual-diff@2.0.0
9:56:38 AM: - netlify-plugin-webmentions@1.1.0
9:56:38 AM: - netlify-purge-cloudflare-on-deploy@1.2.0
9:56:38 AM:
9:56:38 AM: ❯ Installing plugins
9:56:38 AM: - @netlify/plugin-gatsby@3.0.0
9:56:50 AM:
9:56:50 AM: ❯ Loading plugins
9:56:50 AM: - @netlify/plugin-gatsby@3.0.0 from Netlify app (latest 3.0.0, expected 3.0.0, compatible 3.0.0)
9:56:51 AM:
9:56:51 AM: ────────────────────────────────────────────────────────────────
9:56:51 AM: 1. @netlify/plugin-gatsby (onPreBuild event)
9:56:51 AM: ────────────────────────────────────────────────────────────────
9:56:51 AM:
9:56:51 AM: Step starting.
9:56:51 AM: Step started.
9:56:51 AM: Plugin logic started.
9:56:51 AM: No Gatsby cache found. Building fresh.
9:56:51 AM: Please install `gatsby-plugin-netlify` and enable it in your gatsby-config.js. https://www.gatsbyjs.com/plugins/gatsby-plugin-netlify/
9:56:51 AM: Plugin logic ended.
9:56:51 AM: Stop closing.
9:56:51 AM: Step ended.
9:56:51 AM: Step completed.
9:56:51 AM:
9:56:51 AM: (@netlify/plugin-gatsby onPreBuild completed in 12ms)
9:56:51 AM:
9:56:51 AM: ────────────────────────────────────────────────────────────────
9:56:51 AM: 2. Build command from Netlify app
9:56:51 AM: ────────────────────────────────────────────────────────────────
9:56:51 AM:
9:56:51 AM: $ npm run build
9:56:51 AM: > portfolio@1.0.0 build
9:56:51 AM: > env-cmd -f .env gatsby build
9:56:51 AM: Error: Failed to find .env file at path: .env
9:56:51 AM: at getEnvFile (/opt/build/repo/node_modules/env-cmd/dist/get-env-vars.js:40:19)
9:56:52 AM:
9:56:52 AM: ────────────────────────────────────────────────────────────────
9:56:52 AM: "build.command" failed
9:56:52 AM: ────────────────────────────────────────────────────────────────
9:56:52 AM:
9:56:52 AM: Error message
9:56:52 AM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
9:56:52 AM:
9:56:52 AM: Error location
9:56:52 AM: In Build command from Netlify app:
9:56:52 AM: npm run build
9:56:52 AM:
9:56:52 AM: Resolved config
9:56:52 AM: build:
9:56:52 AM: command: npm run build
9:56:52 AM: commandOrigin: ui
9:56:52 AM: environment:
9:56:52 AM: - CMS_ACCESS_TOKEN_DELIVERY
9:56:52 AM: - CMS_ACCESS_TOKEN_PREVIEW
9:56:52 AM: - CMS_INSTANCE_ID
9:56:52 AM: - GATSBY_GRAPHQL_IDE
9:56:52 AM: - NETLIFY_BUILD_DEBUG
9:56:52 AM: publish: /opt/build/repo/public
9:56:52 AM: publishOrigin: ui
9:56:52 AM: plugins:
9:56:52 AM: - inputs: {}
9:56:52 AM: origin: ui
9:56:52 AM: package: '@netlify/plugin-gatsby'
9:56:52 AM: Caching artifacts
9:56:52 AM: Started saving node modules
9:56:52 AM: Finished saving node modules
9:56:52 AM: Started saving build plugins
9:56:52 AM: Finished saving build plugins
9:56:52 AM: Started saving pip cache
9:56:52 AM: Finished saving pip cache
9:56:53 AM: Creating deploy upload records
9:56:52 AM: Started saving emacs cask dependencies
9:56:52 AM: Finished saving emacs cask dependencies
9:56:52 AM: Started saving maven dependencies
9:56:52 AM: Finished saving maven dependencies
9:56:52 AM: Started saving boot dependencies
9:56:54 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:56:52 AM: Finished saving boot dependencies
9:56:52 AM: Started saving rust rustup cache
9:56:52 AM: Finished saving rust rustup cache
9:56:52 AM: Started saving go dependencies
9:56:52 AM: Finished saving go dependencies
9:56:53 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:56:54 AM: Failing build: Failed to build site
9:56:54 AM: Finished processing build request in 1m15.383697017s