35

taken form here - explaining how to install apt-cyg

Install apt-cyg

You may have heard of programs like apt-get (Ubuntu), yum/dnf (Fedora), pacman (Arch), or brew (Mac OS X)... .. .The analogous program for Cygwin is called apt-cyg.

Installing apt-cyg is simple. First, save this file: https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg . Then, use File Explorer to find the file in your Downloads folder and move it into C:\cygwin\bin. Then, open Cygwin and enter "chmod +x /bin/apt-cyg". This tells Cygwin that you want to be able to execute the apt-cyg command. Lastly, enter "apt-cyg mirror ftp://sourceware.org/pub/cygwin". This sets up apt-cyg to use the official repository when downloading programs.

Sounds simple enough. But i have an error.

This tutorial does not specify with what name and what extension to save that file.

I save it as apt-cyg.txt, and move it into C:\cygwin64\bin

This does not work. When running apt-cyg, I get the error: bad interpreter: No such file or directory

how to install apt-cyg for Cygwin? - error

My guess is that extension or filenames are bad. What name and extension should i use?

Are there any more steps to this process?

Note: I just installed cygwin on a windows 10. Please don't assume i have other tools already installed.

AIon
  • 12,521
  • 10
  • 47
  • 73
  • It seems you have downloaded as text file with CRLF line terminators. Try `d2u /bin/apt-cyg` or download again without extension and save as file type `All file *.*` – matzeri Jul 24 '17 at 18:45
  • "This tutorial does not specify with what name and what extension to save that file" You should save it as exactly "apt-cyg" . If you save it as "apt-cyg.txt" then when you want to run the command in cygwin, you will literally have to type "apt-cyg.txt" to run it. Are you familiar with linux command line at all? – Keith Tyler Jan 14 '22 at 03:54

7 Answers7

55

You install it like this:

1 - Make sure lynx is installed

2 - Run lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg

3 - Run install apt-cyg /bin

That's it!

Hayden
  • 551
  • 4
  • 3
  • 9
    Then how do you install lynx? If lynx can be installed using the setup manager, how come apt-cyg wasn't included in this list? – winux Aug 17 '18 at 07:39
  • @winux lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg – bpedroso Dec 03 '18 at 11:57
  • 2
    @winux start the Cygwin installer again and select lynx during the setup process. – langlauf.io Jun 14 '19 at 11:37
  • 3
    @winux or if you installed Cygwin via chocolatey, open Cygwin terminal and `/cygdrive/c/tools/cygwin/cygwinsetup.exe -q -P lynx` – langlauf.io Jun 14 '19 at 12:00
  • 4
    No need for lynx - you can simply use `curl`, which is installed by default. Replace `lynx -source` with `curl -L` to use. The rest of the command stays the same – aggregate1166877 Sep 19 '21 at 23:12
23

You can do this with just the browser.

  1. Right click on the "https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg" link
  2. Select "Save link as"
  3. Navigate to c:\cygwin\bin (or wherever your Cygwin binaries live)
  4. Remove the .txt extension so that it's just apt-cyg
  5. Click "Save"
  6. Run chmod in bash as shown
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Paul Vanderveen
  • 231
  • 2
  • 2
8

The github repo of apt-cyg asks to install apt-cyg as follows:

lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin

(This requires lynx to be already installed in your cygwin. If you have not selected lynx package during installation of cygwin, you can rerun the setup at installation-path-to-cygwin\cygwin\setup\setup-x86_64.exe and then select lynx in its installation wizard.)

However, I was getting error while running above lynx command. Seems that being behind corporate proxy is an issue. And I was unable to figure it out how to configure the proxy for lynx.

So I simply went to github to access apt-cyg script here. I downloaded the script from browser, by navigating to above link, right clicking and then save as. Note that you have to save it without extension (that is, select "All Files" in "Save as type" drop down of "Save As" window, instead of "Text Document"), because browser may by default save it as text file (txt). If you have downloaded it as txt, you may change extension. Cut paste this file to path-tocygwin\cygwin\setup\bin.

Thats it!!! Now apt-cyg must be accessible from cygwin terminal.

