4

For some reason tilde expansion in Cygwin is not working for me at the prompt:

$ ls ~
ls: cannot access : No such file or directory

$ ls ~/bin
(lists /bin not $HOME/bin)

$ echo $HOME
/home/myusername

$ echo ~


$

In the last case there (echo ~) there is no output (other than a couple of blank lines.)

I have set expand-tilde on set in my $HOME/.inputrc file. Is there something else I need configured?

ErikR
  • 50,049
  • 6
  • 66
  • 121

1 Answers1

5

This is a recurring problem with Cygwin that, I believe, was tied to some upgrade bug a while ago and never resolved.

In any case, the solution is simple: open /etc/passwd in your favourite editor, and on the line with your username, between the fifth and sixth colons (the last and second-to-last), write in the correct path to your home directory, ie /home/myusername.

The relevant line in my /etc/passwd looks something like the below:

meand:unused:12345:54321:PCNAME\meand,S-1-5-21-4567891230-654987321-312456978-58252:/home/meand:/bin/screen
me_and
  • 13,911
  • 6
  • 58
  • 93
  • Just installed cygwin, and the file isn't there. – nilskp Dec 13 '15 at 00:29
  • 1
    @nilskp I think Cygwin may have stopped using `/etc/passwd` now, so I'm not sure what the current solution for this problem is. Your best bet is to email the [Cygwin mailing list](https://cygwin.com/lists.html). – me_and Jan 19 '16 at 10:34
  • Windows path to the file is /cygwin64/etc/passwd (if you are editing it using windows based editor, it won't see /etc/passwd). – mosh Sep 22 '17 at 04:03