how is realpathSync supposed to work?

546 views
Skip to first unread message

Cliffano Subagio

unread,
Sep 9, 2010, 2:41:56 AM9/9/10
to nod...@googlegroups.com
Hi,

I was testing an app that uses realpathSync, and I found out that it returns different value compared to realpath itself on certain path settings.

1. mkdir -p /a/b/c/d/e/f/g/h/i/j
2. touch /a/b/c/d/e/f/g/h/i/j/x.txt
3. cd /a/b
4. ln -s /a/b/c/d/e/f current

I then ran the following code:
================
var fs = require('fs'),
     sys = require('sys');
sys.puts(fs.realpathSync('/a/b/current/g/h/i/j/x.txt'));
================

I got the result
    /a/b/c/d/e/f

Whereas running
    realpath /a/b/current/g/h/i/j/x.txt
gave me
    /a/b/c/d/e/f/g/h/i/j/x.txt

However, when I redid the same thing (steps 1, 2, 3) but with a different way of creating the symlink on step 4
4. ln -s c/d/e/f current

I got identical result from both the node code and realpath command, the result was
    /a/b/c/d/e/f/g/h/i/j/x.txt

Could this be a bug with node realpathSync? or did I misunderstand how realpathSync is supposed to work?

Tested on Ubuntu Lucid with node 0.2.0 .

Cheers,
Cliff.

Isaac Schlueter

unread,
Sep 9, 2010, 6:16:55 PM9/9/10
to nod...@googlegroups.com
Can you do this test with the code on ry/master? I suspect that this
commit might fix your problem:
http://github.com/ry/node/commit/ba0c32e2e1aa873728a54df12a3785091f475143

--i

> --
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en.
>

Cliffano Subagio

unread,
Sep 14, 2010, 1:20:37 AM9/14/10
to nod...@googlegroups.com
Retested with code on ry/master, still the same problem.

Isaac Schlueter

unread,
Sep 14, 2010, 12:28:59 PM9/14/10
to nod...@googlegroups.com

r...@tinyclouds.org

unread,
Sep 14, 2010, 6:48:36 PM9/14/10
to nod...@googlegroups.com
On Tue, Sep 14, 2010 at 9:28 AM, Isaac Schlueter <i...@izs.me> wrote:
> Aha.  I see it.  Fixed by
> http://github.com/isaacs/node/commit/2e8ae753d2d366ab4829b34275283e182daa76fc
>

Thanks isaac. committed in 686d9f9cc6688b4febf8ebc4655c1d1bc3515829.

Reply all
Reply to author
Forward
0 new messages