Giter Club home page Giter Club logo

setup-cygwin's Introduction

Set up Cygwin

Test

This GitHub action sets up Cygwin in your workflow run.

  1. Installs Cygwin.
  2. Installs any additional packages specified.

Use it in your workflow like this:

- name: Set up Cygwin
  uses: egor-tensin/setup-cygwin@v4
  with:
    packages: cmake gcc-g++

# Cygwin executables are added to PATH, so you can call them directly:
- run: |
    ls.exe -Al
    pwd.exe

# Alternatively, you can set Cygwin's bash as the shell to use:
- run: |
    # This is a real bash script!
    basic() {
        ls -Al
        pwd
    }
    basic
  shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
  • Specify any additional packages to be installed as a space-separated list in the packages parameter.
  • Set the installation directory using the install-dir parameter (C:\tools\cygwin is the default).
  • The CYGWIN environment variable is set to an empty string by default. Provide a custom value using the env parameter.

API

Input Value Default Description
install-dir empty Install to C:\tools\cygwin.
any Install to the specified directory.
packages empty Don't install any additional packages.
any Space-separated package names.
env empty Set %CYGWIN% to an empty string.
any Set %CYGWIN% to the specified value.
hardlinks any Don't convert any symlinks.
1 Convert symlinks in /usr/bin to hardlinks.

The paths to the Cygwin binaries are added to the PATH variable.

Line terminators

When using Cygwin's bash as the shell to run the step script (or if you see something like \r': command not found in logs), make sure that igncr is present in the SHELLOPTS variable be either:

  • passing -o igncr to bash.exe,

    job:
      name: Test job
      runs-on: windows-latest
      defaults:
        run:
          shell: C:\tools\cygwin\bin\bash.exe --login -o igncr '{0}'
      steps:
        - ...
    
  • or setting the SHELLOPTS variable in the env: block.

    job:
      name: Test job
      runs-on: windows-latest
      env:
        SHELLOPTS: igncr
      defaults:
        run:
          shell: C:\tools\cygwin\bin\bash.exe --login '{0}'
      steps:
        - ...
    

Please avoid using \r\n as line separators in your shell scripts, as Linux shells will choke on them.

Executable symlinks

Some packages install symlinks in /usr/bin along with real executables. An example is package "gcc-core", which (as of November 2021) installs symlink cc, pointing to the real executable gcc.exe. Calling Cygwin symlinks from Windows' command prompt is unsupported, but might be convenient so there's an option to convert them to hardlinks instead (the hardlinks parameter).

License

Distributed under the MIT License. See LICENSE.txt for details.

setup-cygwin's People

Contributors

egor-tensin avatar me-and avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

davinash affggh sazl

setup-cygwin's Issues

Suggested bash default option changes working directory to $HOME

Had to remove the --login option, otherwise the working directory is changed, even w/ --norc specified:

Run cmake -GNinja \
  cmake -GNinja \
    -S . -B build
  cmake --build build
  shell: C:\tools\cygwin\bin\bash.exe --login --norc -o igncr '{0}'
  env:
    CYGWIN: 
Copying skeleton files.
These files are for the users to personalise their cygwin experience.

They will never be overwritten nor automatically updated.

'./.bashrc' -> '/home/runneradmin//.bashrc'
'./.bash_profile' -> '/home/runneradmin//.bash_profile'
'./.inputrc' -> '/home/runneradmin//.inputrc'
'./.profile' -> '/home/runneradmin//.profile'
CMake Error: The source directory "/home/runneradmin" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
Error: /home/runneradmin/build is not a directory
Error: Process completed with exit code 1.

Recent errors with chocolatey 1.2.0

Hi!

I am using this Github action for the Exiv2 project. Few days ago I noticed that the Cygwin builds started to fail, and when I compare the failing jobs:
https://github.com/Exiv2/exiv2/actions/runs/3365823530/jobs/5585304895
With the non failing ones from 1 week ago:
https://github.com/Exiv2/exiv2/actions/runs/3332745648/jobs/5513973618

