148

Is there any apt-get-like program for use with Cygwin?

I already tried cyg-apt but when I try I get this error:

cyg-apt: downloading: http://cygwin.mirrors.pair.com/setup-2.bz2
cyg-apt: downloading: http://cygwin.mirrors.pair.com/setup-2.ini
cyg-apt: bad URL http://cygwin.mirrors.pair.com/setup-2.ini, exiting.
5
  • The file is available in the source repository.
    – Bruno
    Mar 28, 2012 at 19:11
  • Is it possible to download from a different repo than cygwin? Actually, I need some linux-headers for a computer offline with linux but I need to download them on windows with an apt-get.
    – Alex
    Dec 21, 2013 at 3:05
  • possible duplicate of How do I install cygwin components from the command line?
    – Zombo
    Feb 20, 2014 at 4:47
  • 3
    cyg-apt has the last update 5 year ago. Current repository structure is different. Therefore it won't work. Apr 17, 2014 at 21:44
  • 3
    don't confuse cyg-apt with apt-cyg. The latter is much better (just remember the one that sounds most similar to apt-get is the good one). Aug 30, 2017 at 20:49

7 Answers 7

143

Best I have ever used:

apt-cyg package manager

5
  • 1
    apt-cyg orks really well. Just installed rsync, openssh, mc and others.
    – Jako
    Feb 14, 2013 at 0:51
  • 9
    It can only install and remove packages, can't it? It's not possible to upgrade particular package or all packages to the newest version with apt-cyg. So it's nice, but useless since I have to use Cygwin's setup too. I would be pleased if I'm wrong. Apr 17, 2014 at 18:44
  • 1
    apt-cyg update will update setup.ini etc, if anyone has issues without of date setup.ini
    – nwgat
    Aug 4, 2015 at 5:08
  • Are there any mirrors?
    – Danny Lo
    Feb 23, 2016 at 10:09
  • 2
    @CodeMonkey The repo is back up, along with it's competitor: Sage Apr 8, 2016 at 4:13
106

You can do this using Cygwin’s setup.exe from Windows command line. Example:

cd C:\cygwin64
setup-x86_64 -q -P wget,tar,gawk,bzip2,subversion,vim

For a more convenient installer, you may want to use the apt-cyg package manager. Its syntax is similar to apt-get, which is a plus. For this, follow the above steps and then use Cygwin Bash for the following steps:

wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin

Now that apt-cyg is installed. Here are a few examples of installing some packages:

apt-cyg install nano
apt-cyg install git
apt-cyg install ca-certificates
8
  • after doing above step apt-cyg for 64 bits gives exception /usr/local/bin/apt-cyg: line 1: $'\r': command not found /usr/local/bin/apt-cyg: line 3: $'\r': command not found /usr/local/bin/apt-cyg: line 19: $'\r': command not found /usr/local/bin/apt-cyg: line 21: $'\r': command not found /usr/local/bin/apt-cyg: line 27: syntax error near unexpected token ||' 'usr/local/bin/apt-cyg: line 27: || test "-$GAWK-" = "--" Jan 3, 2014 at 11:01
  • @sagunms it worked charm! this was annoying issue until i found the solution. Thanks.
    – Yoon Lee
    Feb 12, 2014 at 11:07
  • @Shahjahan Khan: It seems, that you broke line endings with some Windows text editor. Use Linux line endings (\n or LF or 0x0A), not Windows (\r\n or 0x0D 0x0A or CR LF). Apr 17, 2014 at 19:46
  • hey.. how would i install gcc using that tool suppose i forgot to install the Devel packages while installing cygwin
    – Zuko
    Jan 11, 2015 at 8:47
  • 1
    Works for me! a May 22, 2017 at 17:53
28

Update: you can read the more complex answer, which contains more methods and information.

There exists a couple of scripts, which can be used as simple package managers. But as far as I know, none of them allows you to upgrade packages, because it’s not an easy task on Windows since there is not possible to overwrite files in use. So you have to close all Cygwin instances first and then you can use Cygwin’s native setup.exe (which itself does the upgrade via “replace after reboot” method, when files are in use).


apt-cyg

The best one for me. Simply because it’s one of the most recent. It works correctly for both platforms - x86 and x86_64. There exists a lot of forks with some additional features. For example the kou1okada fork is one of improved versions.


Cygwin’s setup.exe

It has also command line mode. Moreover it allows you to upgrade all installed packages at once.

setup.exe-x86_64.exe -q --packages=bash,vim

Example use:

setup.exe-x86_64.exe -q --packages="bash,vim"

You can create an alias for easier use, for example:

alias cyg-get="/cygdrive/d/path/to/cygwin/setup-x86_64.exe -q -P"

Then you can for example install the Vim package with:

cyg-get vim

19

you can always make a bash alias to setup*.exe files in $home/.bashrc

cygwin 32bit

alias cyg-get="/cygdrive/c/cygwin/setup-x86.exe -q -P"

cygwin 64bit

alias cyg-get="/cygdrive/c/cygwin64/setup-x86_64.exe -q -P"

now you can install packages with

cyg-get <package>
7

This got it working for me:

curl https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg > \
apt-cyg && install apt-cyg /bin
2
  • 1
    wget https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg && install apt-cyg /bin is another option if curl is missing
    – Alex Telon
    Nov 21, 2017 at 11:24
  • 1
    Also remember rm apt-cyg afterwards.
    – Alex Telon
    Nov 21, 2017 at 11:31
6

No. The only officially supported tool for downloading and updating Cygwin packages is the setup.exe file you used for the initial install, although that can be invoked with command line arguments to help the process.

From that same page:

The basic reason for not having a more full-featured package manager is that such a program would need full access to all of Cygwin's POSIX functionality. That is, however, difficult to provide in a Cygwin-free environment, such as exists on first installation. Additionally, Windows does not easily allow overwriting of in-use executables so installing a new version of the Cygwin DLL while a package manager is using the DLL is problematic.

1
  • 1
    Those were some good details on why this is not generally possible. Should be included in the cyg-get or apt-cyg docs.
    – oligofren
    Jun 6, 2016 at 11:30
-1

You can use Chocolatey to install cyg-get and then install your packages with it.

For example:

choco install cyg-get

Then:

cyg-get install my-package
3
  • 1
    Unfortunately this downloads Cygwin setup setup-x86_64.exe and installs Cygwin again, not just apt-cyg. I had to cancel the installation.
    – Metafaniel
    Aug 1, 2016 at 22:57
  • I think this didn't happen to me :/ Aug 2, 2016 at 16:41
  • Works well here. Easy to remember and searchable on chocolatey.
    – amynbe
    Jun 21, 2021 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.