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

[bug] tauri_plugin::Builder directly modifies the source directory for the plugin that's being built #11187

Open
guillemcordoba opened this issue Oct 1, 2024 · 0 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@guillemcordoba
Copy link
Contributor

Describe the bug

tauri_plugin::Builder directly modifies the source code of the plugin that's being built to add the permissions autogenerated files. This is actually a bad practice as per https://doc.rust-lang.org/cargo/reference/build-script-examples.html#code-generation:

In general, build scripts should not modify any files outside of OUT_DIR. It may seem fine on the first blush, but it does cause problems when you use such crate as a dependency, because there’s an implicit invariant that sources in .cargo/registry should be immutable. cargo won’t allow such scripts when packaging.

As a result, building a tauri plugin crate in special environments that protect the source code of crates against writes like nix becomes quite challenging. The build fails with errors of the type:

       >     Checking holochain_metrics v0.3.2
       > error: failed to run custom build command for `tauri-plugin-log v2.0.0-rc.2`
       >
       > Caused by:
       >   process didn't exit successfully: `/private/tmp/nix-build-hc-pilot-deps-0.1.0.drv-0/tauri-workspace/target/release/build/tauri-plugin-log-4a5a88853b912538/build-script-build` (exit status: 1)
       >   --- stdout
       >   cargo:rerun-if-changed=permissions
       >   cargo:PERMISSION_FILES_PATH=/private/tmp/nix-build-hc-pilot-deps-0.1.0.drv-0/tauri-workspace/target/release/build/tauri-plugin-log-6053c8040f31d660/out/tauri-plugin-log-permission-files
       >   tauri-plugin: failed to write file: Permission denied (os error 13)
       > warning: build failed, waiting for other jobs to finish...

Maybe it is enough to just check in all those files in git? Not sure...

Reproduction

No response

Expected behavior

Plugin crates can be built on a source code protected environment.

Full tauri info output

guillemcordoba@Guillems-Mini end-user-happ % npm run tauri info

> [email protected] tauri
> tauri info


[✔] Environment
    - OS: Mac OS 14.6.1 arm64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: 1.81-aarch64-apple-darwin (default)
    - node: 20.9.0
    - pnpm: 9.5.0
    - yarn: 1.22.21
    - npm: 10.1.0

[-] Packages
    - tauri 🦀: 2.0.0-rc.11
    - tauri-build 🦀: 2.0.0-rc.10
    - wry 🦀: 0.43.1
    - tao 🦀: 0.30.0
    - tauri-cli 🦀: 2.0.0-rc.16
    - @tauri-apps/api : 2.0.0-rc.4
    - @tauri-apps/cli : 2.0.0-rc.15

[-] Plugins
    - tauri-plugin-log 🦀: 2.0.0-rc.2
    - @tauri-apps/plugin-log : not installed!

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../ui/dist
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

[-] iOS
    - Developer Teams: Guillem Cordoba (ID: 4XN3VLHC68)

Stack trace

No response

Additional context

No response

@guillemcordoba guillemcordoba added status: needs triage This issue needs to triage, applied to new issues type: bug labels Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

1 participant