diff --git a/src/Composer/Cache.php b/src/Composer/Cache.php
index 22e744fd2..9f9c55ba6 100644
--- a/src/Composer/Cache.php
+++ b/src/Composer/Cache.php
@@ -43,11 +43,12 @@ class Cache
$this->whitelist = $whitelist;
$this->filesystem = $filesystem ?: new Filesystem();
- if (!is_dir($this->root)) {
- if (!@mkdir($this->root, 0777, true)) {
- $this->io->writeError('Cannot create cache directory ' . $this->root . ', proceeding without cache');
- $this->enabled = false;
- }
+ if (
+ (!is_dir($this->root) && !@mkdir($this->root, 0777, true))
+ || !is_writable($this->root)
+ ) {
+ $this->io->writeError('Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache');
+ $this->enabled = false;
}
}