Question

I remember that when I first installed cygwin I could open files form my home directory using Windows applications. For example, I had Emacs installed in Windows and I could just do runemacs ~/some_file.txt. I had run out of space and had to move my cygwin installation to a different drive. Ever since then, I seem to have mucked up my installation and I can't use Windows applications like this anymore.

I have removed cygwin completely and re-installed it in C:\cygwin as before, but the problem remains.

I see that for some reason ~ gets expanded to C:\home\Tudor instead of C:\cygwin\home\Tudor.

Does anyone know how I could get this to work again?

Was it helpful?

Solution

Non-Cygwin Windows applications are not aware of your Cygwin root or home directory.

Emacs is a special case. It was originally developed on UNIX, and it uses UNIX-like syntax for some things.

According to your latest comment, Emacs expands ~ to C:\Users\Tudor. That's your Windows home directory, not your Cygwin home directory.

You can also install a Cygwin version of Emacs, which, like any Cygwin application, will expand ~ to your Cygwin home directory.

If you invoke a Windows application from a Cygwin shell, then the shell, not the Windows application, will expand ~ to your Cygwin home directory, expressed in Cgywin syntax. For example, assuming runemacs is a non-Cygwin application, if I run:

bash$ runemacs ~

then the shell expands the ~, so it's equivalent to (assuming my user name is Tudor):

bash$ runemacs /home/Tudor

runemacs will probably treat /home/Tudor as equivalent to \home\Tudor, which would be equivalent to C:\home\Tudor if the current drive is C:.

If you type Ctrl-X Ctrl-F from within Emacs to open a file, then Emacs will interpret ~ according to whatever rules it follows internally; those rules aren't likely to recognize Cygwin unless you're running a Cygwin version of Emacs or Emacs itself has some special-case code to handle Cygwin paths.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top