Cli: @netlify/build 2.42.0 breaks deploys

Created on 9 Apr 2020  ยท  17Comments  ยท  Source: netlify/cli

- Do you want to request a _feature_ or report a _bug_?
Bug

- What is the current behavior?
Crashes during deploy

- If the current behavior is a bug, please provide the steps to reproduce.
Netlify started failing my deploys since yesterday (8th of april), and I guess a new version of @netlify/build got released.

Netlify deployment logs

12:16:59 AM: Resolved Netlify Build version tag "latest" to "0.2.5"
12:16:59 AM: Netlify Build not installed. Installing Netlify Build version 0.2.5
12:17:21 AM: /opt/buildhome/.nvm/versions/node/v12.16.1/bin/netlify-build -> /opt/buildhome/.nvm/versions/node/v12.16.1/lib/node_modules/@netlify/build/src/core/bin.js
12:17:21 AM: > [email protected] postinstall /opt/buildhome/.nvm/versions/node/v12.16.1/lib/node_modules/@netlify/build/node_modules/core-js
12:17:21 AM: > node -e "try{require('./postinstall')}catch(e){}"
12:17:22 AM: + @netlify/[email protected]
12:17:22 AM: added 588 packages from 325 contributors in 22.009s
12:17:22 AM: Starting Netlify Build...
12:17:25 AM: โ€‹
12:17:25 AM: โฏ Starting Netlify Build v0.2.5
12:17:25 AM:   https://github.com/netlify/build
12:17:25 AM: โ€‹
12:17:25 AM: โฏ Flags
12:17:25 AM:   nodePath: /opt/buildhome/.nvm/versions/node/v10.19.0/bin/node
12:17:25 AM: โ€‹
12:17:25 AM: โฏ Current directory
12:17:25 AM:   /opt/build/repo
12:17:25 AM: โ€‹
12:17:25 AM: โฏ Config file
12:17:25 AM:   /opt/build/repo/netlify.toml
12:17:25 AM: โ€‹
12:17:25 AM: โฏ Context
12:17:25 AM:   production
12:17:25 AM: โ€‹
12:17:26 AM: โฏ Loading plugins
12:17:26 AM:    - @netlify/plugin-functions-core from build core
12:17:26 AM: โ€‹
12:17:26 AM: โฏ Running Netlify Build Lifecycle
12:17:26 AM:   Found 3 commands. Let's do this!
12:17:26 AM: 
12:17:26 AM: โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
12:17:26 AM: โ”‚ 1. Running onPreBuild command from @netlify/plugin-functions-core โ”‚
12:17:26 AM: โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
12:17:26 AM: โ€‹
12:17:30 AM: Installing functions dependencies
12:17:30 AM: โ€‹
12:17:30 AM: โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
12:17:30 AM: โ”‚ Plugin "@netlify/plugin-functions-core" internal error โ”‚
12:17:30 AM: โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
12:17:30 AM: โ€‹
12:17:30 AM: โฏ Error message
12:17:30 AM:   Error: Error while installing dependencies in /opt/build/repo/functions/stripe-webhook
12:17:30 AM:   yarn install v1.17.0
12:17:30 AM:   warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
12:17:30 AM:   [1/4] Resolving packages...
12:17:30 AM:   [2/4] Fetching packages...
12:17:30 AM:   error https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, stat '/opt/buildhome/.cache/yarn/v4/npm-aws-sign2-0.7.0-b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8/node_modules/aws-sign2/README.md'"
12:17:30 AM:   info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.โ€‹
12:17:30 AM: โ€‹
12:17:30 AM: โฏ Plugin details
12:17:30 AM:   ID:             @netlify/plugin-functions-core
12:17:30 AM:   Version:        0.2.5
12:17:30 AM:   npm link:       https://www.npmjs.com/package/@netlify/buildโ€‹
12:17:30 AM: โ€‹
12:17:30 AM: โฏ Error location
12:17:30 AM:   In "onPreBuild" event in npm package "@netlify/plugin-functions-core"
12:17:30 AM:       at runCommand (/opt/buildhome/.nvm/versions/node/v12.16.1/lib/node_modules/@netlify/build/src/install/main.js:24:20)
12:17:30 AM:       at process._tickCallback (internal/process/next_tick.js:68:7)
12:17:30 AM: โ€‹

Running netlify build locally after upgrading to the latest cli version produces the following error (before upgrading worked perfectly fine):

TypeError: Cannot read property 'replace' of null
    at resolvePath (/home/andrepcg/.config/yarn/global/node_modules/@netlify/config/src/files.js:36:22)
    at searchBaseConfigFile (/home/andrepcg/.config/yarn/global/node_modules/@netlify/config/src/path.js:44:20)
    at getConfigPath (/home/andrepcg/.config/yarn/global/node_modules/@netlify/config/src/path.js:20:7)
    at getFullConfig (/home/andrepcg/.config/yarn/global/node_modules/@netlify/config/src/main.js:141:28)
    at loadConfig (/home/andrepcg/.config/yarn/global/node_modules/@netlify/config/src/main.js:113:13)
    at resolveConfig (/home/andrepcg/.config/yarn/global/node_modules/@netlify/config/src/main.js:60:40)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async BuildCommand.getConfig (/home/andrepcg/.config/yarn/global/node_modules/netlify-cli/src/utils/command.js:76:14)

