Lintstaged process is stuck when running rubocop command

84 views Asked by At

I try to lint my .rb files while committing.

Here is my .lintstagedrc file:

{
    "*.rb": [
      "bundle exec rubocop --require rubocop-airbnb",
    ]
}

Lint-staged is setup with husky.

When I change a .rb file, it tries to run the command but it is stuck. I tried to run the command with the debug flags on, but I did not see any useful information:

lint-staged:bin Running `[email protected]` on Node.js v18.19.0 (darwin) 
....
....
....
....
[COMPLETED] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] .lintstagedrc — 3 files
[STARTED] *.rb — 1 file
[STARTED] *.erb — 0 files
[SKIPPED] *.erb — no files
[STARTED] bundle exec rubocop --version
=> Froze

What can be the root cause?

Env

  • Running lint-staged 15.2.0
  • Running node 18.19.0
  • Running rubocop-airbnb 6.0.0
  • Commands run fine locally
  • bundle exec erblint & bundle exec htmlbeautifier commands go through when added into the lintstagedrc file
2

There are 2 answers

0
mtgto On BEST ANSWER

This problem was fixed by v15.2.1. Try to update lint-staged.

0
Adam Harrison On

Are you by chance running rubocop in server mode? Rubocop will hang if it is running in server mode (see this issue for details: https://github.com/lint-staged/lint-staged/issues/1293).

Try running rubocop --stop-server and then try your commit (or yarn lint-staged). A coworker had a similar problem, something in their config caused rubocop to automatically start a server in the background, resulting in this issue.