tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.21k stars 2.58k forks source link

Permission denied on yarn tauri build #2731

Closed SnowyCoder closed 2 years ago

SnowyCoder commented 3 years ago

Permission denied on yarn tauri build

Running yarn tauri build on any tauri app fails with the following error: boost::filesystem::status: Permission denied: "/root/.local/binexport"

To Reproduce

Steps to reproduce the behavior:

  1. Create any tauri project with yarn create tauri-app (or clone my simple example)
  2. Cd into your project
  3. yarn tauri build --verbose
  4. See error

Expected behavior

The project should build successfully

Platform and Versions (required):

Operating System - Manjaro, version 21.1.4 X64

Node.js environment
  Node.js - 14.15.5
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 7.5.4
  yarn - 1.22.11

Rust environment
  rustc - 1.55.0
  cargo - 1.55.0

App directory structure
/.git
/dist
/node_modules
/src-tauri

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - ../dist

Additional context

uanme -a: Linux snowy-pc 5.10.68-1-MANJARO #1 SMP PREEMPT Wed Sep 22 12:29:47 UTC 2021 x86_64 GNU/Linux

Stack Trace

$ tauri build --verbose                                                                                                                                                                                                                [27/3507]
 app:spawn Running "/run/media/snowy/Volume/misc/progetti/tauritmp2/node_modules/@tauri-apps/cli/bin/tauri-cli tauri build --verbose" +0ms

   Compiling app v0.1.0 (/run/media/snowy/Volume/misc/progetti/tauritmp2/src-tauri)
    Finished release [optimized] target(s) in 22.05s
    Bundling tauritmp2_0.1.0_amd64.deb
    Bundling tauritmp2_0.1.0_amd64.AppImage
+ export ARCH=x86_64
+ ARCH=x86_64
+ mkdir -p tauritmp2.AppDir
+ cp -r ../appimage_deb/data/usr tauritmp2.AppDir
+ cd tauritmp2.AppDir
+ wget -q -4 -O AppRun https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-x86_64
SSL_INIT
SSL_INIT
+ chmod +x AppRun
+ cp usr/share/icons/hicolor/512x512@2x/apps/tauritmp2.png .DirIcon
+ ln -s usr/share/icons/hicolor/512x512@2x/apps/tauritmp2.png tauritmp2.png
+ ln -s usr/share/applications/tauritmp2.desktop tauritmp2.desktop
+ cd ..
+ wget -q -4 -O linuxdeploy-plugin-gtk.sh https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh
SSL_INIT
+ wget -q -4 -O linuxdeploy-x86_64.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
SSL_INIT
SSL_INIT
+ chmod +x linuxdeploy-plugin-gtk.sh
+ chmod +x linuxdeploy-x86_64.AppImage
+ OUTPUT=tauritmp2_0.1.0_amd64.AppImage
+ ./linuxdeploy-x86_64.AppImage --appdir tauritmp2.AppDir --plugin gtk --output appimage
linuxdeploy version 1-alpha (git commit ID 49f4f23), GitHub actions build 32 built on 2021-05-28 23:32:28 UTC
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::status: Permission denied: "/root/.local/binexport"
/run/media/snowy/Volume/misc/progetti/tauritmp2/src-tauri/target/release/bundle/appimage/build_appimage.sh: line 31: 124027 Aborted                 (core dumped) OUTPUT="tauritmp2_0.1.0_amd64.AppImage" ./linuxdeploy-x86_64.AppImage --appdir
 "tauritmp2.AppDir" --plugin gtk --output appimage
Error: failed to bundle project

Caused by:
    Shell Scripting Error:`error running appimage.sh`

app:spawn Command "/run/media/snowy/Volume/misc/progetti/tauritmp2/node_modules/@tauri-apps/cli/bin/tauri-cli" failed with exit code: 1 +0ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
denvaki commented 2 years ago

hey @SnowyCoder , I checked and all works fine. Seems like issue is fixed. Please close this

SnowyCoder commented 2 years ago

I checked and the error still seems to be present in the latest exported tauri-cli (v.1.0.0-rc.10).

+ ./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir totemfe.AppDir --plugin gtk --output appimage
linuxdeploy version 1-alpha (git commit ID 097212a), GitHub actions build 80 built on 2022-05-03 17:10:24 UTC
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::status: Permission denied: "/root/.local/binexport"
`
error Command failed with exit code 1.

uname -a: Linux snowy-pc 5.16.20-2-MANJARO #1 SMP PREEMPT Thu Apr 14 06:44:39 UTC 2022 x86_64 GNU/Linux (example github repo updated accordingly)

SnowyCoder commented 2 years ago

Additional info (using this project):

❯ yarn tauri info
yarn run v1.22.15
warning package.json: No license field
$ tauri info

Environment
  › OS: Manjaro 21.2.6 X64
  › Node.js: 17.1.0
  › npm: 8.1.3
  › pnpm: 6.11.0
  › yarn: 1.22.15
  › rustup: 1.24.3
  › rustc: 1.60.0
  › cargo: 1.60.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu

Packages
  › @tauri-apps/cli [NPM]: 1.0.0-rc.10
  › @tauri-apps/api [NPM]: 1.0.0-rc.5
  › tauri [RUST]: 1.0.0-rc.10,
  › tauri-build [RUST]: 1.0.0-rc.8,
  › tao [RUST]: 0.8.4,
  › wry [RUST]: 0.16.2,

App
  › build-type: bundle
  › CSP: default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  › distDir: ../dist
  › devPath: ../dist

App directory structure
  ├─ .git
  ├─ dist
  ├─ src-tauri
  └─ node_modules
good-praxis commented 2 years ago

Oh here's a thought, you seem to be building these with the tauri cli directly, (you don't build it through yarn tauri build). how'd you install that? Maybe the output of which tauri could be useful? I just don't believe (and please, collaborators correct me if I'm wrong) that the build process should be creating any files in /root/, unless you're running it as root?

lucasfernog commented 2 years ago

What is trying to read /root is the linuxdeploy AppImage - maybe it is searching files from / and thinking it should read /root/.local/binexport

good-praxis commented 2 years ago

It shouldn't fail irrecoverably while scanning for something though, that sounds incredibly unstable and would've caused bigger issues on more systems that, I think. It looks to me more like a constructed path that looks for the users home to read binexport but somehow derives /root/ as home when the user doesn't have the permission to access that

That or PATH could be a little weird and AppImage is trying to force access to all the folders in PATH?

good-praxis commented 2 years ago

Oh yeah it is, I just gave it a shot and added a false dir to my path and could reproduce the error!

Error running CLI: failed to bundle project: error running appimage.sh: error running appimage.sh: `+ export ARCH=x86_64
+ ARCH=x86_64
+ mkdir -p tauritmp2.AppDir
+ cp -r ../appimage_deb/data/usr tauritmp2.AppDir
+ cd tauritmp2.AppDir
++ dirname '{}'
+ find /usr/lib /usr/lib32 /usr/lib64 /usr/libexec -name WebKitNetworkProcess -exec mkdir -p . ';' -exec cp --parents '{}' . ';'
++ dirname '{}'
+ find /usr/lib /usr/lib32 /usr/lib64 /usr/libexec -name WebKitWebProcess -exec mkdir -p . ';' -exec cp --parents '{}' . ';'
++ dirname '{}'
+ find /usr/lib /usr/lib32 /usr/lib64 /usr/libexec -name libwebkit2gtkinjectedbundle.so -exec mkdir -p . ';' -exec cp --parents '{}' . ';'
+ wget -q -4 -O AppRun https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-x86_64
+ chmod +x AppRun
+ cp usr/share/icons/hicolor/512x512@2x/apps/tauritmp2.png .DirIcon
+ ln -s usr/share/icons/hicolor/512x512@2x/apps/tauritmp2.png tauritmp2.png
+ ln -s usr/share/applications/tauritmp2.desktop tauritmp2.desktop
+ cd ..
+ wget -q -4 -O linuxdeploy-plugin-gtk.sh https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh
+ wget -q -4 -O linuxdeploy-x86_64.AppImage https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
+ chmod +x linuxdeploy-plugin-gtk.sh
+ chmod +x linuxdeploy-x86_64.AppImage
+ OUTPUT=tauritmp2_0.1.0_amd64.AppImage
+ ./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir tauritmp2.AppDir --plugin gtk --output appimage
linuxdeploy version 1-alpha (git commit ID 56760df), GitHub actions build 83 built on 2022-05-18 21:34:43 UTC
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::status: Permission denied: "/root/.local/bindoesntexist/usr/local/sbin"
`
error Command failed with exit code 1.
lucasfernog commented 2 years ago

Hmm nice catch. I guess there's nothing we can do except tell users to not add /root stuff in the PATH lol

good-praxis commented 2 years ago

It's not quite that, the folders both got to exist and the user got to have access to them. If we keep track of troubleshoot solutions, that could go there for as long as we rely on AppImage

As for now, building an AppImage requires a "sane" PATH

lucasfernog commented 2 years ago

@FabianLars @lorenzolewis can one of you track this for a FAQ or troubleshoot section in the docs?

SnowyCoder commented 2 years ago

Thanks, you're right, I had a "/root/.local/binexport" in my path (and I have no idea why it was there), I've removed it and it's working fine!