Skip to main content
added 61 characters in body
Source Link
user14492
  • 1.1k
  • 10
  • 20

Using the following snippet it creates an invalid symlink. But according to other answers it should work fine.

# make a temp dir and save path to var.
# set dir (mktemp -d)  # fish shell only!
dir=$(mktemp -d)  # bash/zsh
cd $dir
mkdir a b
echo 'text file' > a/file.txt
ln -s a/file.txt b/
open .

When you see the symlink in Finder it doesn't recognise the file type in Quick Preview and when you open it Finder complains 'the original item cannot be found'.

If you use absolute paths everything works fine. See below:

rm b/file.txt
ln -s $dir/a/file.txt $dir/b/
open .

Then you can see symlink is correctly make and you can even read the file content in Quick Preview.

How is this happening? I've checked that ln is /bin/ln. I'm on macOS Catalina 10.15.7 (19H2).

correct symlink and quick preview

Using the following snippet it creates an invalid symlink. But according to other answers it should work fine.

set dir (mktemp -d)
cd $dir
mkdir a b
echo 'text file' > a/file.txt
ln -s a/file.txt b/
open .

When you see the symlink in Finder it doesn't recognise the file type in Quick Preview and when you open it Finder complains 'the original item cannot be found'.

If you use absolute paths everything works fine. See below:

rm b/file.txt
ln -s $dir/a/file.txt $dir/b/
open .

Then you can see symlink is correctly make and you can even read the file content in Quick Preview.

How is this happening? I've checked that ln is /bin/ln. I'm on macOS Catalina 10.15.7 (19H2).

correct symlink and quick preview

Using the following snippet it creates an invalid symlink. But according to other answers it should work fine.

# make a temp dir and save path to var.
# set dir (mktemp -d)  # fish shell only!
dir=$(mktemp -d)  # bash/zsh
cd $dir
mkdir a b
echo 'text file' > a/file.txt
ln -s a/file.txt b/
open .

When you see the symlink in Finder it doesn't recognise the file type in Quick Preview and when you open it Finder complains 'the original item cannot be found'.

If you use absolute paths everything works fine. See below:

rm b/file.txt
ln -s $dir/a/file.txt $dir/b/
open .

Then you can see symlink is correctly make and you can even read the file content in Quick Preview.

How is this happening? I've checked that ln is /bin/ln. I'm on macOS Catalina 10.15.7 (19H2).

correct symlink and quick preview

Source Link
user14492
  • 1.1k
  • 10
  • 20

macOS Cannot Create Valid Symlink From Terminal Using Relative Paths

Using the following snippet it creates an invalid symlink. But according to other answers it should work fine.

set dir (mktemp -d)
cd $dir
mkdir a b
echo 'text file' > a/file.txt
ln -s a/file.txt b/
open .

When you see the symlink in Finder it doesn't recognise the file type in Quick Preview and when you open it Finder complains 'the original item cannot be found'.

If you use absolute paths everything works fine. See below:

rm b/file.txt
ln -s $dir/a/file.txt $dir/b/
open .

Then you can see symlink is correctly make and you can even read the file content in Quick Preview.

How is this happening? I've checked that ln is /bin/ln. I'm on macOS Catalina 10.15.7 (19H2).

correct symlink and quick preview