What causes ln: //: Is a directory?

14,746

In pathname resolution, having a trailing / is equivalent to a trailing /. — in other words, ~/inbox/ is equivalent to ~/inbox/. in this context. So the ln command is trying to create a link called . in the root directory (and, unsurprisingly, failing).

Zsh removes the trailing / when you press Space after completing a directory (unless configured not to do so). I don't know if bash can be made to do this.

Share:
14,746

Related videos on Youtube

iamgato
Author by

iamgato

Updated on September 18, 2022

Comments

  • iamgato
    iamgato almost 2 years

    When linking a directory to root, I get this error:

    $ ln -s ~/inbox/ /
    $ ln: //: Is a directory
    

    Bash autocompletes the directory path by adding a /. I've tried escaping without success.

    $ ln -s ~/inbox /
    

    works though. Why is this?

    • jsbillings
      jsbillings about 12 years
      What OS is this? Is it GNU Coreutils, or the BSD utils?
    • Mikel
      Mikel about 12 years
      I don't think it's coreutils. My version puts the file name in quotes, e.g. ln: 'foo': hard link not allowed for directory.
  • jippie
    jippie about 12 years
    I think it is good to explain what cd $(mktemp -d) does. Not everybody is familiar with this construction.
  • Mikel
    Mikel about 12 years
    It creates a new directory somewhere under /tmp. It makes sure that the files I'm using in my examples don't already exist so that everyone can get try running the commands and get the same results.
  • Mikel
    Mikel about 12 years
    Very interesting. Pathname resolution also says that symlinks should be resolved. But when you do ln symlink blah, blah should point to symlink, not what symlink points at.