string('extensions.directory'), config()->string('extensions.assets_directory'), storage_path('app'.DIRECTORY_SEPARATOR.'extensions-tmp'), ] as $directory) { // A directory that does not exist yet is created inside the nearest one that does. $existing = $this->nearestExisting($directory); if (! is_dir($existing) || ! is_writable($existing)) { $blocked[$existing] = $existing; } } if ($blocked === []) { return; } throw new InvalidExtensionException(sprintf( 'The panel cannot write to %s. Give %s write access to %s, then try again.', implode(', ', $blocked), $this->processUser(), count($blocked) === 1 ? 'it' : 'them', )); } private function nearestExisting(string $path): string { while (! file_exists($path) && dirname($path) !== $path) { $path = dirname($path); } return $path; } private function processUser(): string { $user = function_exists('posix_geteuid') ? posix_getpwuid(posix_geteuid()) : false; return $user === false ? 'the user the panel runs as' : "the {$user['name']} user"; } }