renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
17.55k stars 2.3k forks source link

Failed to pick up right Node.js version in sub folder #18885

Closed hongbo-miao closed 1 year ago

hongbo-miao commented 1 year ago

How are you running Renovate?

Mend Renovate hosted app on github.com

Was this something which used to work for you, and then stopped?

I never saw this working

Describe the bug

This is the pull request having issue: https://github.com/Hongbo-Miao/hongbomiao.com/pull/5997

I have a mono repo. The sub folder /grafana/hm-panel-plugin expects using Node.js 16.

However, when Renovate tries to update package at /grafana/hm-panel-plugin/package.json, I got error from Reonvate:

npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: hm-panel-plugin@1.0.0
npm ERR! notsup Not compatible with your version of node/npm: hm-panel-plugin@1.0.0
npm ERR! notsup Required: {"node":"16.x","npm":"8.x"}
npm ERR! notsup Actual:   {"npm":"8.19.3","node":"v18.12.1"}

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/renovate-cache/others/npm/_logs/2022-11-12T18_31_35_449Z-debug-0.log

I think Renovate probably used the Node.js version 18 in the root /.nvmrc instead of Node.js version 16 at /grafana/hm-panel-plugin/.nvmrc

Let me know if need any other info, thanks! 😃

Relevant debug logs

Logs Part of log at https://app.renovatebot.com/dashboard#github/Hongbo-Miao/hongbomiao.com/886333983 ```sh lock file error(branch="renovate/tanstack-query-monorepo") { "err": { "name": "ExecError", "cmd": "/bin/sh -c docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\":\"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\" -v \"/tmp/renovate-cache\":\"/tmp/renovate-cache\" -v \"/tmp/containerbase\":\"/tmp/containerbase\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/grafana/hm-panel-plugin\" docker.io/renovate/sidecar bash -l -c \"install-tool node 18.12.1 && install-tool npm 8.19.3 && hash -d npm 2>/dev/null || true && npm install --package-lock-only --no-audit --ignore-scripts\"", "stderr": "npm ERR! code EBADENGINE\nnpm ERR! engine Unsupported engine\nnpm ERR! engine Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Required: {\"node\":\"16.x\",\"npm\":\"8.x\"}\nnpm ERR! notsup Actual: {\"npm\":\"8.19.3\",\"node\":\"v18.12.1\"}\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /tmp/renovate-cache/others/npm/_logs/2022-11-12T08_26_30_850Z-debug-0.log\n", "stdout": "installing v2 tool node v18.12.1\nlinking tool node v18.12.1\nnode: v18.12.1 /usr/local/bin/node\nnpm: 8.19.2 /usr/local/bin/npm\nInstalled v2 /usr/local/buildpack/tools/v2/node.sh in 7 seconds\nskip cleanup, not a docker build: 96b4d4cb4ab1\ninstalling v2 tool npm v8.19.3\n\nadded 1 package in 6s\nlinking tool npm v8.19.3\n8.19.3\nInstalled v2 /usr/local/buildpack/tools/v2/npm.sh in 8 seconds\nskip cleanup, not a docker build: 96b4d4cb4ab1\n", "options": { "cwd": "/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/grafana/hm-panel-plugin", "encoding": "utf-8", "env": { "NPM_CONFIG_CACHE": "/tmp/renovate-cache/others/npm", "npm_config_store": "/tmp/renovate-cache/others/pnpm", "HOME": "/home/user", "PATH": "/home/user/.local/bin:/home/user/bin:/opt/buildpack/tools/python/3.9.3/bin:/home/user/.npm-global/bin:/home/ubuntu/renovateapp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "LC_ALL": "C.UTF-8", "LANG": "C.UTF-8", "BUILDPACK_CACHE_DIR": "/tmp/containerbase", "CONTAINERBASE_CACHE_DIR": "/tmp/containerbase" }, "maxBuffer": 10485760, "timeout": 900000 }, "exitCode": 1, "message": "Command failed: docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\":\"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\" -v \"/tmp/renovate-cache\":\"/tmp/renovate-cache\" -v \"/tmp/containerbase\":\"/tmp/containerbase\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/grafana/hm-panel-plugin\" docker.io/renovate/sidecar bash -l -c \"install-tool node 18.12.1 && install-tool npm 8.19.3 && hash -d npm 2>/dev/null || true && npm install --package-lock-only --no-audit --ignore-scripts\"\nnpm ERR! code EBADENGINE\nnpm ERR! engine Unsupported engine\nnpm ERR! engine Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Required: {\"node\":\"16.x\",\"npm\":\"8.x\"}\nnpm ERR! notsup Actual: {\"npm\":\"8.19.3\",\"node\":\"v18.12.1\"}\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /tmp/renovate-cache/others/npm/_logs/2022-11-12T08_26_30_850Z-debug-0.log\n", "stack": "ExecError: Command failed: docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\":\"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\" -v \"/tmp/renovate-cache\":\"/tmp/renovate-cache\" -v \"/tmp/containerbase\":\"/tmp/containerbase\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/grafana/hm-panel-plugin\" docker.io/renovate/sidecar bash -l -c \"install-tool node 18.12.1 && install-tool npm 8.19.3 && hash -d npm 2>/dev/null || true && npm install --package-lock-only --no-audit --ignore-scripts\"\nnpm ERR! code EBADENGINE\nnpm ERR! engine Unsupported engine\nnpm ERR! engine Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Required: {\"node\":\"16.x\",\"npm\":\"8.x\"}\nnpm ERR! notsup Actual: {\"npm\":\"8.19.3\",\"node\":\"v18.12.1\"}\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /tmp/renovate-cache/others/npm/_logs/2022-11-12T08_26_30_850Z-debug-0.log\n\n at ChildProcess. (/home/ubuntu/renovateapp/node_modules/renovate/dist/util/exec/common.js:87:24)\n at ChildProcess.emit (node:events:525:35)\n at ChildProcess.emit (node:domain:489:12)\n at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)" }, "type": "npm" } ```

