Skip to content

Commit

Permalink
[Fix #12638] Fix an Errno::ENOENT error when using server mode
Browse files Browse the repository at this point in the history
Fixes #12638.

There is a possibility of a race condition occurring with the status file
when using server mode. The status file is updated to a new status by
`Cache.write_status_file` (`Pathname#write`), so there is no need to clear
it by deleting the file.

Due to the difficulty in reproducing this race conditions, test code for this
have not been added.
  • Loading branch information
koic authored and bbatsov committed Jan 22, 2024
1 parent 96542aa commit 60a9350
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 2 deletions.
1 change: 1 addition & 0 deletions changelog/fix_an_error_when_using_sever_mode.md
@@ -0,0 +1 @@
* [#12638](https://github.com/rubocop/rubocop/issues/12638): Fix an `Errno::ENOENT` error when using server mode. ([@koic][])
1 change: 0 additions & 1 deletion lib/rubocop/server/client_command/exec.rb
Expand Up @@ -17,7 +17,6 @@ module ClientCommand
class Exec < Base
def run
ensure_server!
Cache.status_path.delete if Cache.status_path.file?
read_stdin = ARGV.include?('-s') || ARGV.include?('--stdin')
send_request(
command: 'exec',
Expand Down
1 change: 0 additions & 1 deletion lib/rubocop/server/server_command/exec.rb
Expand Up @@ -16,7 +16,6 @@ module ServerCommand
# @api private
class Exec < Base
def run
Cache.status_path.delete if Cache.status_path.file?
# RuboCop output is colorized by default where there is a TTY.
# We must pass the --color option to preserve this behavior.
@args.unshift('--color') unless %w[--color --no-color].any? { |f| @args.include?(f) }
Expand Down

0 comments on commit 60a9350

Please sign in to comment.