0

I'm working in a monorepo and I want the example for my packages to be separated from the packages in a structure as follows:

my_packages_collection/
  examples/
    foo/
     ...
  packages/
    foo/
      example
      ...

If I cd in my_packages_collection and run ln -s examples/foo packages/foo/example I get in packages/foo a file named example and not a folder.

If I run cd packages/foo/example I get: cd: no such file or directory: packages/foo/example and vscode shows instead:

Unable to read file '[...]/foo/example' (Unknown (FileSystemError): An unknown error occurred. Please consult the log for more details.)

ls -l works as intended.

"pushed" it for science and on github and shows a "linked folder" icon that contains a file with text "examples/foo" (LOL)

What am I missing?

1 Answer 1

3

One way is to chdir into packages/foo and make the symbolic link from there:

$ mkdir my_packages_collection && cd my_packages_collection
$ mkdir -p examples/foo packages/foo
$ touch examples/foo/bar
$ cd packages/foo && ln -s ../../examples/foo example
$ ls example
bar

Another way is to make the link without the chdir. This will be more difficult to tab complete on in the shell.

$ cd -
$ cd ..
$ rm -rf my_packages_collection
$ mkdir my_packages_collection && cd my_packages_collection
$ mkdir -p examples/foo packages/foo
$ touch examples/foo/bar
$ ln -s ../../examples/foo packages/foo/example
$ ls packages/foo/example
bar

The result of either of these methods is a symbolic link file that contains the string ../../examples/foo in it.

$ readlink packages/foo/example
../../examples/foo
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .