Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative symlinks are created relative to the current directory #725

Closed
turikhay opened this issue Aug 21, 2021 · 3 comments · Fixed by #1079
Closed

Relative symlinks are created relative to the current directory #725

turikhay opened this issue Aug 21, 2021 · 3 comments · Fixed by #1079
Labels

Comments

@turikhay
Copy link

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)

@kylecarbs
Copy link
Contributor

Working on a fix.

kylecarbs added a commit to kylecarbs/memfs that referenced this issue Dec 13, 2024
Fixes streamich#725.

Symlinks are intended to be stored as relative
paths to their target file.
kylecarbs added a commit to kylecarbs/memfs that referenced this issue Dec 13, 2024
Fixes streamich#725.

Symlinks are intended to be stored as relative
paths to their target file.
@kylecarbs
Copy link
Contributor

Fix is in the attached PR.

Feel free to use:

    "memfs": "npm:@kylecarbs/memfs@^4.15.0",

in your package.json until this is merged and a new release is out if you encounter this issue.

@G-Rath G-Rath closed this as completed in 63e3873 Dec 22, 2024
github-actions bot pushed a commit that referenced this issue Dec 22, 2024
## [4.15.1](v4.15.0...v4.15.1) (2024-12-22)

### Bug Fixes

* resolve relative symlinks to the current directory ([#1079](#1079)) ([63e3873](63e3873)), closes [#725](#725)
Copy link

🎉 This issue has been resolved in version 4.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants