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

npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/MediaPipeUnityPlugin/MediaPipeUnityPlugin/Packages/com.github.homuler.mediapipe/package.json' #1009

Closed
baig97 opened this issue Aug 26, 2023 · 4 comments
Labels
type:build/install Cannot build/install the plugin

Comments

@baig97
Copy link

baig97 commented Aug 26, 2023

Plugin Version or Commit ID

2f37866

Unity Version

2022.3.6f1

Your Host OS

Ubuntu 20.04

Target Platform

Android, iOS

[Windows Only] Visual Studio C++ and Windows SDK Version

No response

[Linux Only] GCC/G++ and GLIBC Version

No response

[Android Only] Android Build Tools and NDK Version

Build Tools: 30.0.2
NDK: 21.4.7075529

[iOS Only] XCode Version

Unsure (default)

Command Sequences

Used github actions workflow.

  1. Forked the most recent commit from master branch.
  2. Commented the line in build-package.yml and package.yml that install for windows, macOS and linux.
  3. Changed android default args to --android arm64 --android_ndk_api_level 21
  4. Ran Github actions 'Build a package' workflow with default args (leaving the args empty)

build-package.yml contents:

name: Build a Package
on:
  workflow_dispatch:
    inputs:
      bazelBuildArgs:
        type: string
        description: A value for `--bazel_build_opts`
      # linuxBuildArgs:
      #   type: string
      #   description: Build options for Linux Build
      androidBuildArgs:
        type: string
        description: Build options for Android Build
      # macosBuildArgs:
      #   type: string
      #   description: Build options for macOS Build
      iosBuildArgs:
        type: string
        description: Build options for iOS Build
      # windowsBuildArgs:
      #   type: string
      #   description: Build options for Windows Build
  schedule:
    - cron: 0 12 * * 0,3
jobs:
  package:
    uses: ./.github/workflows/package.yml
    with:
      ref: ${{ github.event.ref }}
      packageName: package
      bazelBuildArgs: ${{ inputs.bazelBuildArgs || '--experimental_scale_timeouts=10.0 --http_timeout_scaling=10.0' }}
      # linuxBuildArgs: ${{ inputs.linuxBuildArgs || '--desktop gpu --opencv cmake' }}
      androidBuildArgs: ${{ inputs.androidBuildArgs || '--android arm64 --android_ndk_api_level 21' }}
      # macosBuildArgs: ${{ inputs.macosBuildArgs || '--desktop cpu --opencv cmake --macos_universal' }}
      iosBuildArgs: ${{ inputs.iosBuildArgs || '--ios arm64' }}
      # windowsBuildArgs: ${{ inputs.windowsBuildArgs || '--desktop cpu --opencv cmake' }}
    secrets: inherit

package.yml contents:

name: Package
on:
  workflow_call:
    inputs:
      ref:
        type: string
        required: true
      packageName:
        type: string
        default: package
      bazelBuildArgs:
        type: string
        default: '--experimental_scale_timeouts=10.0 --http_timeout_scaling=10.0'
      # linuxBuildArgs:
      #   type: string
      #   default: '--desktop gpu --opencv cmake'
      androidBuildArgs:
        type: string
        default: '--android arm64 --android_ndk_api_level 21'
      # macosBuildArgs:
        # type: string
        # default: '--desktop cpu --opencv cmake --macos_universal'
      iosBuildArgs:
        type: string
        default: '--ios arm64'
      # windowsBuildArgs:
      #   type: string
      #   default: '--desktop cpu --opencv cmake'
    secrets:
      UNITY_EMAIL:
        required: false
      UNITY_PASSWORD:
        required: false
      UNITY_TOTP_KEY:
        required: false

