{"record":{"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/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Filesystem/Filesystem.php#L361-L397","documentation":"Thrown by Filesystem::relativeLink() when the Symfony\\Component\\Filesystem\\Filesystem class is not autoloadable. Laravel computes relative symlinks by delegating path arithmetic to symfony/filesystem's makePathRelative(); without that package the operation cannot be performed safely, so it errors rather than silently producing a broken link.","triggerScenarios":"Calling File::relativeLink($target, $link) (often via storage:link with relative paths, or during package asset publishing) in a project where composer has not installed symfony/filesystem.","commonSituations":"Slimmed dependency tree where symfony/filesystem was removed; using a standalone subset of Illuminate\\Filesystem outside a full Laravel app; composer install --no-dev against a constraint that dropped the package.","solutions":["Run composer require symfony/filesystem.","If you do not need a relative link, use File::link($target, $link) for an absolute symlink instead.","Verify the package is present in composer.lock after deploy: composer show symfony/filesystem.","Pin the package in composer.json so it is not stripped by dependency resolution."],"exampleFix":"// before\nFile::relativeLink($target, $link); // throws if symfony/filesystem absent\n\n// after (terminal)\n// composer require symfony/filesystem\nFile::relativeLink($target, $link);","handlingStrategy":"validation","validationCode":"if (! class_exists(\\Symfony\\Component\\Filesystem\\Filesystem::class)) {\n    throw new RuntimeException('Run: composer require symfony/filesystem');\n}\nFile::relativeLink($target, $link);","typeGuard":"function supportsRelativeLink(): bool {\n    return class_exists(\\Symfony\\Component\\Filesystem\\Filesystem::class);\n}","tryCatchPattern":"try {\n    File::relativeLink($target, $link);\n} catch (\\RuntimeException $e) {\n    File::link($target, $link); // absolute fallback\n}","preventionTips":["Require symfony/filesystem if you use relativeLink().","Use absolute File::link() when the relative form is not needed.","Verify composer.lock after dependency changes.","Document optional dependencies in your README."],"tags":["filesystem","symlink","symfony","dependency"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}