{"id":"32c2f7a7a2ee7ff4","repo":"laravel/framework","slug":"to-enable-support-for-relative-links-please-insta","errorCode":null,"errorMessage":"To enable support for relative links, please install the symfony/filesystem package.","messagePattern":"To enable support for relative links, please install the symfony/filesystem package\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Filesystem/Filesystem.php","lineNumber":379,"sourceCode":"\n        $mode = $this->isDirectory($target) ? 'J' : 'H';\n\n        exec(\"mklink /{$mode} \".escapeshellarg($link).' '.escapeshellarg($target));\n    }\n\n    /**\n     * Create a relative symlink to the target file or directory.\n     *\n     * @param  string  $target\n     * @param  string  $link\n     * @return void\n     *\n     * @throws \\RuntimeException\n     */\n    public function relativeLink($target, $link)\n    {\n        if (! class_exists(SymfonyFilesystem::class)) {\n            throw new RuntimeException(\n                'To enable support for relative links, please install the symfony/filesystem package.'\n            );\n        }\n\n        $relativeTarget = (new SymfonyFilesystem)->makePathRelative($target, dirname($link));\n\n        $this->link($this->isFile($target) ? rtrim($relativeTarget, '/') : $relativeTarget, $link);\n    }\n\n    /**\n     * Extract the file name from a file path.\n     *\n     * @param  string  $path\n     * @return string\n     */\n    public function name($path)\n    {\n        return pathinfo($path, PATHINFO_FILENAME);","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Filesystem/Filesystem.php#L361-L397","documentation":"Thrown by Filesystem::relativeLink() when the Symfony\\Component\\Filesystem\\Filesystem class is not loadable. Laravel delegates computing a portable relative path between target and link to symfony/filesystem's makePathRelative(); without that package the operation cannot be performed safely across platforms, so it errors rather than producing a wrong absolute link.","triggerScenarios":"Calling File::relativeLink($target, $link) in a project where composer did not install symfony/filesystem (it is a suggested, not required, dependency of illuminate/filesystem in slim installs).","commonSituations":"Using illuminate/filesystem outside a full Laravel app (e.g. a standalone script or micro-framework) that didn't require symfony/filesystem; aggressive dependency pruning; custom composer.json that excludes the package.","solutions":["Install the package: `composer require symfony/filesystem`.","If you cannot add it, use File::link() (absolute symlink) instead.","Pin a compatible version aligned with your Symfony components to avoid conflicts."],"exampleFix":"// before - throws because symfony/filesystem is absent\nFile::relativeLink($target, $link);\n\n// after - install it, or fall back to an absolute link\n// shell: composer require symfony/filesystem\n// or code:\nFile::link($target, $link);","handlingStrategy":"validation","validationCode":"if (! class_exists(\\Symfony\\Component\\Filesystem\\Filesystem::class)) {\n    // use absolute link instead\n    File::link($target, $link);\n} else {\n    File::relativeLink($target, $link);\n}","typeGuard":"function relativeLinksAvailable(): bool\n{\n    return class_exists(\\Symfony\\Component\\Filesystem\\Filesystem::class);\n}","tryCatchPattern":"try {\n    File::relativeLink($target, $link);\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'symfony/filesystem')) {\n        File::link($target, $link);\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Add symfony/filesystem to composer.json if you call relativeLink().","Check class_exists before calling in optional-dependency code.","Document optional deps in your package README."],"tags":["filesystem","dependency","symfony","symlink"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}