Have you created a minimal reproduction repository?

No reproduction, but I have linked to a public repo where it occurs

github-actions[bot] commented 1 year ago

Hi there,

We have found that there's a problem with the logs. Depending on which situation applies follow one, some or all of these instructions.

No logs at all

If you haven't posted any log yet, we need you to find and copy/paste the log into the issue template.

Finding logs on hosted app

Click me to read instructions If you use the Renovate app (GitHub): 1. Go to the affected PR, and search for "View repository job log here" 1. Click on the link to go to the "Mend Renovate Dashboard" and log in 1. You are now in the correct repository log overview screen 1. Copy/paste the correct log 1. Follow the steps in the **formatting your logs** section

Finding logs when self-hosting

Click me to read instructions If you're running self-hosted, run with `LOG_LEVEL=debug` in your environment variables and search for whatever dependency/branch/PR that is causing the problem.

Insufficient logs

Click me to read instructions If you already gave us a log, and the Renovate team said it's not enough, then follow the instructions from the **No logs at all** section.

Formatting your logs

Click me to read instructions Please put your logs in a `
` and `` element like this:
Click me to see logs ``` Copy/paste your logs here, between the starting and ending backticks ```
rarkins commented 1 year ago

Please provide the full logs for that branch leading up to the error

hongbo-miao commented 1 year ago

Thanks @rarkins ! Here you are! It is over the GitHub comment length limit, so I uploaded as a file. log.txt

(I think this is the one. It is a little hard to match Renovate job id with the responding log. Is there a way? Thanks)

rarkins commented 1 year ago

Here is the log for the branch:

