cygwin / cygwin-install-action

GitHub action to install Cygwin
GNU General Public License v3.0
22 stars 11 forks source link

Environment variable contains `NUL` #15

Open ms609 opened 4 months ago

ms609 commented 4 months ago

I'm running cygwin/cygwin-install-action@v4 from a Windows runner, using act pull_request -j build-windows -P windows-latest=-self-hosted -s GITHUB_TOKEN="<...>"

Here's the top of my action.yml script:

name: Build and test

on:
  push:
    branches:
      - "*"
  pull_request:
    branches:
    - "*"

env:
  SHELLOPTS: igncr

jobs:
  build-windows:
    runs-on: windows-latest
    steps:
    - name: Use safe line endings
      run: git config --global core.autocrlf input
      shell: cmd

    - uses: actions/checkout@v4

    - name: Set up Cygwin
      uses: cygwin/cygwin-install-action@v4
      with:
        platform: x86_64
        packages: cmake 

I see:

❌ Failure - Main # run login shell to copy skeleton profile files C:\cygwin\bin\bash.exe --login exec: environment variable contains NUL

Do you have any advice?

Full output

[Build and test/build-windows] ⭐ Run Main Set up Cygwin
[Build and test/build-windows] ⭐ Run Main $platform = 'x86_64'
$platform = $platform -replace '^(x64|amd64)$', 'x86_64'
$platform = $platform -replace '^i686$', 'x86'
# validate that platform is one of the expected values
if (($platform -ne 'x86') -and ($platform -ne 'x86_64')) {
  echo "unknown platform $platform"
  exit 1
}
Invoke-WebRequest https://cygwin.com/setup-$platform.exe -OutFile C:\setup.exe

$packages = 'cmake'
$pkg_list = $packages.Split('', [System.StringSplitOptions]::RemoveEmptyEntries)
$pkg_list = $pkg_list | % { $_.Trim() }
$pkg_list = $pkg_list | % { $_.Trim(',') }

$args = @(
 '-qgnO',
 '-l', 'C:\cygwin-packages',
 '-R', 'C:\cygwin'
)

# default site if not specified
if ( '' ) {
  $sites = ''
} elseif ($platform -eq 'x86') {
  $sites = 'http://mirrors.kernel.org/sourceware/cygwin-archive/20221123'
} else {
  $sites = 'http://mirrors.kernel.org/sourceware/cygwin/'
}
$site_list = $sites.Split('', [System.StringSplitOptions]::RemoveEmptyEntries)
$site_list = $site_list | % { $_.Trim() }
foreach ($site in $site_list) {
  $args += '-s'
  $args += $site
}

if ($pkg_list.Count -gt 0) {
  $args += '-P'
  $args += $pkg_list -Join(',')
}

if ('true' -eq $false) {
  $args += '-X'
}

if ( '' ) {
  $pubkeys = ''
  $pubkey_list = $pubkeys.Split('', [System.StringSplitOptions]::RemoveEmptyEntries)
  $pubkey_list = $pubkey_list | % { $_.Trim() }
  foreach ($pubkey in $pubkey_list) {
    $args += '-K'
    $args += $pubkey
  }
}

if ($platform -eq 'x86') {
  $args += '--allow-unsupported-windows'
}

# because setup is a Windows GUI app, make it part of a pipeline to make
# PowerShell wait for it to exit
& C:\setup.exe $args | Out-Default
| Starting cygwin install, version 2.932
| User has backup/restore rights
| User has symlink creation right
| Current Directory: C:\cygwin-packages
| root: C:\cygwin system
| Changing gid to Administrators
| Selected local directory: C:\cygwin-packages
| net: Preconfig
| site: http://mirrors.kernel.org/sourceware/cygwin/
| solving: 1 tasks, update: yes, use test packages: no
| solving: 0 tasks, update: no, use test packages: no
| Augmented Transaction List: is empty
| Registry value set: HKEY_LOCAL_MACHINE\Software\Cygwin\setup\rootdir = "C:\cygwin"
| running: C:\cygwin\bin\dash.exe "/etc/postinstall/0p_000_autorebase.dash"
| running: C:\cygwin\bin\dash.exe "/etc/postinstall/0p_update-info-dir.dash"
| running: C:\cygwin\bin\bash.exe --norc --noprofile "/etc/postinstall/zp_adwaita-icon-theme.sh"
| running: C:\cygwin\bin\bash.exe --norc --noprofile "/etc/postinstall/zp_desktop-file-utils.sh"
| running: C:\cygwin\bin\bash.exe --norc --noprofile "/etc/postinstall/zp_fontconfig_cache_1.sh"
| running: C:\cygwin\bin\dash.exe "/etc/postinstall/zp_fontconfig_dtd.dash"
| running: C:\cygwin\bin\bash.exe --norc --noprofile "/etc/postinstall/zp_glib2.0.sh"
| running: C:\cygwin\bin\bash.exe --norc --noprofile "/etc/postinstall/zp_hicolor-icon-theme.sh"
| running: C:\cygwin\bin\dash.exe "/etc/postinstall/zp_man-db-update-index.dash"
| running: C:\cygwin\bin\bash.exe --norc --noprofile "/etc/postinstall/zp_shared-mime-info.sh"
| Ending cygwin install
[Build and test/build-windows]   ✅  Success - Main $platform = 'x86_64'
$platform = $platform -replace '^(x64|amd64)$', 'x86_64'
$platform = $platform -replace '^i686$', 'x86'
# validate that platform is one of the expected values
if (($platform -ne 'x86') -and ($platform -ne 'x86_64')) {
  echo "unknown platform $platform"
  exit 1
}
Invoke-WebRequest https://cygwin.com/setup-$platform.exe -OutFile C:\setup.exe