- Local Environment Information

โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 Environment Info   โ”‚
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

  System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (4) x64 AMD Ryzen 7 3700X 8-Core Processor
  Binaries:
    Node: 12.16.2 - /usr/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 6.14.4 - /usr/bin/npm

netlify-cli/2.42.0 linux-x64 node-v12.16.2
bug

Most helpful comment

Thank you all!

All 17 comments

Thank you for reporting this issue @andrepcg. We'll get back to you with more information soon

@RaeesBhatti Found out that I have specifically to set base in netlify.toml file AND the following function should not return null but an empty string.

https://github.com/netlify/build/blob/master/packages/config/src/files.js#L31

path is not undefined but null instead and thus never entering that path. But even if it could enter it would result in TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

i just update netlify-cli version from 2.4.0 to 2.42.0 that i got same error in my terminal.

TypeError: Cannot read property 'replace' of null
    at resolvePath (C:\Users\owner\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\@netlify\config\src\files.js:36:22)
    at searchBaseConfigFile (C:\Users\owner\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\@netlify\config\src\path.js:44:20)
    at getConfigPath (C:\Users\owner\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\@netlify\config\src\path.js:20:7)
    at getFullConfig (C:\Users\owner\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\@netlify\config\src\main.js:140:28)
    at loadConfig (C:\Users\owner\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\@netlify\config\src\main.js:112:13)
    at resolveConfig (C:\Users\owner\AppData\Roaming\npm\node_modules\netlify-cli\node_modules\@netlify\config\src\main.js:59:40)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Thanks for reporting this issue!
I have created a PR (https://github.com/netlify/build/pull/1120) to solve this problem, I will let you know as soon as this available.

Please publish the fix to npm to unbreak everyone's builds, thanks:)

Hi,

Cannot make deploys until this is fixed

There are two separate problems in this issue.

  1. Deploys crash with Netlify CLI with the Cannot read property 'replace' of null error message. This should be fixed by #813. This PR might take some time to publish to npm. In the meantime, you can do the following to get the fix right away:

    • remove your package-lock.json or yarn.lock and re-install netlify-cli

    • run npm ls @netlify/config (or npm ls -g @netlify/config if netlify-cli is installed globally). You should see the following:

[email protected]
โ”œโ”€โ”ฌ @netlify/[email protected]
โ”‚ โ””โ”€โ”€ @netlify/[email protected]  deduped
โ”œโ”€โ”€ @netlify/[email protected] 
โ””โ”€โ”ฌ [email protected]
  โ””โ”€โ”€ @netlify/[email protected]
  • make sure that @netlify/config is shown as 0.9.1 in the message above (except the one under netlify-redirect-parser)
  • if @netlify/config is indeed 0.9.1 but the error message still appear, please let me know
  1. The following error happens in some builds:
error https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, stat '/opt/buildhome/.cache/yarn/v4/npm-aws-sign2-0.7.0-b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8/node_modules/aws-sign2/README.md'"

It looks like this error message has to do with aws and therefore should only impact builds that use aws. I am currently investigating that issue.

I have separated the second issue (with aws-sign2) to its own GitHub issue at https://github.com/netlify/build/issues/1121.

The first issue (Cannot read property 'replace' of null) is impacting more users. Note: it only impacts Netlify CLI not production builds.

The first issue (Cannot read property 'replace' of null) is impacting more users. Note: it only impacts Netlify CLI not production builds.

Thanks for working on this issue. Just a note on the urgency of this issue: it is affecting the production of everyone building in GitHub Actions and deploying with netlify/actions/cli. The latter uses no version pinning and the Docker images are not uploaded anywhere.

Thanks for the information @haphut!

If I am not mistaken, since that GitHub Action is not using any version pinning as you mentioned, it should respect semver for @netlify/config and install the latest 0.9.1 which should solve the issue.

Note: if anyone is using that GitHub Action and still experiences problems, please post a URL to your deploy logs, thanks!

@ehmicky Thank You, Updating the netlify-config dependency to 0.9.1 fixed the issue.

Fantastic @ehmicky! Thank you.

Yessss!! Wow you guys are amazing!

It's fixed!

image

A new version ([email protected]) has just been published. Please update and let us know if it fixes this problem. We'll close this issue when we have confirmation.

Hi,

I want to thank you very much for your fast response to the issue! Thanks again!

@RaeesBhatti I have confirmed it to be working on [email protected]. Cheers! ๐ŸŽ‰

Thank you all!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasikpark picture jasikpark  ยท  5Comments

lukasluecke picture lukasluecke  ยท  3Comments

karl-cardenas-coding picture karl-cardenas-coding  ยท  4Comments

ercgrat picture ercgrat  ยท  3Comments

bendg25 picture bendg25  ยท  5Comments