Note:

Dont forget to set proxt path if you are running apt-cyg install behind corporate proxy:

export http_proxy=http://username:password@proxy-server-name:proxy-server-port
export https_proxy=http://username:password@proxy-server-name:proxy-server-port

For example:

export http_proxy=http://mahesh:password%40123@proxy.mycompany.com:8080
export https_proxy=http://mahesh:password%40123@proxy.mycompany.com:8080

Note @ in password should be replaced with %40.

Then you can install packages:

apt-cyg install gcc-core
Mahesha999
  • 22,693
  • 29
  • 116
  • 189
  • there is no reason to use or not to use lynx versus any other web browser or tool. wget, curl, chrome, whatever. you're just downloading a file. – Keith Tyler Jan 14 '22 at 03:56
7

It seems like there is not problem with the extension but with the line endings in the script (see the part ^M). Similar things happen when you use git on several platforms and change unix ending lf to windows ending clrf and so.

Consider change clrf to lf (removing cr) by the command:

sed -i 's/\r//g' apt-cyg

There should be no extension in commands so do not add any extension to the apt-cyg after downloading it to /bin.

Michal
  • 71
  • 1
  • 1
2

Install Net packages with setup.exe, then use wget.exe https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg and install apt-cyg /bin as it was mentioned above.

Igor Maximov
  • 526
  • 1
  • 4
  • 11
  • If you get a problem with privileges during install command, start CygWin as Administrator – JRr Jan 31 '21 at 07:53
0

Remember that the setup-x86.exe or setup-x86_64.exe downloaded from https://www.cygwin.com/ is the official method for installing cygwin. If you install using some other method and have problems, you may get little or no official support. Just use the official gui installer to install and update packages.

Doug Henderson
  • 785
  • 8
  • 17
  • 6
    To answer your question, download the `apt-cyg` file by using a left-click save link as... with the name `apt-cyg` with no extension. You may need to supply the dot that separates the filename and extension. The file is a bash shell script. Use `head apt-cyg | cat -A`. If you see `^M`s at the end of lines, use `d2u apt-cyg` to convert line ends from `\m\n` to `\n`. Then `chmod +x apt-cyg`. Now you can execute `apt-cyg`. – Doug Henderson Jul 25 '17 at 00:19
  • 6
    Cygwin brings Linux to Windows, I just wish it would "Officially" bring the benefits of command line package management, not GUI installation only methods :( – Ben Winding Mar 13 '18 at 00:08
  • 7
    `apt-cyg` and its forks are well-maintained. Using the GUI installer takes away a benefit of using a Linux terminal emulator. I suggest using `apt-cyg`. If support is an issue (and I understand that it can be), run the `setup` from the command line as described [here](https://stackoverflow.com/a/23143997/6505499). I want to explain my down-vote. If you want support, the GUI installer in one step too many, especially considering the OP's question. P.S. [this](https://stackoverflow.com/a/16869816/6505499) is a good link with instructions for installing `apt-cyg`. Or use the answer from @Hayden – bballdave025 Jun 18 '18 at 23:45
  • 1
    I've been a happy user of apt-cyg back when I had to run MS Windows at work so I don't think this is a particularly useful answer for people who *do* want to install the script. However, I also don't think it should be down-voted as it's probably good advice for newbies who aren't familiar with Cygwin and the differences between Linux and MS Windows systems. See https://sourceware.org/ml/cygwin/2019-01/msg00084.html – Anthony Geoghegan Feb 11 '19 at 19:07
0

Note to self: I am lazy and I prefer to be able to type apt-get... Here is a copy and paste shell command to automate this.

$ wget 'https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg' -O \
       /usr/bin/apt-cyg && 
       chmod 755 /usr/bin/apt-get; \
  test -f /usr/bin/apt-get || ( 
       curl 'https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg' -o \
           /usr/bin/apt-get && 
       chmod 755 /usr/bin/apt-cyg ); \
       cd /usr/bin && ln -s apt-cyg apt-get && apt-get update
Orwellophile
  • 13,235
  • 3
  • 69
  • 45