For Developers‎ > ‎How-Tos‎ > ‎

Installing cygwin

For Windows developers, cygwin can optionally be used to provide a more Unix-like environment.

Installing
  1. Download http://cygwin.org/setup.exe and run it.  Use the default options.  When it comes time to pick a mirror, use http://cygwin.com/mirrors.html to find a nearby one.
  2. Once you have an opportunity to select packages, make sure to search for and add all the specific packages named in the required_packages section of http://trac.webkit.org/browser/trunk/Tools/CygwinDownloader/cygwin-downloader.py.  Note: If you will be using git, also install the ca-certificates package, or gclient won't allow you to clone the repository.  You can also add any other packages you happen to particularly want, e.g. editors or utilities.  After you move on, the installer will note that it needs to add various other prerequisites for your selected packages; let it.
  3. (Optional) Download PuTTYCyg from http://code.google.com/p/puttycyg/ to use as a better console (e.g. to gain a Unix-like "drag to select, middle click to paste" clipboard without needing to use menus).  There's no installer; just unzip the package somewhere on your drive, create a shortcut to putty.exe, and add the flags "-cygterm -" (sans quotes) to the shortcut's target line as described atop http://code.google.com/p/puttycyg/wiki/FAQ.
  4. Launch a shell to let cygwin do first-run initialization.
  5. If using Visual Studio 2010 Express: edit /etc/profile and comment out the block that sets up $TMP and $TEMP, then close and re-open your shell.  Otherwise you may get MSB6001 errors when trying to compile. If you do get these errors, and you haven't done this step, do it, and also kill any MSBuild.exe processes still alive before re-launching Visual Studio (otherwise you'll continue to see the errors).

Error messages about module base addresses

DLLs on Windows need to be loaded into memory at non-conflicting base addresses.  rebaseall is a cygwin utility that scans all the libraries currently installed and sets each to request a different base address so that none will conflict.  Normally the cygwin installer runs this every time it installs packages, so you shouldn't need to run it.  However, if you somehow install a package by some other mechanism, or something gets hosed, and you get cryptic error messages about not being able to change a module base address, here's how to do it manually:
  1. Quit all cygwin shells and ensure no other cygwin processes are still running.
  2. Open a Windows command shell (cmd) as administrator.
  3. cd \cygwin\bin, or the bin directory wherever you installed cygwin.
  4. ash /usr/bin/rebaseall
  5. If all was successful, you should see no messages printed.
Sometimes even these steps are not enough.  For example, if you have an antivirus program running, its modules can conflict with cygwin's.  If you get remapping errors and the above steps do not solve them, refer to the instructions at  http://code.google.com/p/chromium/wiki/CygwinDllRemappingFailure to find out how to manually rebase below the conflicting non-cygwin modules.

Making permissions work
  1. Cygwin will apply a too-restrictive set of permissions due to its inability to interpret Windows ACLs perfectly. Instruct Cygwin to 'play dumb' about permissions by editing /etc/fstab and adding the 'noacl' flag to the mount points. Mine looks like:
    none /cygdrive cygdrive binary,posix=0,user,noacl 0 0
    D:/cygwin / ntfs override,binary,auto,noacl 0 0
  2. The executable bit on Git repository files will get changed, and you will have permissions "changes" in your git respository immediately after checkout. Fix this by turning git's core.filemode config to false. Refer to this post: https://groups.google.com/a/chromium.org/forum/?fromgroups=#!topic/chromium-dev/0EdNev3NNsw
    1. Turn it for globally: git config --global core.filemode false
    2. Turn it off for each repo: git config core.filemode false
    3. Turn it off for all the submodules of each repo: git submodule foreach --recursive git config core.filemode false
Notes
  • You can check out the code using either the cygwin svn or the one from depot_tools, but you must be consistent.  From the very first checkout you do onward, use the same svn and never do any operations on your tree with the other one.  Otherwise things will become very confused and you may need to blow away your checkout and re-sync.  The directions on the page about installing depot_tools should ensure you always use the Cygwin svn.
  • Sometimes cygwin will spit out errors about DOS-style pathnames, e.g. during gclient runhooks (the last stage of a sync).  It's safe to ignore these.
  • When using cygwin, you need to be more careful about LF vs. CRLF line endings.  The dos2unix and unix2dos utilities will convert a file from one to the other.  If you ever see "\r" (spelled out that way) in an error message, it's a clue that the file in question is CRLF but expected to be LF.
Comments