jobs:
  print-inputs:
    runs-on: ubuntu-latest
    steps:
      - name: Print inputs for debug
        run: |
          echo 'inputs.ref=${{ inputs.ref }}'
          echo 'inputs.bazelBuildArgs=${{ inputs.bazelBuildArgs }}'
          # echo 'inputs.linuxBuildArgs=${{ inputs.linuxBuildArgs }}'
          echo 'inputs.androidBuildArgs=${{ inputs.androidBuildArgs }}'
          # echo 'inputs.macosBuildArgs=${{ inputs.macosBuildArgs }}'
          echo 'inputs.iosBuildArgs=${{ inputs.iosBuildArgs }}'
          # echo 'inputs.windowsBuildArgs=${{ inputs.windowsBuildArgs }}'

  # linux-build:
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v3
  #       with:
  #         ref: ${{ inputs.ref }}

  #     - name: Build a Docker image
  #       run: |
  #         docker build --no-cache --build-arg UID=$(id -u) -t mediapipe_unity:latest . -f docker/linux/x86_64/Dockerfile

  #     - name: Build
  #       run: |
  #         docker run --rm \
  #           --mount type=bind,src=$PWD/Packages,dst=/home/mediapipe/Packages \
  #           --mount type=bind,src=$PWD/Assets,dst=/home/mediapipe/Assets \
  #           mediapipe_unity:latest \
  #           python build.py build --bazel_build_opts="${{ inputs.bazelBuildArgs }}" ${{ inputs.linuxBuildArgs }} -vv

  #     - name: Upload artifacts
  #       uses: actions/upload-artifact@v3
  #       with:
  #         name: ${{ inputs.packageName }}-base
  #         path: .

  android-build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ inputs.ref }}

      - name: Build a Docker image
        run: |
          docker build --no-cache --build-arg UID=$(id -u) -t mediapipe_unity:latest . -f docker/linux/x86_64/Dockerfile

      - name: Remove unused files to free up space
        run: |
          sudo rm -rf /usr/share/dotnet /usr/local/lib/android

      - name: Build
        run: |
          docker run --rm \
            --mount type=bind,src=$PWD/Packages,dst=/home/mediapipe/Packages \
            --mount type=bind,src=$PWD/Assets,dst=/home/mediapipe/Assets \
            mediapipe_unity:latest \
            python build.py build --bazel_build_opts="${{ inputs.bazelBuildArgs }}" ${{ inputs.androidBuildArgs }} -vv

      - name: Upload mediapipe_android.aar
        uses: actions/upload-artifact@v3
        with:
          name: ${{ inputs.packageName }}-mediapipe_android.aar
          path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/Android/mediapipe_android.aar

  # macos-build:
  #   runs-on: macos-12
  #   steps:
  #     - uses: actions/checkout@v3
  #       with:
  #         ref: ${{ inputs.ref }}

  #     # Setup Python
  #     - uses: actions/setup-python@v4
  #       with:
  #         python-version: '3.10'
  #     - name: Install NumPy
  #       run: pip install --no-cache-dir --user numpy

  #     - name: Build libmediapipe_c.dylib
  #       run: |
  #         unset ANDROID_NDK_HOME
  #         python build.py build --bazel_build_opts="${{ inputs.bazelBuildArgs }}" ${{ inputs.macosBuildArgs }} -vv

  #     - name: Upload libmediapipe_c.dylib
  #       uses: actions/upload-artifact@v3
  #       with:
  #         name: ${{ inputs.packageName }}-libmediapipe_c.dylib
  #         path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/libmediapipe_c.dylib

  ios-build:
    runs-on: macos-12
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ inputs.ref }}

      # Setup Python
      - uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      - name: Install NumPy
        run: pip install --no-cache-dir --user numpy

      - name: Build bazel to circumvent a compile error
        run: |
          mkdir bin
          git clone https://github.com/bazelbuild/bazel.git --depth 1 --single-branch --branch  6.1.1
          cd bazel
          git apply ../third_party/bazel_ios_workaround.diff
          USE_BAZEL_VERSION=6.2.1 bazel build --java_runtime_version=remotejdk_11 //src:bazel
          cp bazel-bin/src/bazel ../bin
          cd ..
          echo "bin" >> $GITHUB_PATH

      - name: Build MediaPipeUnity.framework
        run: |
          unset ANDROID_NDK_HOME
          sed -i -e 's/PLEASE_SET_YOUR_BUNDLE_ID_HERE/com.github.homuler.mediapipe.unity/g' mediapipe_api/objc/BUILD
          python build.py build --bazel_build_opts="${{ inputs.bazelBuildArgs }}" ${{ inputs.iosBuildArgs }} -vv

      - name: Upload MediaPipeUnity.framework
        uses: actions/upload-artifact@v3
        with:
          name: ${{ inputs.packageName }}-MediaPipeUnity.framework
          path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework

  # windows-build:
  #   runs-on: windows-2019
  #   steps:
  #     - uses: actions/checkout@v3
  #       with:
  #         ref: ${{ inputs.ref }}

  #     - name: Build a Docker image
  #       run: |
  #         docker build --no-cache -t mediapipe_unity:latest . -f docker/windows/x86_64/Dockerfile
  #       shell: cmd
  #       timeout-minutes: 60

  #     - name: Build
  #       run: |
  #         docker run --rm --cpus=2 --memory=8g ^
  #           --mount type=bind,src=%CD%\Packages,dst=C:\mediapipe\Packages ^
  #           --mount type=bind,src=%CD%\Assets,dst=C:\mediapipe\Assets ^
  #           mediapipe_unity:latest ^
  #           python build.py build --bazel_build_opts="${{ inputs.bazelBuildArgs }}" ${{ inputs.windowsBuildArgs }} -vv
  #       shell: cmd

  #     - name: Upload mediapipe_c.dll
  #       uses: actions/upload-artifact@v3
  #       with:
  #         name: ${{ inputs.packageName }}-mediapipe_c.dll
  #         path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/mediapipe_c.dll

  package:
    runs-on: ubuntu-latest
    needs:
      # - linux-build
      - android-build
      # - macos-build
      - ios-build
      # - windows-build
    steps:
      - name: Check options
        run: |
          if [[ -z '${{ secrets.UNITY_EMAIL }}' ]]; then
            echo "BUILD_UNITYPACKAGE=0" >> $GITHUB_ENV
          else
            echo "BUILD_UNITYPACKAGE=1" >> $GITHUB_ENV
          fi

      - name: Install UnityEditor
        if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
        run: |
          sudo docker cp $(docker create --rm unityci/editor:2022.3.6f1-base-1):/opt/unity /opt/unity
          sudo chown -R $(id -u):$(id -g) /opt/unity

          echo -e '#!/bin/bash\nxvfb-run -ae /dev/stdout /opt/unity/Editor/Unity -batchmode "$@"' | sudo tee -a /usr/bin/unity-editor
          sudo chmod +x /usr/bin/unity-editor
      - name: Generate a license activation file
        if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
        run: |
          unity-editor -quit -createManualActivationFile -logFile || true
      - name: Request a Unity license file
        if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
        env:
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
          UNITY_TOTP_KEY: ${{ secrets.UNITY_TOTP_KEY }}
        run: |
          npm install -g unity-verify-code
          git clone https://github.com/homuler/unity-license-activate.git
          cd unity-license-activate
          npm install
          cd ..
          npm install -g ./unity-license-activate
          unity-license-activate "$UNITY_EMAIL" "$UNITY_PASSWORD" Unity_v2022.3.6f1.alf --authenticator-key "$UNITY_TOTP_KEY"
          rm -rf unity-license-activate
      - name: Activate License
        if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
        run: |
          unity-editor -quit -batchmode -nographics -logFile -manualLicenseFile $(ls Unity_*.ulf) || true
          rm Unity_*.alf
          rm Unity_*.ulf

      # - name: Download the base package
      #   uses: actions/download-artifact@v3
      #   with:
      #     name: ${{ inputs.packageName }}-base
      - name: Download mediapipe_android.aar
        uses: actions/download-artifact@v3
        with:
          name: ${{ inputs.packageName }}-mediapipe_android.aar
          path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/Android
      # - name: Download libmediapipe_c.dylib
      #   uses: actions/download-artifact@v3
      #   with:
      #     name: ${{ inputs.packageName }}-libmediapipe_c.dylib
      #     path: Packages/com.github.homuler.mediapipe/Runtime/Plugins
      - name: Download MediaPipeUnity.framework
        uses: actions/download-artifact@v3
        with:
          name: ${{ inputs.packageName }}-MediaPipeUnity.framework
          path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/iOS/MediaPipeUnity.framework
      # - name: Download mediapipe_c.dll
      #   uses: actions/download-artifact@v3
      #   with:
      #     name: ${{ inputs.packageName }}-mediapipe_c.dll
      #     path: Packages/com.github.homuler.mediapipe/Runtime/Plugins

      - name: Zip all
        run: |
          zip -r MediaPipeUnityPlugin-all.zip . -x .git/**\*

      - name: Export tarball
        run: |
          cd Packages/com.github.homuler.mediapipe
          npm pack
          mv com.github.homuler.mediapipe-*.tgz ../..

      - name: Export unitypackage
        if: ${{ env.BUILD_UNITYPACKAGE == '1' }}
        run: |
          unity-editor -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export

      - name: Upload artifacts
        uses: actions/upload-artifact@v3
        with:
          name: ${{ inputs.packageName }}
          path: |
            com.github.homuler.mediapipe-*.tgz
            *.unitypackage
            MediaPipeUnityPlugin-all.zip
          retention-days: 7

  clean:
    runs-on: ubuntu-latest
    needs:
      - package
    steps:
      - uses: geekyeggo/delete-artifact@v2
        with:
          name: ${{ inputs.packageName }}-base
          failOnError: false

      - uses: geekyeggo/delete-artifact@v2
        with:
          name: ${{ inputs.packageName }}-mediapipe_android.aar
          failOnError: false

      # - uses: geekyeggo/delete-artifact@v2
      #   with:
      #     name: ${{ inputs.packageName }}-libmediapipe_c.dylib
      #     failOnError: false

      - uses: geekyeggo/delete-artifact@v2
        with:
          name: ${{ inputs.packageName }}-MediaPipeUnity.framework
          failOnError: false

      # - uses: geekyeggo/delete-artifact@v2
      #   with:
      #     name: ${{ inputs.packageName }}-mediapipe_c.dll
      #     failOnError: false

Log

Android and iOS builds completed successfully. Got error in package/package -> Export tarball step.

Here's the log for this step:

1s
Run cd Packages/com.github.homuler.mediapipe
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/MediaPipeUnityPlugin/MediaPipeUnityPlugin/Packages/com.github.homuler.mediapipe/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/MediaPipeUnityPlugin/MediaPipeUnityPlugin/Packages/com.github.homuler.mediapipe/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in: /home/runner/.npm/_logs/2023-08-26T[1](https://github.com/baig97/MediaPipeUnityPlugin/actions/runs/5984295639/job/16235890513#step:10:1)1_4[8](https://github.com/baig97/MediaPipeUnityPlugin/actions/runs/5984295639/job/16235890513#step:10:9)_21_008Z-debug-0.log
Error: Process completed with exit code 254.

Additional Context

P.s: I am not very proficient with Github Actions workflow neither working with bazel. I just want to complete my face blendshapes project in unity for which I want to use Mediapipe Tasks (unavailable in release 0.12.0).

If you can suggest me steps to circumvent this issue or give me an alternate pathway to make this work, I would be grateful.

Also tell me, if there is a way I can use the built binaries for android and iOS to do some manual steps for successfully loading the plugin in untiy project (I am getting build errors as of now trying this).

@baig97 baig97 added the type:build/install Cannot build/install the plugin label Aug 26, 2023
@homuler
Copy link
Owner

homuler commented Aug 27, 2023

I don't know why you need to modify the workflow file in the first place.
And if you don't know what you're doing too, please don't modify the existing files. Even if something stops working as a result, please take responsibility for it yourself.

See also #1007 (comment).

@homuler homuler closed this as completed Aug 27, 2023
@baig97
Copy link
Author

baig97 commented Aug 27, 2023

Thanks, it really helped. I modified mine as I wanted only android and iOS. Plus the non modified build was failing too (on Windows) for some reason.

Will download your latest successful build now.

@homuler
Copy link
Owner

homuler commented Aug 27, 2023

I see. If it fails, try rerunning failed jobs.
github com_homuler_MediaPipeUnityPlugin_actions_runs_5951006796

However, it seems to me that the latest error doesn't have occurred by chance, so we might need to fix it.

@baig97
Copy link
Author

baig97 commented Aug 27, 2023

Thanks for noting. Please look into it.

I couldn't make it work by rerunning the jobs but I could get the plugin to work by using package.zip from Build a package # 126.

Working like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:build/install Cannot build/install the plugin
Projects
None yet
Development

No branches or pull requests

2 participants