Cygwin Portable – (some) Linux power on a USB for Windows
The Cygwin tools are ports of the popular GNU development tools for Microsoft Windows. They run thanks to the Cygwin library which provides the POSIX system calls and environment these programs expect.
With these tools installed, it is possible to write Windows console or GUI applications that make use of significant parts of the POSIX API. As a result, it is possible to easily port many Unix programs without the need for extensive changes to the source code. This includes configuring and building most of the available GNU software (including the packages included with the Cygwin development tools themselves) as well as lots of BSD tools and packages (including OpenSSH). Even if the development tools are of little to no use to you, you may have interest in the many standard POSIX utilities provided with the package. They can be used from one of the provided Unix shells like bash, tcsh or zsh, as well as from the standard Windows command shell if you have to for some sad reason.
From Cygwin FAQ
If you google Cygwin Portable you will find several solutions:
- Cygwin on portable storage devices (Devin Sezer)
- Cygwin Portable Project
- A Guide to Building a Portable Cygwin « fuzzix
The one that actually worked for me came from the SourceForge project called CygwinPortable. This version is designed to work with the software bundle PortableApps, but you could use it yourself outside the bundle (see bellow).
To install this software under the bundle just extract the zip file into your PortableAps folder, and on the gui launcher click on Options->Refresh App Icons. You will see two icons appear : one launches cygwin the other launches the setup.
I had some issues getting it to work as i wanted:
it seems the project mantainer packaged the software with svn files, you will need to remove all .svn folders from the exploded contents. I used SVN Cleaner for that.
The project seems to be unmaintained for some time now. Since that time a new version of cygwin came out which changed how setup.exe and setup.ini work. If you want to update or install new Cygwin packages you will need to download setup.exe from the cygwin page (see bellow for links) and replace the file cygwinsetup.exe in CygwinPortable\App\Cygwin\setup\ with the download one, i would advise you to replace it with a renamed version of the one download if you are using Portable Apps since the portable Apps link runs the original exe file. After doing this you can update and install new cygwin software without a hinch.
Cygwin is locked to the drive you updated it on
After i updated some packages on my cygwin my shell window changed into a normal cmd dos windows, which besides being ugly had the huge disadvantage of not allowing me to copy and paste with a single click. I set out to find a solution and it came in the form of rxvt. %Explain rxvt%. The problem was in my cygwin.bat file.
If you go into CygwinPortable\App\Cygwin you will find a file named cygwin.bat. This batch file is responsible for starting up cygwin. For some reason this file will be changed when you update your cygwin version and (after the setup) it will look something like bellow:
@echo off F: chdir F:\Software\Bin\PortableApps\CygwinPortable\App\Cygwin\bin bash --login -i
the above just runs bash.exe from your cygwin bin dir. And worse it just locked your instalation of cygwin back to the current computer (see the two lines bellow @echo off).
In order to solve this all you have to do is open the cygwin portable zip file you downloaded and replace your cygwin.bat with the one provided in there. This will be able to determine the folder you are running CygwinPortable.exe from and open up your rxvt window.
For those of you wanting to use cygwin outside the PortableApps bundle all the above steps apply, but unfortunally there is some other work you need to do:
- All you need to work with cygwin is the folder “CygwinPortable\App\Cygwin” so pull that out
- To run cygwin you will need to execute the cygwin.bat file inside that folder. But this file is configured to be run by the CygwinPortable.exe file and not on its own. So to get it to run on is own you will need to change the first line of the script to
for /F %%A in ('cd') do set WD=%%A
Notice i only removed the last part of the line which was telling the batch file where the cygwin base folder was. Since with Portable Apps we run CygwinPortable.exe the base folder would be the file execution folder (\CygwinPortable\) plus “App\Cygwin”. But when running the batch file directly the base folder becomes the batch file execution folder. Ok this part was confusing, if you have any doubts let me know and i’ll revise this part
Enjoy your new powers.