Open amir-reza-bijandi opened 1 day ago
It looks like the first argument needs to be a relative path from link's path to target. If I modified the main.ts like the below, it worked:
import * as fs from "@std/fs";
await fs.ensureSymlink("./test.txt", "./dir/test.link.txt");
$ tree dir
dir
├── test.link.txt -> ./test.txt
└── test.txt
1 directory, 2 files
I agree this is not clear from the documentation. I think we need to update the parameter document to make this clear.
I agree this is not clear from the documentation. I think we need to update the parameter document to make this clear.
I don't think this is a documentation issue. The reason for that is that it just doesn't make any sense. Just think about it, Deno.symlink
and fs.ensureLink
do not have this issue and do not need a relative relation between two paths, so why would fs.ensureSymlink
behave this way?
Even after seeing your solution and testing it, it just doesn't click in my head... I get it... but it always takes a second to process what the hell is going on...
I checked how Deno.symlink
works, and it looks like working as the same way as fs.ensureSymlink
:
When you have file in this way:
$ tree dir
dir
└── file.txt
and you'd like to create a symlink dir/link.txt
pointing dir/file.txt
, then you need to call Deno.symlink
like:
await Deno.symlink("file.txt", "dir/link.txt");
and the below doesn't work (the below script creates a broken symlink):
await Deno.symlink("dir/file.txt", "dir/link.txt");
I think this behavior comes from how ln -s
command works. If you like to achieve the same as ln -s
, you need to call:
ln -s file.txt dir/link.txt
and the below creates a broken link:
ln -s dir/file.txt dir/link.txt
Describe the bug
ensureSymlink
method does not work! Well... Mostly... I'm new to using Deno and it's std library and I was trying out @std/fs and that's when I encountered an error with my very basic code...Error:
As you can see the target file exists and i'm trying to create the symlink inside the same directory as the target file:
I tried removing the
./
from the paths, but it didn't work, and I got the same error again. The funny part is that if the target file and the path for creating symlink are both at the root of the working directory, The method work! So this line of code works with no problem:One more thing that i tried that also did not work was this:
I even made the
new-dir
directory myself but i still got the same error.Steps to Reproduce
I'm not doing anything special!
deno init
main.ts
to this:await fs.ensureSymlink("./dir/test.txt", "./dir/test.link.txt");