The only different that I see is that apparently chocolatey got upgraded from version 1.1.0 to 1.2.0. The error is not very informative and just says this:

Chocolatey installed 0/0 packages. 
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
The system cannot find the file specified
Error: Process completed with exit code 1.

The pipeline can be found here: https://github.com/Exiv2/exiv2/blob/dc5dc0d2e39aba87e38cda8378ffd90b833877a6/.github/workflows/on_PR_windows_matrix.yml#L165

Do you know what could be happening? Or any other feedback that could help me to fix this situation?

Thanks in advance for your time and for this nice github action :)

Can't run most basic commands due to CRLF: ls\r not found

Proof of concept:


on:
  push:
    branches: [ develop,cygwin ]
  pull_request:
    branches: [ develop ]
  workflow_dispatch:

jobs:


  win-build-upstream-mono:
    runs-on: windows-2019
    steps:
      - uses: actions/checkout@v2
      - name: Set up Cygwin
        uses: egor-tensin/setup-cygwin@v3
        with:
          platform: x64
          packages: git unzip
      - name: check env
        shell: bash
        run: |
          ls
          pwd
          ls -a

   

I have such error:


Run ls
  ls
  pwd
  ls -a
  shell: C:\tools\cygwin\bin\bash.EXE --noprofile  -e -o pipefail {0}
  env:
    CYGWIN: 
D:\a\_temp\a2ea1fad-fdcb-46f8-8a2c-62d654473fda: line 1: $'ls\r': command not found
Error: Process completed with exit code 127.

Feature request: Add cache

If we cache cygwin packages, we can speed up CI process and save bandwidth for kernel.org
I tried https://github.com/Endle/wine-mono/blob/940e19c2abbc576f597e924270812721638b8eb1/.github/workflows/c-cpp.yml#L13 but t didn't work

      - name: Get Date
        id: get-date
        run: |
          echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
          echo "::set-output name=time::$(/bin/date -u "+%H%M%S")"
        shell: bash
      - name: Cache Cygwin
        uses: actions/cache@v2
        env:
          cache-name: cache-cygwin-packages
        with:
          path: /cygdrive/c/tools/cygwin/packages
          key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.get-date.outputs.date }}-${{ steps.get-date.outputs.time }}
          restore-keys: |
            ${{ runner.os }}-${{ env.cache-name }}-${{ steps.get-date.outputs.date }}-
            ${{ runner.os }}-${{ env.cache-name }}-

Non-default symlink behaviour

Hi,

I'm the Cygwin maintainer for Git, and I'm trying to set up GitHub Actions to do CI-style builds, rather than my current manual build process, and for that I've been playing with this action. Unfortunately, this action currently causes the cygport unpack build stage to fail for the Git project, because it sets CYGWIN=winsymlinks:nativestrict. See https://github.com/me-and/Cygwin-Git/runs/1601065913 for an example of the failure.

I've been experimenting over at me-and/setup-cygwin@7119423 and confirmed that removing that symlinking behaviour gets the builds working as expected for my use case.

I can see three obvious-to-me approaches, all of which I'm happy with, but I'd like to know what you'd prefer before I submit a PR:

  1. Add a new "CYGWINENV" input that defaults to an empty string, and sets the CYGWIN environment variable to whatever it's configured with. This would not be back-compatible, but seems most likely to cause minimal surprise to people who are expecting Cygwin's default behaviour except when they've deliberately asked for something else.

  2. Add a new "CYGWINENV" input that defaults to winsymlinks:nativestrict but otherwise works as per the previous point. In my opinion this would violate the principle of least surprise, but would not require a backwards-incompatible change.

  3. Don't make any changes, in which case I'll maintain my fork, probably taking option 1 above.

If you let me know which you prefer, I'll submit a PR with the relevant changes :)

Warning: Unable to resolve dependency 'chocolatey'

When using the action today, the output is:

