tauri-apps / tauri-action

Build your Web application as a Tauri binary for macOS, Linux and Windows
https://tauri.app
MIT License
889 stars 147 forks source link

[bug] Github actions all platform builds fail with MODULE NOT FIND #288

Closed Flavsditz closed 2 years ago

Flavsditz commented 2 years ago

Describe the bug

Using the GitHub action provided on the website (with just a change to use NPM instead of Yarn) here:

name: "publish"
on:
  push:
    branches:
      - release

jobs:
  publish-tauri:
    strategy:
      fail-fast: false
      matrix:
        platform: [macos-latest, ubuntu-latest, windows-latest]

    runs-on: ${{ matrix.platform }}
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Node.js setup
      uses: actions/setup-node@v1
      with:
        node-version: 16

    - name: Rust setup
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable

    - name: Install dependencies (ubuntu only)
      if: matrix.platform == 'ubuntu-latest'
      run: |
        sudo apt-get update
        sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf

    - name: Install app dependencies and build it
      run: npm install && npm run build

    - name: Build the app
      uses: tauri-apps/tauri-action@v0
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
        releaseName: "App v__VERSION__"
        releaseBody: "See the assets to download this version and install."
        releaseDraft: true
        prerelease: false

I've left it running and initially I got an error on the windows pipeline due to prettier that got solved by adding a .gitattributes file to the root of the project with * text=auto eol=lf. (I would be willing to make an MR to get this info in the docs if you judge it necessary - I know it is specific to prettier, but it could avoid other problems due to line-endings)

All other pipelines seemed ok but I later found out they all get stuck (and consume minutes) on the build step with the following error:

Run tauri-apps/tauri-action@v0

running npx [ 'run', 'tauri:build' ]
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN exec The following package was not found and will be installed: run
Watching D:\a\test-tauri-app\test-tauri-app and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
Found & ignored ./node_modules ; is listed in .gitignore
Found & ignored ./dist\css\app.6cd52001.css ; has ignored extension
Found & ignored ./src\assets\style\tailwind.css ; has ignored extension
Starting: tauri:build
node:internal/modules/cjs/loader:936
  throw err;
  ^
Error: Cannot find module 'D:\a\test-tauri-app\test-tauri-app\tauri:build'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

It is my first experience with Github Actions and I have no idea what this error is pointing to.

Reproduction

No response

Expected behavior

No response

Platform and versions

The Platform and version is from the gitlab pipelines

Stack trace

No response

Additional context

No response

lucasfernog commented 2 years ago

Are you using vue-cli-plugin-tauri?

Flavsditz commented 2 years ago

I am indeed! I started the project with what was proposed by the tauri guide...

Here is my package.json:

{
  "name": "test-tauri-app",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "tauri:build": "vue-cli-service tauri:build",
    "tauri:serve": "vue-cli-service tauri:serve"
  },
  "dependencies": {
    "@tauri-apps/api": "^1.0.1",
    "@tauri-apps/cli": "^1.0.2",
    "axios": "^0.27.2",
    "core-js": "^3.23.3",
    "exceljs": "^4.3.0",
    "jsonwebtoken": "^8.5.1",
    "vue": "^2.6.14",
    "vue-class-component": "^7.2.6",
    "vue-property-decorator": "^9.1.2",
    "vue-router": "^3.5.4",
    "vuex": "^3.6.2"
  },
  "devDependencies": {
    "@tailwindcss/postcss7-compat": "^2.2.17",
    "@types/exceljs": "^1.3.0",
    "@typescript-eslint/eslint-plugin": "^4.33.0",
    "@typescript-eslint/parser": "^4.33.0",
    "@vue/cli-plugin-babel": "~4.5.19",
    "@vue/cli-plugin-eslint": "~4.5.19",
    "@vue/cli-plugin-router": "~4.5.19",
    "@vue/cli-plugin-typescript": "~4.5.19",
    "@vue/cli-plugin-vuex": "~4.5.19",
    "@vue/cli-service": "~4.5.19",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/eslint-config-typescript": "^7.0.0",
    "autoprefixer": "^9",
    "eslint": "^6.8.0",
    "eslint-plugin-prettier": "^3.4.1",
    "eslint-plugin-vue": "^6.2.2",
    "lint-staged": "^13.0.3",
    "postcss": "^7",
    "prettier": "^2.7.1",
    "prettier-plugin-tailwindcss": "^0.1.11",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.17",
    "typescript": "~4.4.4",
    "vue-cli-plugin-tailwind": "~3.0.0",
    "vue-cli-plugin-tauri": "~1.0.0-rc.3",
    "vue-template-compiler": "^2.7.0"
  },
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,jsx,vue,ts,tsx}": [
      "vue-cli-service lint",
      "git add"
    ]
  }
}
lucasfernog commented 2 years ago

I think the bug is on our end: https://github.com/tauri-apps/tauri-action/blob/88012a3961e8a906fae5e3fc3c25660e9b93d3c6/packages/core/index.ts#L373 this should be using npm instead of npx.

Flavsditz commented 2 years ago

anything I can help with?

lucasfernog commented 2 years ago

Can you test using tauri-apps/tauri-action@fix/vue-cli-plugin-tauri-usage instead of tauri-apps/tauri-action@v0?

Flavsditz commented 2 years ago

It seems to go through now! I am now facing the exactly same error as I had on a windows machine I have at home, which I thought was misconfigured:

 Finished release [optimized] target(s) in 10m 00s
        Info Verifying wix package
 Downloading https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip
        Info validating hash
        Info extracting WIX
        Info Target: x64
     Running candle for "main.wxs"
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^
[Error: failed to bundle project: error running candle.exe: error running candle.exe: ``] {
  code: 'GenericFailure'
}
Error: Command failed with exit code 1: npm run tauri:build

But I've already raised this on the main Tauri repository. I am just hoping someone can help. The pipeline seems to work now :)

Thanks @lucasfernog

lucasfernog commented 2 years ago

Maybe try adding args: --verbose to the action input arguments.

Flavsditz commented 2 years ago

Did that already before and couldn't get any more information than what I posted here (and also on the link I mentioned this issue). Tbh I am at a loss since I haven't been working with Windows for a while now. I think I have to do a deep dive...

lucasfernog commented 2 years ago

Maybe -- --verbose since you're using NPM.

lucasfernog commented 2 years ago

Let's move to that issue to discuss it.

lucasfernog commented 2 years ago

You can use tauri-apps/tauri-action@dev for now since i'll merge and delete that branch.