egor-tensin / setup-clang

GitHub action to set up Clang & LLVM
MIT License
59 stars 7 forks source link

Error: pwsh: command not found #4

Open yegor256 opened 2 years ago

yegor256 commented 2 years ago

I'm getting this error:

Error: pwsh: command not found

See the full log: https://github.com/yegor256/fibonacci/runs/4907989586?check_suite_focus=true

tbarbette commented 1 year ago

I have the same problem using "act" on Windows, and therefore under WSL (so using Docker-Windows) I suspect the detection of the OS is wrong, Linux subsystem must be used if using WSL.

"| OCI runtime exec failed: exec failed: unable to start container process: exec: "pwsh": executable file not found in $PATH: unknown"

Cankar001 commented 7 months ago

I have the same problem, but I am running a self-hosted runner on my ubuntu system. My config looks like this:

    - name: Install Clang
      uses: egor-tensin/setup-clang@v1
      with:
        version: latest
        platform: x64

And this is my log output:

Run egor-tensin/setup-clang@v1
  with:
    version: latest
    platform: x64
    cygwin: 0
    cc: 1
    hardlinks: 0
Run New-Variable os -Value 'Linux' -Option Constant
  New-Variable os -Value 'Linux' -Option Constant

  New-Variable linux_host -Value ($os -eq 'Linux') -Option Constant
  New-Variable cygwin_host -Value ('0' -eq '1') -Option Constant
  New-Variable windows_host -Value ($os -eq 'Windows' -and !$cygwin_host) -Option Constant

  New-Variable version -Value ('latest') -Option Constant
  New-Variable latest -Value ($version -eq 'latest') -Option Constant
  New-Variable x64 -Value ('x64' -eq 'x64') -Option Constant

  function Locate-Choco {
      $path = Get-Command 'choco' -ErrorAction SilentlyContinue
      if ($path) {
          $path.Path
      } else {
          Join-Path ${env:ProgramData} 'chocolatey' 'bin' 'choco'
      }
  }

  function Install-Package {
      param(
          [Parameter(Mandatory=$true, ValueFromRemainingArguments=$true)]
          [string[]] $Packages
      )

      if ($script:linux_host) {
          sudo apt-get update
          sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends $Packages
      } elseif ($script:cygwin_host) {
          $choco = Locate-Choco
          & $choco install $Packages -y --no-progress --source=cygwin
      } elseif ($script:windows_host) {
          $choco = Locate-Choco
          & $choco upgrade $Packages -y --no-progress --allow-downgrade
      } else {
          throw "Sorry, installing packages is unsupported on $script:os"
      }
  }

  function Format-UpstreamVersion {
      param(
          [Parameter(Mandatory=$true)]
          [string] $Version
      )

      switch -Exact ($Version) {
          # Since version 7, they dropped the .0 suffix. The earliest
          # version supported is 3.9 on Bionic; versions 4, 5 and 6 are
          # mapped to LLVM-friendly 4.0, 5.0 and 6.0.
          '4' { '4.0' }
          '5' { '5.0' }
          '6' { '6.0' }
          default { $Version }
      }
  }

  function Format-AptLine {
      param(
          [Parameter(Mandatory=$true)]
          [string] $Version
      )

      if (!(Get-Command lsb_release -ErrorAction SilentlyContinue)) {
          throw "Couldn't find lsb_release; LLVM only provides repositories for Debian/Ubuntu"
      }
      $codename = lsb_release -sc

      "deb http://apt.llvm.org/$codename/ llvm-toolchain-$codename-$Version main"
  }

  function Add-UpstreamRepo {
      param(
          [Parameter(Mandatory=$true)]
          [string] $Version
      )

      wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
      $apt_line = Format-AptLine $Version
      sudo add-apt-repository --yes --update $apt_line
  }

  $clang = 'clang'
  $clangxx = 'clang++'

  if ($linux_host) {
      $pkg_clang = 'clang'
      $pkg_llvm = 'llvm'
      $pkg_gxx = 'g++'

      if (!$latest) {
          $pkg_version = Format-UpstreamVersion $version
          Add-UpstreamRepo $pkg_version

          $pkg_clang = "$pkg_clang-$pkg_version"
          $pkg_llvm = "$pkg_llvm-$pkg_version"

          $clang = "$clang-$pkg_version"
          $clangxx = "$clangxx-$pkg_version"
      }
      if (!$x64) {
          $pkg_gxx = 'g++-multilib'
      }
      $packages = $pkg_clang,$pkg_llvm,$pkg_gxx

      Install-Package $packages
  } elseif ($cygwin_host) {
      if (!$x64) {
          echo @'
  ::warning ::
  32-bit-targeting Clang is unavailable on 64-bit Cygwin.
  Please use 32-bit Cygwin instead.
  If you _are_ using 32-bit Cygwin, please ignore this message.
  '@
      }

      # IDK why, but without libiconv-devel, even a "Hello, world!"
      # C++ app cannot be compiled as of December 2020. Also, libstdc++
      # is required; it's simpler to install gcc-g++ for all the
      # dependencies.
      Install-Package clang gcc-g++ libiconv-devel llvm
  } elseif ($windows_host) {
      Install-Package llvm

      $bin_dir = Join-Path $env:ProgramFiles LLVM bin
      echo $bin_dir >> $env:GITHUB_PATH
  } else {
      throw "Sorry, installing Clang is unsupported on $os"
  }

  echo "clang=$clang"     >> $env:GITHUB_OUTPUT
  echo "clangxx=$clangxx" >> $env:GITHUB_OUTPUT
  Error: pwsh: command not found

Can anyone help me with this issue?