[NuGet] One or more unresolved package dependency constraints detected in the Chocolatey lib folder. All dependency constraints must be resolved to add or update packages. If these packages are being updated this message may be ignored, if not the following error(s) may be blocking the current package operation: 'apache-httpd 2.4.55 constraint: chocolatey (>= 1.2.0)', 'cmake.install 3.27.4 constraint: chocolatey (>= 0.10.5)', 'php 8.2.10 constraint: chocolatey (>= 0.10.0)'
Unable to resolve dependency 'chocolatey': Unable to resolve dependencies. 'chocolatey 1.1.0' is not compatible with 'apache-httpd 2.4.55 constraint: chocolatey (>= 1.2.0)'.

Does it really try to install chocolatey itself?

cygwin for building python extension

I would like to build a Python/C extension module for windows using cygwin and Gitbub actions.
Additionally to python3 there are only two things I need, gnu make and gcc.

As an initial step I created a minimal workflow. That fails miserably, after countless iterations.

Could you please help me with this problem, thanks.

Chocolatey had an error on fv-az1565-626 (with user runneradmin):

thanks

Set up Cygwin

Chocolatey v2.2.2
Installing the following packages:
chocolatey
By installing, you accept licenses for the packages.
Invalid credentials specified.
Please provide credentials for: https://community.chocolatey.org/api/v2/
User name: Password: Chocolatey had an error on fv-az1565-626 (with user runneradmin):
System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
   at System.Console.ReadKey(Boolean intercept)
   at chocolatey.infrastructure.commandline.ReadKeyTimeout.ConsoleReadKey()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
   at System.Console.ReadKey(Boolean intercept)
   at chocolatey.infrastructure.commandline.ReadKeyTimeout.ConsoleReadKey()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Chocolatey v2.2.2
Upgrading the following packages:
cygwin
By upgrading, you accept licenses for the packages.
cygwin is not installed. Installing...
Invalid credentials specified.
Please provide credentials for: https://community.chocolatey.org/api/v2/
User name: Password: Chocolatey had an error on fv-az1565-626 (with user runneradmin):
System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
   at System.Console.ReadKey(Boolean intercept)
   at chocolatey.infrastructure.commandline.ReadKeyTimeout.ConsoleReadKey()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
   at System.Console.ReadKey(Boolean intercept)
   at chocolatey.infrastructure.commandline.ReadKeyTimeout.ConsoleReadKey()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Chocolatey v2.2.2
Installing the following packages:
make;gcc-g++;zlib-devel
By installing, you accept licenses for the packages.
Invalid credentials specified.
Invalid credentials specified.
Invalid credentials specified.
Unable to connect to source 'https://community.chocolatey.org/api/v2/':
 Failed to fetch results from V2 feed at 'https://community.chocolatey.org/api/v2/Packages()?$filter=tolower(Id)%20eq%20'cygwin'&semVerLevel=2.0.0' with following message : Response status code does not indicate success: 403 (Forbidden).
cygwin not installed. The package was not found with the source(s) listed.
 Source(s): 'https://community.chocolatey.org/api/v2/'
 NOTE: When you specify explicit sources, it overrides default sources.
If the package version is a prerelease and you didn't specify `--pre`,
 the package may not be found.
Please see https://docs.chocolatey.org/en-us/troubleshooting for more
 assistance.
Chocolatey installed 0/0 packages. 
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
The system cannot find the file specified
Error: Process completed with exit code 1.

zlib-devel and perl-YAML-Tiny Cygwin packages fail to install

I suspect this is a bug with Chocolatey, but I'm not managing to work out what's going on well enough, or to reproduce the problem without using this GitHub Action, so I'm reporting this here in the hope we can work out what's going on.

Clearest example of the problem is at https://github.com/me-and/Cygwin-Git/actions/runs/441220070: I've used the action in this repository to install zlib-devel in the "Install Cygwin" job. However if you look at the cygcheck.out file, which is generated in the "Generate cygcheck output" job and stored as an artefact in "cyg-install-logs", you can see the package isn't listed in the set of installed packages.

Looking through the installation logs, everything seems to be reporting itself as successful, and in particular the logs from Chocolatey seem to show it attempting to install the zlib-devel package, running the Cygwin installer, which doesn't seem to meaningfully do anything, and reports success.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.