subosito / flutter-action

Flutter environment for use in GitHub Actions. It works on Linux, Windows, and macOS.
MIT License
2.28k stars 202 forks source link

Action fails due to "which" command not found #309

Closed RossComputerGuy closed 6 months ago

RossComputerGuy commented 6 months ago
28 packages have newer versions incompatible with dependency constraints.
Try `dart pub outdated` for more information.
Unhandled exception:
ProcessException: Failed to find "which" in the search path.
  Command: which 
#0      LocalProcessManager.runSync (package:process/src/interface/local_process_manager.dart:118:7)
#1      ErrorHandlingProcessManager.runSync.<anonymous closure> (package:flutter_tools/src/base/error_handling_io.dart:711:24)
#2      _runSync (package:flutter_tools/src/base/error_handling_io.dart:587:14)
#3      ErrorHandlingProcessManager.runSync (package:flutter_tools/src/base/error_handling_io.dart:710:12)
#4      _PosixUtils._which (package:flutter_tools/src/base/os.dart:223:50)
#5      OperatingSystemUtils.whichAll (package:flutter_tools/src/base/os.dart:103:43)
#6      AndroidSdk.locateAndroidSdk.findAndroidHomeDir (package:flutter_tools/src/android/android_sdk.dart:131:46)
#7      AndroidSdk.locateAndroidSdk (package:flutter_tools/src/android/android_sdk.dart:155:36)
#8      AppContext._generateIfNecessary.<anonymous closure> (package:flutter_tools/src/base/context.dart:107:42)
#9      _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:543:23)
#10     AppContext._generateIfNecessary (package:flutter_tools/src/base/context.dart:95:20)
#11     AppContext.get (package:flutter_tools/src/base/context.dart:124:32)
#12     androidSdk (package:flutter_tools/src/globals.dart:71:39)
#13     generateCommands (package:flutter_tools/executable.dart:190:25)
#14     main.<anonymous closure> (package:flutter_tools/executable.dart:95:11)
#15     run.<anonymous closure> (package:flutter_tools/runner.dart:53:13)
<asynchronous suspension>
#16     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#17     main (package:flutter_tools/executable.dart:93:3)
<asynchronous suspension>
Error: Process completed with exit code 255.

Action:

  linux:
    strategy:
      matrix:
        arch: [x64]
        channel: [stable]
    continue-on-error: true
    runs-on: ubuntu-latest
    container:
      image: bilelmoussaoui/flatpak-github-actions:freedesktop-22.08
      options: --privileged
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Add dependencies
        run: |
          dnf update -y
          dnf install -y jq cmake ninja-build gtk3-devel clang appstream
          dnf clean all
      - uses: subosito/flutter-action@v2
        with:
          cache: true
          channel: ${{ matrix.channel }}
          architecture: ${{ matrix.arch }}
      - if: ${{ !github.event.issue.pull_request }}
        name: Set up GPG key
        uses: crazy-max/ghaction-import-gpg@v5
        with:
          gpg_private_key: ${{ secrets.FLATPAK_GPG_KEY }}
          passphrase: ${{ secrets.FLATPAK_GPG_PASSPHRASE }}
      - name: Build Flutter
        run: |
          git config --global --add safe.directory /opt/hostedtoolcache/flutter/${{ matrix.channel }}-3.10.2-${{ matrix.arch }}
          flutter config --enable-linux-desktop
          flutter build linux --build-number $GITHUB_RUN_NUMBER --dart-define=COMMIT_HASH=$GITHUB_SHA --dart-define=SENTRY_DSN=${{ secrets.SENTRY_DSN }}
          tar -czf com.expidusos.calculator-linux-${{ matrix.arch }}.tar.gz -C build/linux/${{ matrix.arch }}/release/bundle/ .
      - if: ${{ !github.event.issue.pull_request }}
        uses: flatpak/flatpak-github-actions/flatpak-builder@v6.1
        name: Bundle Flatpak
        with:
          bundle: com.expidusos.calculator.flatpak
          manifest-path: data/com.expidusos.calculator.yml
          cache-key: flatpak-builder-${{ github.sha }}
          gpg-sign: F1AE8F34E36642E92E7777B591654E1B742E4226
      - if: ${{ github.event.issue.pull_request }}
        uses: flatpak/flatpak-github-actions/flatpak-builder@v6.1
        name: Bundle Flatpak
        with:
          bundle: com.expidusos.calculator.flatpak
          manifest-path: data/com.expidusos.calculator.yml
          cache-key: flatpak-builder-${{ github.sha }}
      - name: Upload build
        uses: actions/upload-artifact@v3
        with:
          name: com.expidusos.calculator-linux-${{ matrix.arch }}
          path: build/linux/${{ matrix.arch }}/release/bundle/
      - if: startsWith(github.ref, 'refs/tags/')
        name: Release
        uses: softprops/action-gh-release@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          files: |
            com.expidusos.calculator.flatpak
            com.expidusos.calculator-linux-${{ matrix.arch }}.tar.gz

Run: https://github.com/ExpidusOS/calculator/actions/runs/9105465116/job/25031073337?pr=6

bartekpacia commented 6 months ago

Hey @RossComputerGuy! Nice to meet you and thank you for reporting this problem.

It may be a stupid question, but does the image bilelmoussaoui/flatpak-github-actions:freedesktop-22.08 have which in its $PATH?

Furthermore, the error you posted is thrown by the Flutter tool – which means Flutter itself was successfully downloaded - so I think that this problem is not related to flutter-action.

wdyt?

RossComputerGuy commented 6 months ago

It may be a stupid question, but does the image bilelmoussaoui/flatpak-github-actions:freedesktop-22.08 have which in its $PATH?

I'm not sure. I fixed it by dnf install which.