146

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.
alex
  • 6,818
  • 9
  • 52
  • 103
Hyztname
  • 1,597
  • 2
  • 10
  • 7
  • The file is available in the source repository. – Bruno Mar 28 '12 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 '13 at 03:05
  • possible duplicate of [How do I install cygwin components from the command line?](http://stackoverflow.com/questions/9260014/how-do-i-install-cygwin-components-from-the-command-line) – Zombo Feb 20 '14 at 04:47
  • 3
    **cyg-apt** has the last update 5 year ago. Current repository structure is different. Therefore it won't work. – David Ferenczy Rogožan Apr 17 '14 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). – Sridhar Sarnobat Aug 30 '17 at 20:49

7 Answers7

142

Best I have ever used:

apt-cyg package manager

user229044
  • 232,980
  • 40
  • 330
  • 338
pansophism
  • 1,452
  • 1
  • 9
  • 2
104

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
DagdA
  • 484
  • 1
  • 7
  • 25
sagunms
  • 8,030
  • 5
  • 41
  • 43
  • 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-" = "--" – Shahjahan Khan Jan 03 '14 at 11:01
  • @sagunms it worked charm! this was annoying issue until i found the solution. Thanks. – Yoon Lee Feb 12 '14 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). – David Ferenczy Rogožan Apr 17 '14 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 '15 at 08:47
  • `/usr/local/bin/apt-cyg: line 5: syntax error near unexpected token \`newline'` – JackHasaKeyboard Oct 27 '16 at 20:39
  • 1
    Works for me! a – Nick Gallimore May 22 '17 at 17:53
  • `cd C:\cygwin64` was not necessary for me since I had just downloaded the cygwin install and the setup.exe file was in my Downloads/ directory so I cd'd into my Downloads/ directory then ran the second command you gave. Just figured I'd share for documentation and to help others – Coty Embry Aug 24 '17 at 05:34
  • @ShahjahanKhan @JackHasaKeyboard and maybe others : `/cygdrive/c/cygwin64/setup-x86_64.exe dos2unix` (it might take you to the GUI setup installer. Just follow the steps.) Then `dos2unix apt-cyg` and follow the rest of the instructions. The problem is that you have Windows- or OS-like line endings, whereas Cygwin expects Linux-like endings. @DawidFerenczy described this, but I want to show a concrete example of how to implement his solution. – bballdave025 Jun 18 '18 at 23:51
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

Community
  • 1
  • 1
David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
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>
Zombo
  • 1
  • 62
  • 391
  • 407
nwgat
  • 661
  • 7
  • 11
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
Willem van Ketwich
  • 5,666
  • 7
  • 49
  • 57
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.

me_and
  • 15,158
  • 7
  • 59
  • 96
  • 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 06 '16 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
fabriciorissetto
  • 9,475
  • 5
  • 65
  • 73