DEBUG: syncBranchState()(branch="renovate/tanstack-query-monorepo")
DEBUG: syncBranchState(): Branch cache not found, creating minimal branchState(branch="renovate/tanstack-query-monorepo")
DEBUG: getBranchPr(renovate/tanstack-query-monorepo)(branch="renovate/tanstack-query-monorepo")
DEBUG: findPr(renovate/tanstack-query-monorepo, undefined, open)(branch="renovate/tanstack-query-monorepo")
DEBUG: findPr(renovate/tanstack-query-monorepo, undefined, closed)(branch="renovate/tanstack-query-monorepo")
DEBUG: branchExists=false(branch="renovate/tanstack-query-monorepo")
DEBUG: dependencyDashboardCheck=undefined(branch="renovate/tanstack-query-monorepo")
DEBUG: recreateClosed is false(branch="renovate/tanstack-query-monorepo")
DEBUG: findPr(renovate/tanstack-query-monorepo, fix(deps): update tanstack-query monorepo to v4.15.0, !open)(branch="renovate/tanstack-query-monorepo")
DEBUG: prAlreadyExisted=false(branch="renovate/tanstack-query-monorepo")
DEBUG: Checking schedule(at any time, null)(branch="renovate/tanstack-query-monorepo")
DEBUG: No schedule defined(branch="renovate/tanstack-query-monorepo")
DEBUG: Branch needs creating(branch="renovate/tanstack-query-monorepo")
DEBUG: Using reuseExistingBranch: false(branch="renovate/tanstack-query-monorepo")
DEBUG: Setting current branch to main(branch="renovate/tanstack-query-monorepo")
DEBUG: latest commit(branch="renovate/tanstack-query-monorepo")
{
  "branchName": "main",
  "latestCommitDate": "2022-11-11T23:42:09-08:00"
}
DEBUG: manager.getUpdatedPackageFiles() reuseExistingBranch=false(branch="renovate/tanstack-query-monorepo")
DEBUG: npm.updateDependency(): dependencies.@tanstack/react-query = 4.15.0(branch="renovate/tanstack-query-monorepo")
DEBUG: Updating @tanstack/react-query in web/package.json(branch="renovate/tanstack-query-monorepo")
DEBUG: npm.updateDependency(): dependencies.@tanstack/react-query = 4.15.0(branch="renovate/tanstack-query-monorepo")
DEBUG: Updating @tanstack/react-query in grafana/hm-panel-plugin/package.json(branch="renovate/tanstack-query-monorepo")
DEBUG: npm.updateDependency(): devDependencies.@tanstack/react-query-devtools = 4.15.0(branch="renovate/tanstack-query-monorepo")
DEBUG: Updating @tanstack/react-query-devtools in web/package.json(branch="renovate/tanstack-query-monorepo")
DEBUG: npm.updateDependency(): devDependencies.@tanstack/react-query-devtools = 4.15.0(branch="renovate/tanstack-query-monorepo")
DEBUG: Updating @tanstack/react-query-devtools in grafana/hm-panel-plugin/package.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Updated 2 package files(branch="renovate/tanstack-query-monorepo")
DEBUG: Getting updated lock files(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing package.json files(branch="renovate/tanstack-query-monorepo")
{
  "packageFiles": [
    "api-node/package.json",
    "cypress/package.json",
    "ethereum/package.json",
    "grafana/hm-panel-plugin/package.json",
    "mobile/package.json",
    "package.json",
    "web/package.json"
  ]
}
DEBUG: Writing api-node/package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing cypress/package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing ethereum/package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing grafana/hm-panel-plugin/package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Massaging npm lock file before writing to disk(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing mobile/package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing web/package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Massaging npm lock file before writing to disk(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing any updated package files(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing web/package.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Writing grafana/hm-panel-plugin/package.json(branch="renovate/tanstack-query-monorepo")
DEBUG: npmrc file found in repository(branch="renovate/tanstack-query-monorepo")
DEBUG: Generating package-lock.json for web(branch="renovate/tanstack-query-monorepo")
DEBUG: Spawning npm install to create web/package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Updating lock file only(branch="renovate/tanstack-query-monorepo")
DEBUG: Using node constraint "18.12.1" from web/.nvmrc(branch="renovate/tanstack-query-monorepo")
DEBUG: Setting CONTAINERBASE_CACHE_DIR to /tmp/containerbase(branch="renovate/tanstack-query-monorepo")
DEBUG: Using docker to execute image: sidecar(branch="renovate/tanstack-query-monorepo")
DEBUG: Resolved stable matching version(branch="renovate/tanstack-query-monorepo")
{
  "toolName": "npm",
  "constraint": "8.x",
  "resolvedVersion": "8.19.3"
}
DEBUG: containerbaseDir is separate from cacheDir(branch="renovate/tanstack-query-monorepo")
DEBUG: No tag or tagConstraint specified for image: docker.io/renovate/sidecar(branch="renovate/tanstack-query-monorepo")
DEBUG: Docker image is already prefetched: docker.io/renovate/sidecar@sha256:5103d041fbc1e3deb7fd201ad0ed6ade56dc5c7f44c1613b094e58c022167fe8(branch="renovate/tanstack-query-monorepo")
DEBUG: exec completed(branch="renovate/tanstack-query-monorepo")
{
  "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\":\"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\" -v \"/tmp/renovate-cache\":\"/tmp/renovate-cache\" -v \"/tmp/containerbase\":\"/tmp/containerbase\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/web\" docker.io/renovate/sidecar bash -l -c \"install-tool node 18.12.1 && install-tool npm 8.19.3 && hash -d npm 2>/dev/null || true && npm install --package-lock-only --no-audit --ignore-scripts\"",
  "durationMs": 32939,
  "stdout": "installing v2 tool node v18.12.1\nlinking tool node v18.12.1\nnode: v18.12.1 /usr/local/bin/node\nnpm: 8.19.2  /usr/local/bin/npm\nInstalled v2 /usr/local/buildpack/tools/v2/node.sh in 7 seconds\nskip cleanup, not a docker build: fa57930b8e63\ninstalling v2 tool npm v8.19.3\n\nadded 1 package in 6s\nlinking tool npm v8.19.3\n8.19.3\nInstalled v2 /usr/local/buildpack/tools/v2/npm.sh in 8 seconds\nskip cleanup, not a docker build: fa57930b8e63\n\nup to date in 14s\n\n339 packages are looking for funding\n  run `npm fund` for details\n",
  "stderr": "npm notice \nnpm notice New major version of npm available! 8.19.3 -> 9.1.1\nnpm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.1.1>\nnpm notice Run `npm install -g npm@9.1.1` to update!\nnpm notice \n"
}
DEBUG: web/package-lock.json needs updating(branch="renovate/tanstack-query-monorepo")
DEBUG: npmrc file found in repository(branch="renovate/tanstack-query-monorepo")
DEBUG: Generating package-lock.json for grafana/hm-panel-plugin(branch="renovate/tanstack-query-monorepo")
DEBUG: Spawning npm install to create grafana/hm-panel-plugin/package-lock.json(branch="renovate/tanstack-query-monorepo")
DEBUG: Updating lock file only(branch="renovate/tanstack-query-monorepo")
DEBUG: Using node constraint "18.12.1" from web/.nvmrc(branch="renovate/tanstack-query-monorepo")
DEBUG: Setting CONTAINERBASE_CACHE_DIR to /tmp/containerbase(branch="renovate/tanstack-query-monorepo")
DEBUG: Using docker to execute image: sidecar(branch="renovate/tanstack-query-monorepo")
DEBUG: Resolved stable matching version(branch="renovate/tanstack-query-monorepo")
{
  "toolName": "npm",
  "constraint": "8.x",
  "resolvedVersion": "8.19.3"
}
DEBUG: containerbaseDir is separate from cacheDir(branch="renovate/tanstack-query-monorepo")
DEBUG: No tag or tagConstraint specified for image: docker.io/renovate/sidecar(branch="renovate/tanstack-query-monorepo")
DEBUG: Docker image is already prefetched: docker.io/renovate/sidecar@sha256:5103d041fbc1e3deb7fd201ad0ed6ade56dc5c7f44c1613b094e58c022167fe8(branch="renovate/tanstack-query-monorepo")
DEBUG: rawExec err(branch="renovate/tanstack-query-monorepo")
{
  "err": {
    "name": "ExecError",
    "cmd": "/bin/sh -c docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\":\"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\" -v \"/tmp/renovate-cache\":\"/tmp/renovate-cache\" -v \"/tmp/containerbase\":\"/tmp/containerbase\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/grafana/hm-panel-plugin\" docker.io/renovate/sidecar bash -l -c \"install-tool node 18.12.1 && install-tool npm 8.19.3 && hash -d npm 2>/dev/null || true && npm install --package-lock-only --no-audit --ignore-scripts\"",
    "stderr": "npm ERR! code EBADENGINE\nnpm ERR! engine Unsupported engine\nnpm ERR! engine Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Required: {\"node\":\"16.x\",\"npm\":\"8.x\"}\nnpm ERR! notsup Actual:   {\"npm\":\"8.19.3\",\"node\":\"v18.12.1\"}\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /tmp/renovate-cache/others/npm/_logs/2022-11-12T08_26_30_850Z-debug-0.log\n",
    "stdout": "installing v2 tool node v18.12.1\nlinking tool node v18.12.1\nnode: v18.12.1 /usr/local/bin/node\nnpm: 8.19.2  /usr/local/bin/npm\nInstalled v2 /usr/local/buildpack/tools/v2/node.sh in 7 seconds\nskip cleanup, not a docker build: 96b4d4cb4ab1\ninstalling v2 tool npm v8.19.3\n\nadded 1 package in 6s\nlinking tool npm v8.19.3\n8.19.3\nInstalled v2 /usr/local/buildpack/tools/v2/npm.sh in 8 seconds\nskip cleanup, not a docker build: 96b4d4cb4ab1\n",
    "options": {
      "cwd": "/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/grafana/hm-panel-plugin",
      "encoding": "utf-8",
      "env": {
        "NPM_CONFIG_CACHE": "/tmp/renovate-cache/others/npm",
        "npm_config_store": "/tmp/renovate-cache/others/pnpm",
        "HOME": "/home/user",
        "PATH": "/home/user/.local/bin:/home/user/bin:/opt/buildpack/tools/python/3.9.3/bin:/home/user/.npm-global/bin:/home/ubuntu/renovateapp/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
        "LC_ALL": "C.UTF-8",
        "LANG": "C.UTF-8",
        "BUILDPACK_CACHE_DIR": "/tmp/containerbase",
        "CONTAINERBASE_CACHE_DIR": "/tmp/containerbase"
      },
      "maxBuffer": 10485760,
      "timeout": 900000
    },
    "exitCode": 1,
    "message": "Command failed: docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\":\"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\" -v \"/tmp/renovate-cache\":\"/tmp/renovate-cache\" -v \"/tmp/containerbase\":\"/tmp/containerbase\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/grafana/hm-panel-plugin\" docker.io/renovate/sidecar bash -l -c \"install-tool node 18.12.1 && install-tool npm 8.19.3 && hash -d npm 2>/dev/null || true && npm install --package-lock-only --no-audit --ignore-scripts\"\nnpm ERR! code EBADENGINE\nnpm ERR! engine Unsupported engine\nnpm ERR! engine Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Required: {\"node\":\"16.x\",\"npm\":\"8.x\"}\nnpm ERR! notsup Actual:   {\"npm\":\"8.19.3\",\"node\":\"v18.12.1\"}\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /tmp/renovate-cache/others/npm/_logs/2022-11-12T08_26_30_850Z-debug-0.log\n",
    "stack": "ExecError: Command failed: docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\":\"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com\" -v \"/tmp/renovate-cache\":\"/tmp/renovate-cache\" -v \"/tmp/containerbase\":\"/tmp/containerbase\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/mnt/renovate/gh/Hongbo-Miao/hongbomiao.com/grafana/hm-panel-plugin\" docker.io/renovate/sidecar bash -l -c \"install-tool node 18.12.1 && install-tool npm 8.19.3 && hash -d npm 2>/dev/null || true && npm install --package-lock-only --no-audit --ignore-scripts\"\nnpm ERR! code EBADENGINE\nnpm ERR! engine Unsupported engine\nnpm ERR! engine Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Not compatible with your version of node/npm: hm-panel-plugin@1.0.0\nnpm ERR! notsup Required: {\"node\":\"16.x\",\"npm\":\"8.x\"}\nnpm ERR! notsup Actual:   {\"npm\":\"8.19.3\",\"node\":\"v18.12.1\"}\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /tmp/renovate-cache/others/npm/_logs/2022-11-12T08_26_30_850Z-debug-0.log\n\n    at ChildProcess.<anonymous> (/home/ubuntu/renovateapp/node_modules/renovate/dist/util/exec/common.js:87:24)\n    at ChildProcess.emit (node:events:525:35)\n    at ChildProcess.emit (node:domain:489:12)\n    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)"
  }
}
rarkins commented 1 year ago

In this case it's the node version which is wrong: Required: {\"node\":\"16.x\",\"npm\":\"8.x\"}\nnpm ERR! notsup Actual: {\"npm\":\"8.19.3\",\"node\":\"v18.12.1\"}

It seems to say:

DEBUG: Using node constraint "18.12.1" from web/.nvmrc(branch="renovate/tanstack-query-monorepo")

Any idea why it's using that folder?

I'm not sure we currently support mixed versions in the same branch. To debug it we'd want a simplified reproduction repo (instructions to follow)

github-actions[bot] commented 1 year ago

Hi there,

Get your issue fixed faster by creating a minimal reproduction. This means a repository dedicated to reproducing this issue with the minimal dependencies and config possible.

Before we start working on your issue we need to know exactly what's causing the current behavior. A minimal reproduction helps us with this.

To get started, please read our guide on creating a minimal reproduction.

We may close the issue if you, or someone else, haven't created a minimal reproduction within two weeks. If you need more time, or are stuck, please ask for help or more time in a comment.

Good luck,

The Renovate team

hongbo-miao commented 1 year ago

Yeah, I saw that

DEBUG: Using node constraint "18.12.1" from web/.nvmrc(branch="renovate/tanstack-query-monorepo")

I have multiple .nvmrc in each Node.js project folders, such as

Yeah, I guess Renovate is picking up first .nvmrc it met.

Sounds good, if need I will provide a simplified reproduction repo soon! Thanks!

PhilipAbed commented 1 year ago

the dependency tanstack exists in both:

  1. grafana/hm-panel-plugin/package.json
  2. web/package.json

check the files: https://github.com/Hongbo-Miao/hongbomiao.com/pull/5997/files

the main issue here is that we have 2 repos with 2 different .nvmrc and each has a package.json with the same dependency

maybe use this? https://docs.renovatebot.com/configuration-options/#additionalbranchprefix

it would split your PRs instead of having the same branch for both folders which is causing the confusion

Churro commented 1 year ago

Hmm, would it probably be an option to use the .nvmrc located relative to the lockfile, rather than the package file?

getAdditionalFiles() triggers an update of all relevant lockfiles here. The invoked npm.generateLockFile() in turn calls getNodeToolConstraint() in line 66. This then finally leads to: https://github.com/renovatebot/renovate/blob/49b7b733cd1ff5b80e57394fb1a814b1e7805df0/lib/modules/manager/npm/post-update/node-version.ts#L35-L41

config.packageFile is web/package.json, so the node constraint 18.12.1 is extracted from web/.nvmrc

So an intuitive fix for me would be to search .nvmrc in the folder where the current lock file is located too:

diff --git a/lib/modules/manager/npm/post-update/npm.ts b/lib/modules/manager/npm/post-update/npm.ts
--- a/lib/modules/manager/npm/post-update/npm.ts    (revision 49b7b733cd1ff5b80e57394fb1a814b1e7805df0)
+++ b/lib/modules/manager/npm/post-update/npm.ts    (date 1668359225943)
@@ -33,6 +33,7 @@
   const lockFileName = upath.join(lockFileDir, filename);

   logger.debug(`Spawning npm install to create ${lockFileDir}/${filename}`);
+  config.packageFile = lockFileName;
   const { skipInstalls, postUpdateOptions } = config;

   let lockFile: string | null = null;

When running this on https://github.com/Hongbo-Miao/hongbomiao.com, it works just fine and node constraints are extracted as expected. However, I'm not really familiar with the npm manager, so probably there are good reasons against doing what I suggested but in case this is valid, it should also be checked if relevant for yarn.generateLockFile(), pnpm.generateLockFile(), etc.

rarkins commented 1 year ago

.nvmrc should be searched in the directory which we execute npm. I'm not sure if we should mess with config.packageFile directly though

guillaumewuip commented 1 year ago

would it probably be an option to use the .nvmrc located relative to the lockfile

I'm in a similar situation and such a change would help. My monorepo looks like this

packages
  packageA/
      package.json
  packageB/
      package.json
apps
  appA/
      package.json
package.json
pnpm-lock.yaml
.nvmrc

Only the root .nvmrc specifies the Node.js version to be used across the repo (eg. not latest but 16.17.1) but Renovate is using the latest version instead it fails to find any constraints from the current package package.json file siblings.

https://github.com/renovatebot/renovate/blob/49b7b733cd1ff5b80e57394fb1a814b1e7805df0/lib/modules/manager/npm/post-update/node-version.ts#L45

  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"Generating pnpm-lock.yaml for .",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"Spawning pnpm install to create pnpm-lock.yaml",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"No node constraint found - using latest",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"Setting CONTAINERBASE_CACHE_DIR to /renovate-manager-data/renovate-manager/renovate/cache/containerbase",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"Using docker to execute image: sidecar",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","toolName":"node","constraint":null,"resolvedVersion":"v18.12.1","msg":"Resolved stable matching version",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"containerbaseDir is inside cacheDir",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"No tag or tagConstraint specified for image: docker.io/renovate/sidecar",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"Fetching Docker image: docker.io/renovate/sidecar",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","msg":"Finished fetching Docker image docker.io/renovate/sidecar@sha256:5103d041fbc1e3deb7fd201ad0ed6ade56dc5c7f44c1613b094e58c022167fe8",v":0}
  {"name":"renovate","repository":"<rep>","branch":"renovate/google.maps-3.x","err":{"name":"ExecError","cmd":"/bin/sh -c docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/renovate-manager-data/renovate-manager/renovate/base/repos/github/\":\"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\" -v \"/renovate-manager-data/renovate-manager/renovate/cache\":\"/renovate-manager-data/renovate-manager/renovate/cache\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\" docker.io/renovate/sidecar bash -l -c \"install-tool node v18.12.1 && install-tool pnpm 7.5.2 && pnpm install --recursive --lockfile-only --ignore-scripts --ignore-pnpmfile\"","stderr":"","stdout":"installing v2 tool node v18.12.1\nlinking tool node v18.12.1\nnode: v18.12.1 /usr/local/bin/node\nnpm: 8.19.2  /usr/local/bin/npm\nInstalled v2 /usr/local/buildpack/tools/v2/node.sh in 3 seconds\nskip cleanup, not a docker build: a839625bbc54\ninstalling v2 tool pnpm v7.5.2\n\nadded 1 package in 721ms\nlinking tool pnpm v7.5.2\n7.5.2\nInstalled v2 /usr/local/buildpack/tools/v2/pnpm.sh in 1 seconds\nskip cleanup, not a docker build: a839625bbc54\n ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version)\n\nYour Node version is incompatible with \"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\".\n\nExpected version: >=16.17.1 <17\nGot: v18.12.1\n\nThis is happening because the package's manifest has an engines.node field specified.\nTo fix this issue, install the required Node version.\n","options":{"cwd":"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>","encoding":"utf-8","env":{"NPM_CONFIG_CACHE":"/renovate-manager-data/renovate-manager/renovate/cache/others/npm","npm_config_store":"/renovate-manager-data/renovate-manager/renovate/cache/others/pnpm","HOME":"/home/ubuntu","PATH":"/home/ubuntu/bin:/home/ubuntu/.npm-global/bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","LC_ALL":"C.UTF-8","LANG":"C.UTF-8","DOCKER_HOST":"127.0.0.1:2376","DOCKER_TLS_VERIFY":"true","DOCKER_CERT_PATH":"/docker/certs/client","BUILDPACK_CACHE_DIR":"/renovate-manager-data/renovate-manager/renovate/cache/containerbase","CONTAINERBASE_CACHE_DIR":"/renovate-manager-data/renovate-manager/renovate/cache/containerbase"},"maxBuffer":10485760,"timeout":600000},"exitCode":1,"message":"Command failed: docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\":\"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\" -v \"/renovate-manager-data/renovate-manager/renovate/cache\":\"/renovate-manager-data/renovate-manager/renovate/cache\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\" docker.io/renovate/sidecar bash -l -c \"install-tool node v18.12.1 && install-tool pnpm 7.5.2 && pnpm install --recursive --lockfile-only --ignore-scripts --ignore-pnpmfile\"\n","stack":"ExecError: Command failed: docker run --rm --name=renovate_sidecar --label=renovate_child -v \"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\":\"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\" -v \"/renovate-manager-data/renovate-manager/renovate/cache\":\"/renovate-manager-data/renovate-manager/renovate/cache\" -e NPM_CONFIG_CACHE -e npm_config_store -e BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w \"/renovate-manager-data/renovate-manager/renovate/base/repos/github/<rep>\" docker.io/renovate/sidecar bash -l -c \"install-tool node v18.12.1 && install-tool pnpm 7.5.2 && pnpm install --recursive --lockfile-only --ignore-scripts --ignore-pnpmfile\"\n\n    at ChildProcess.<anonymous> (/usr/src/app/node_modules/renovate/lib/util/exec/common.ts:99:11)\n    at ChildProcess.emit (node:events:525:35)\n    at ChildProcess.emit (node:domain:489:12)\n    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)"},"msg":"rawExec err","v":0}
rarkins commented 1 year ago

@guillaumewuip You're describing a similar but different problem. The best thing would be a minimal reproduction repository attached to a different issue

hongbo-miao commented 1 year ago

Here you are!

rarkins commented 1 year ago

Thanks, could you also update the readme file to describe expected vs observed behavior. That way it's all contained in the same repo

hongbo-miao commented 1 year ago

@rarkins added in the readme at https://github.com/Hongbo-Miao/bug-renovate-node-version! Thanks! 😃

PhilipAbed commented 1 year ago

@Hongbo-Miao Thanks for reporting and reproduction, i took a peek at your profile, what a lovely view! xD

rarkins commented 1 year ago

Reproduction forked to https://github.com/renovate-reproductions/18885

rarkins commented 1 year ago

Also confirmed this problem:

DEBUG: Generating package-lock.json for grafana/hm-panel-plugin (repository=renovate-reproductions/18885, branch=renovate/tanstack-query-monorepo)
DEBUG: Spawning npm install to create grafana/hm-panel-plugin/package-lock.json (repository=renovate-reproductions/18885, branch=renovate/tanstack-query-monorepo)
DEBUG: Updating lock file only (repository=renovate-reproductions/18885, branch=renovate/tanstack-query-monorepo)
DEBUG: Using node constraint "18.12.1" from web/.nvmrc (repository=renovate-reproductions/18885, branch=renovate/tanstack-query-monorepo)
rarkins commented 1 year ago

I debugged and found that we check for an .nvmrc in the directory of the packageFile but it instead should be in the directory of the lock file.

rarkins commented 1 year ago

How's this look? https://github.com/renovate-reproductions/18885/pull/1/files

The second lock file has a lot of removed lines, but I wonder if it's a mistake in the reproduction because it has only one dependency in package.json

hongbo-miao commented 1 year ago

Thanks @rarkins ! It looks good! Yeah, I forgot to update the lock file when I created that repo.

renovate-release commented 1 year ago

:tada: This issue has been resolved in version 34.27.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: