I just installed Cygwin and I'm a bit confused about how it works. I see I have a "home" folder in C:\cygwin\home. I've already installed and set up Mercurial, Vim, Git, etc. on my Windows machine using their respective installers. How do I let Cygwin use those programs, and also their config files (_vimrc, etc.) ?

  • Good question, I was looking to compare mingw64-gcc package with the native windows installed version.
    – jiggunjer
    Dec 1, 2015 at 4:11

3 Answers 3


Cygwin is intended primarily to provide a Linux-like environment on top of Windows. It works best with programs that are compiled for Cygwin. It can work directly with native Windows programs, but you have to be careful.

One feature of Cygwin is that it tries to make the Windows file system look like a typical Linux file system, e.g., programs are under /usr/bin. Cygwin programs don't refer to the C: drive, they refer to /cygdrive/c. (Some Cygwin programs understand "C:" but those are the exception.) While your home directory appears under C:\cygwin\home from Windows, it appears under /home from Cygwin. That means that passing full path names between Cygwin programs and Windows programs can be tricky: Windows programs don't understand Cygwin full path names and Cygwin programs generally don't understand Windows full path names. There's a Cygwin utility, cygpath, that can translate between Windows and Cygwin paths, but you do have to insert that level of translation yourself as necessary.

I don't know of a general solution to the problem of interfacing Cygwin programs with Windows programs. The best solution depends on what you're trying to do, on how much you want to live in the Linux world vs. living in the Windows world, and on the programs you need to use.

If you're planning to use Mercurial, Vim, Git, etc. from the Cygwin command line, I would recommend installing the Cygwin versions of those programs. You can have both Windows and Cygwin versions on your system, but you have to be careful with your PATH.

I tried configuring Windows gvim to use the Cygwin shell and finally gave up. I now use Windows gvim when opening files from the GUI and Cygwin vim when opening files from the command line. There are just too many places within Windows Vim where conventions of the Windows OS API have to be matched to the Cygwin conventions of external programs. That said, using the same user configuration files for both is easy. In a Cygwin bash shell:

ln -s /cygdrive/c/Documents\ and\ Settings/username/_vimrc ~/.vimrc
ln -s /cygdrive/c/Documents\ and\ Settings/username/vimfiles ~/.vim

You just have to make sure that all those files have Unix line endings and use d2u on those that don't. Cygwin's Vim (any Unix Vim) expects Unix line endings; Windows Vim accepts either Unix or DOS line endings.

I have used Cygwin quite a bit, but I'm not an expert. The above just reflects my experiences.

  • So if I already have mingw-gcc installed in windows, I don't actually need the cygwin version of it too? using make in cygwin should use my windows g++ binary...
    – jiggunjer
    Dec 1, 2015 at 4:13

Most problems will be solved by making sure those programs are in your PATH environment variable for the Operating System.

Depending on what version of Windows you have, that is:

  1. click start
  2. right-click Computer or My Computer (or go to System settings through Control Panel)
  3. click the "Advanced" tab, or "Advanced system settings"
  4. click "Environment Variables"
  5. scroll to PATH
  6. add the path of the folder containing any programs you want (for instance add C:\vim72; to the beginning of your PATH variable, now if you type "vim" in cygwin, vim should execute (p.s. the semicolon is important))
  • Thanks. I just tried hg, git and gvim and they seem to work (they were already in my PATH). But vim gives me an error "/cygdrive/c/msysgit/msysgit/bin/vim: line 2: $'\r': command not found /cygdrive/c/msysgit/msysgit/bin/vim: line 3: /share/vim/vim73/vim: No such file or directory" Why is it looking in /cygdrive/c/msysgit?
    – john2x
    May 17, 2011 at 21:31
  • You probably need to go to that directory (/share/vim/vim73/vim) and make sure there is a vim.exe IN it. If not, you've got to add the directory that actually holds vim.exe. In other words, if vim.exe is at C:\vim\vim27\vim.exe, adding c:\vim\ to PATH will not necessarily work. Make sure to do C:\vim\vim27. May 17, 2011 at 21:36
  • But gvim works fine and they are in the same directory.
    – john2x
    May 18, 2011 at 6:30
  • That is extremely odd... :-/ I'll look around May 18, 2011 at 14:41
  • In answer to your in-comment question, /cygdrive/c/ is the path to C:\ from cygwin and msysgit I believe is some internal cygwin thing. That does not seem to be the problem because it can get to the next reference to /share/vim/vim73/vim. That might not be a valid path. Also it seems \r is an invalid command. Did you pass \r when you ran a command? May 18, 2011 at 14:52

I wrote a script to help fix some of the annoying issues with windows and cygwin (paths) interaction.

makewin() {    
eval "function $1 {
  # Don't taint locals
  local FN
  declare -a FN
  local x
  # For each option
  for x in \"\${@}\"
     # Fix the path to "windows"
     FN[\"\${#FN[*]}\"]=\`cygpath -w \"\$x\"|sed 's/ /\\\\ /g'\`

  # Run the Command
  \"$2\" \"\${FN[@]}\" >/dev/null 2>/dev/null &

Then I run it for each command I want to fix

makewin vi /cygdrive/c/Program\ Files\ \(x86\)/Vim/vim74/gvim.exe
makewin np /cygdrive/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe

It creates a function alias to the command I want that fixes the parameter path issues. This is added to my ~/.bash_profile

You must log in to answer this question.

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