Skip to content

Relative symlinks are created relative to the current directory #725

Closed
redwoodjs/redwood
#11803
@turikhay

Description

This is a minor inconsistency with Node.js. According to their docs:

Relative targets are relative to the link’s parent directory.

Take a look:

const MemFs = require('memfs');
const fs = MemFs.Volume.fromJSON({
    '/test/target': 'foo',
    '/test/folder': null
});

// create symlink
// here memfs resolves '../target' relative to cwd, not '/test/folder'
fs.symlinkSync('../target', '/test/folder/link');

// Error: ENOENT: no such file or directory, open '/test/folder/link'
fs.readFileSync('/test/folder/link');
const fs = require('fs');

// create symlink
fs.symlinkSync('../target', 'test/folder/link');

// ok!
fs.readFileSync('test/folder/link');

(For your convenience, I've created the test repo)

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions