commitlint icon indicating copy to clipboard operation
commitlint copied to clipboard

Config not found when used with `rush` and `pnpm v7`

Open Faithfinder opened this issue 3 years ago • 3 comments

Expected Behavior

All good

Current Behavior

Error: Cannot find module "@commitlint/config-conventional"

Affected packages

  • [x] cli
  • [ ] core
  • [ ] prompt
  • [ ] config-angular

Steps to Reproduce (for bugs)

Repro here: https://github.com/Faithfinder/rush-pnpm7-commilint-repro

  • Checkout main
  • rush update to install git hooks
  • Try to make a commit (empty is fine) with random letters, get error:
â§—   input: asdfasdf
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
  • Try to make a commit conforming to standard, ie test: commit, succeed
    • These steps are just to check that commitlint is set up correctly and working, all behaviour intended.
  • Checkout pnpmv7 branch (or update pnpm to v7 in rush.json)
  • Try to make the same conforming commit, get error:
dependencies:
+ @commitlint/cli 17.0.2
+ @commitlint/config-conventional 17.0.2

Progress: resolved 189, reused 189, downloaded 0, added 189, done
Auto install completed successfully

Error: Cannot find module "@commitlint/config-conventional" from "/home/misamoto/Source/OpenSource/rush-pnpm7-commilint-repro"
.commitlintrc.json ```json { "extends": ["@commitlint/config-conventional"] } ```

Context

I've initially opened the bug report in rushstack repo, however it was closed with a statement that the error is on commitlint's side, so now I'm hoping for you guys to release a fix. Here's the full response from rushstack:

This isn't an issue with Rush or PNPM, it's an issue with commitlint. Changing this line to cwd: __dirname and this line to cwd: cwd fixes the issue. commitlint uses an incorrect assumption about the way it was installed when performing module resolution that was exposed by changes to the installation topology in PNPM 7.

I'd recommend you raise an issue with commitlint. They should be able to fix this issue by either using a more conventional module resolution tool (like node's built-in require) or correctly passing module context between calls to their custom module resolver.

Workaround:

Target the config directly:

{
    "extends": ["./common/autoinstallers/commitlint/node_modules/@commitlint/config-conventional/index.js"]
}

Faithfinder avatar Sep 26 '22 18:09 Faithfinder

Happy for a PR here

escapedcat avatar Sep 27 '22 02:09 escapedcat

@escapedcat any update on this issue ?

insignias avatar Nov 17 '22 00:11 insignias

Nope :(

escapedcat avatar Nov 17 '22 08:11 escapedcat