$packages = 'cmake'
$pkg_list = $packages.Split('', [System.StringSplitOptions]::RemoveEmptyEntries)
$pkg_list = $pkg_list | % { $_.Trim() }
$pkg_list = $pkg_list | % { $_.Trim(',') }

$args = @(
 '-qgnO',
 '-l', 'C:\cygwin-packages',
 '-R', 'C:\cygwin'
)

# default site if not specified
if ( '' ) {
  $sites = ''
} elseif ($platform -eq 'x86') {
  $sites = 'http://mirrors.kernel.org/sourceware/cygwin-archive/20221123'
} else {
  $sites = 'http://mirrors.kernel.org/sourceware/cygwin/'
}
$site_list = $sites.Split('', [System.StringSplitOptions]::RemoveEmptyEntries)
$site_list = $site_list | % { $_.Trim() }
foreach ($site in $site_list) {
  $args += '-s'
  $args += $site
}

if ($pkg_list.Count -gt 0) {
  $args += '-P'
  $args += $pkg_list -Join(',')
}

if ('true' -eq $false) {
  $args += '-X'
}

if ( '' ) {
  $pubkeys = ''
  $pubkey_list = $pubkeys.Split('', [System.StringSplitOptions]::RemoveEmptyEntries)
  $pubkey_list = $pubkey_list | % { $_.Trim() }
  foreach ($pubkey in $pubkey_list) {
    $args += '-K'
    $args += $pubkey
  }
}

if ($platform -eq 'x86') {
  $args += '--allow-unsupported-windows'
}

# because setup is a Windows GUI app, make it part of a pipeline to make
# PowerShell wait for it to exit
& C:\setup.exe $args | Out-Default
[Build and test/build-windows] ⭐ Run Main echo "C:\cygwin\bin" >> $env:GITHUB_PATH
[Build and test/build-windows]   ✅  Success - Main echo "C:\cygwin\bin" >> $env:GITHUB_PATH
[Build and test/build-windows]   ⚙  ::add-path:: ��C:\cygwin\bin
[Build and test/build-windows]   ⚙  ::add-path::
[Build and test/build-windows] ⭐ Run Main # run login shell to copy skeleton profile files
C:\cygwin\bin\bash.exe --login
[Build and test/build-windows]   ❌  Failure - Main # run login shell to copy skeleton profile files
C:\cygwin\bin\bash.exe --login
[Build and test/build-windows] exec: environment variable contains NUL
[Build and test/build-windows]   ❌  Failure - Main Set up Cygwin
[Build and test/build-windows] exec: environment variable contains NUL
jon-turney commented 4 months ago

A google search for exec: environment variable contains NUL seems to suggest this message comes from go.

I'm not sure if/how that's involved in your runner.

I don't immediately see how this action could be the cause of such an envvar.

ms609 commented 4 months ago

go is not installed or used in the runner (unless indirectly within act?)

jon-turney commented 4 months ago

go is not installed or used in the runner (unless indirectly within act?)

I'm assuming act means https://github.com/nektos/act, in which case, yes, it seems to be written in go.

It seems like this might be an interaction between this checking that the go runtime does on the Windows environment and the one that Cygwin sets up (which is different to the environment seen by Cygwin processes (see https://cygwin.com/cygwin-ug-net/setup-env.html#setup-env-win32), but I can't quite convince myself that the process heirarchy would be one where that makes sense.

I guess a simple investigation would be to test if a trivial go program, built using Window go compiler, runs under a Cygwin shell or issues the same error.