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.67k stars 2.51k forks source link

[bug] Tauri 2.0 beta project generator fails with tauri commands due to invalid CLI version #9182

Closed kristianmandrup closed 7 months ago

kristianmandrup commented 7 months ago

Describe the bug

After having created a tauri 2.0 beta project for mobile, the tauri ios init command failed as per this issue

This was due to package.json dev dependency having tauri CLI set to 1.x. It works when updated to 2.x as demonstrated by this demo project

Reproduction

> bun tauri ios init
       Error [tauri_cli::helpers::config] `tauri.conf.json` error on `build`: Additional properties are not allowed ('devUrl', 'frontendDist' were unexpected)
       Error [tauri_cli::helpers::config] `tauri.conf.json` error: Additional properties are not allowed ('app', 'bundle', 'identifier', 'productName', 'version' were unexpected)

Expected behavior

tauri commands such as tauri ios init should work after generating a project using official starter guide with --beta option

Full tauri info output

[✔] Environment
    - OS: Mac OS 14.2.1 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.76.0 (07dca489a 2024-02-04)
    ✔ cargo: 1.76.0 (c84b36747 2024-01-18)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 18.12.1
    - pnpm: 8.6.3
    - yarn: 1.22.19
    - npm: 8.19.2
    - bun: 1.0.30

[-] Packages
    - tauri [RUST]: 2.0.0-beta.11
    - tauri-build [RUST]: 2.0.0-beta.9
    - wry [RUST]: 0.37.0
    - tao [RUST]: 0.26.1
    - tauri-cli [RUST]: 1.5.11
    - @tauri-apps/api [NPM]: 2.0.0-beta.5
    - @tauri-apps/cli [NPM]: 2.0.0-beta.9

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

[-] iOS
    - Developer Teams: None

Stack trace

No response

Additional context

No response

amrbashir commented 7 months ago

Can you please describe your exact steps where you ended up with @tauri-apps/cli having 1.x version?

kristianmandrup commented 7 months ago

Sure. I first followed the guide at https://beta.tauri.app/blog/create-tauri-app-version-3-released/

pnpm create-tauri-app --beta --mobile

I aborted this since a number of steps were missing and I wanted to use bun.

I then discovered this this guide which I followed, installing to the same folder as my aborted attempt (that may be the reason?)

bunx create-tauri-app --beta --mobile
cd test-app
bun install
bun run tauri dev

Each time I started the project generator, I chose the following options

I then followed the prerequisites guide at https://beta.tauri.app/guides/prerequisites/#ios

Making sure I had the latest Rust installed, latest Node LTS and so on.

It seems very difficult to find a good guide for how to install, configure and run a project with v2 beta and a lot of the guides still reference the alpha version.

kristianmandrup commented 7 months ago

I might have done --alpha in my first attempt and then run again with --beta using the same project name and hence location, overwriting previous files, which could have messed things up I guess. I'll proceed to do a clean start with a new project name or location

amrbashir commented 7 months ago

None of what you tried should ever result in a package.json with 1.x version of the CLI even if you aborted. Also your tauri info suggests you have 2.x of the CLI.

The only issue I see is that you have tauri-cli installed globally which is 1.x, maybe you ran cargo tauri dev instead of bun run tauri dev?

I will close this issue for now but feel free to ping me if you still face the issue.

kristianmandrup commented 7 months ago

Now that I think about it, it may have been due to me being unable to follow the guide "to the letter", ie. the tauri command failed. Then I found a way to install the tauri CLI, but without specifying the version explicitly, initially. Then I finally managed to be able to run tauri (but with bunx I guess?) and then there was a mismatch as would be expected. Ideally, I guess the CLI could determine such a mismatch instead of simply failing on not being able to parse the tauri config files.