Skip to content

fs.realpathSync returns a unix path on a windows system in node sea #305

Open

Description

@spotandjake

What version of pkg are you using?

6.22.0

What version of Node.js are you using?

24.21.0

What operating system are you using?

macOS, Windows, Ubuntu 20.04

What CPU architecture are you using?

x86_64, arm64

What Node versions, OSs and CPU architectures are you building for?

node24-macos-arm64, node24-win-x64

Describe the Bug

I am currently working on switching a project from the classic mode to the newer sea mode. I am calling fs.realpathSync on a path in the virtual file system to resolve a symlink however instead of returning: C:\snapshot\ it returns /snapshot/ in the posix form.

I think fixing this would involve something along the lines of adding:

var _origRealpathSync = VirtualFileSystem.prototype.realpathSync;
VirtualFileSystem.prototype.realpathSync = function (inputPath, options) {
   return toPlatformPath(_origRealpathSync.call(this, inputPath, options));
};

to prelude/sea-vfs-setup.js when the paths to the vfs are converted from windows to posix.

To work around this locally I just used path.resolve after fs.realpathSync

Expected Behavior

I would expect the path being returned to be a windows path instead of a posix path.

To Reproduce

It should just be a matter of packaging a small app that bundles a symlink into the stdlib and then calling fs.realPathSync on that path on windows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions