tauri-apps / tauri

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

[bug] Failed to rename app, directory not empty #8682

Closed Guilherme-Vasconcelos closed 8 months ago

Guilherme-Vasconcelos commented 8 months ago

Describe the bug

I have just created a brand new tauri project using create-tauri-app. Then I ran npm install, followed by npm run tauri dev and got this panic:

> npm run tauri dev

> my-tauri-app@0.0.0 tauri
> tauri "dev"

     Running BeforeDevCommand (`npm run dev`)

> my-tauri-app@0.0.0 dev
> vite

  VITE v5.0.12  ready in 431 ms

  ➜  Local:   http://localhost:1420/
  ➜  Network: use --host to expose
        Info Watching /home/guilherme/Desktop/my-tauri-app/src-tauri for changes...
   Compiling my-tauri-app v0.0.0 (/home/guilherme/Desktop/my-tauri-app/src-tauri)
    Finished dev [unoptimized + debuginfo] target(s) in 1.04s
thread '<unnamed>' panicked at src/interface/rust/desktop.rs:52:69:
failed to rename app: failed to rename `/home/guilherme/Desktop/my-tauri-app/src-tauri/target/debug/my-tauri-app` to `/home/guilherme/Desktop/my-tauri-app/src-tauri/target/debug`

Caused by:
    Directory not empty (os error 39)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Despite the panic, I can open http://localhost:1420/ in my browser and it displays the default tauri page, so I'm not really sure what effect the panic had but it doesn't seem to have affected the startup:

image

Reproduction

Run the following commands:

  1. mkdir my-tauri-app
  2. cd my-tauri-app
  3. npm create tauri-app@latest . --template svelte-ts --manager npm

In the create-tauri-app interface, pick the following:

  1. Package name: my-tauri-app
  2. Choose which language to use for your frontend: TypeScript / JavaScript - (pnpm, yarn, npm, bun)
  3. Choose your package manager: npm
  4. Choose your UI template: Svelte
  5. Choose your UI flavor: TypeScript

Wait for the project to be generated, then run the following commands:

  1. npm install
  2. npm run tauri dev

You should see the panic I mentioned in the description field.

Expected behavior

I expected the default generated project to run without panics.

Full tauri info output

> npm run tauri info

> my-tauri-app@0.0.0 tauri
> tauri "info"

[✔] Environment
    - OS: Manjaro 23.1.3 X64
    ✔ webkit2gtk-4.0: 2.42.4
    ✔ rsvg2: 2.57.1
    ✔ rustc: 1.75.0 (82e1608df 2023-12-21)
    ✔ cargo: 1.75.0 (1d8b05cdd 2023-11-20)
    ✔ rustup: 1.26.0 (2023-11-14)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 18.4.0
    - yarn: 1.22.21
    - npm: 8.12.1

[-] Packages
    - tauri [RUST]: 1.5.4
    - tauri-build [RUST]: 1.5.1
    - wry [RUST]: 0.24.7
    - tao [RUST]: 0.16.7
    - @tauri-apps/api [NPM]: 1.5.3
    - @tauri-apps/cli [NPM]: 1.5.9

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


### Stack trace

_No response_

### Additional context

_No response_
Guilherme-Vasconcelos commented 8 months ago

It seems like I figured out the issue: because I used npm create tauri-app@latest . (to initialize the project in the current directory, which should be allowed according to create-tauri-app's README), my package.productName in src-tauri/tauri.conf.json was set to ".". I changed it to "my-tauri-app" and now it works.

wxllow commented 8 months ago

Why is this issue closed if nothing was done to address the problem? Users expect running create-tauri-app with the current directory passed should either set the app name to the current directory or prompt for an app name