From cb475fd8c0bbfcb00340459966b6780f39ea87a7 Mon Sep 17 00:00:00 2001 From: Cuki <2996147+cuki@users.noreply.github.com> Date: Wed, 17 Jul 2019 06:59:45 +0200 Subject: [PATCH] Fix: Cache file error handling on read-only file system. (fixes #11945) (#11946) --- lib/cli-engine/cli-engine.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cli-engine/cli-engine.js b/lib/cli-engine/cli-engine.js index d7512fe3f36..7f80887f086 100644 --- a/lib/cli-engine/cli-engine.js +++ b/lib/cli-engine/cli-engine.js @@ -734,7 +734,10 @@ class CLIEngine { try { fs.unlinkSync(cacheFilePath); } catch (error) { - if (!error || error.code !== "ENOENT") { + const errorCode = error && error.code; + + // Ignore errors when no such file exists or file system is read only (and cache file does not exist) + if (errorCode !== "ENOENT" && !(errorCode === "EROFS" && !fs.existsSync(cacheFilePath))) { throw error; } }