Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variable contains NUL #15

Open
ms609 opened this issue Jul 11, 2024 · 3 comments
Open

Environment variable contains NUL #15

ms609 opened this issue Jul 11, 2024 · 3 comments

Comments

@ms609
Copy link

ms609 commented Jul 11, 2024

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
Copy link
Member

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
Copy link
Author

ms609 commented Jul 11, 2024

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

@jon-turney
Copy link
Member

jon-turney commented Jul 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants