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

Creating a project with npm x create-tauri-app leaves description undefined, causes builds to fail #2508

Closed
edgex004 opened this issue Aug 21, 2021 · 6 comments · Fixed by #2514

Comments

@edgex004
Copy link
Contributor

edgex004 commented Aug 21, 2021

Describe the bug

Projects created with npm x create-tauri-app do not set a package.description in the the top-level Cargo.toml. This causes the Cargo.toml to fail being imported in cargo_tauri::interface::rust::get_workspace_dir in the call to CargoSettings::load(&dir);. This eventually leads to tauri build failing.

Additionally, the feedback to the developer as to why the build failure is happening is not particularly helpful. In my case, the failure to identify the workspace causes the rename of the built app from app to the final target name to fail due to incorrect path. The parse failure adds a context describing why parsing failed, which is silently consumed by rs.cli. This parse detail might be useful for the developer.

To Reproduce

Steps to reproduce the behavior:
1.

$ npm x create-tauri-app
We hope to help you create something special with Tauri!
You will have a choice of one of the UI frameworks supported by the greater web tech community.
This should get you started. See our docs at https://tauri.studio/
If you haven't already, please take a moment to setup your system.
You may find the requirements here: https://tauri.studio/en/docs/getting-started/setup-macos/
Press any key to continue...
? What is your app name? test-tauri-app
? What should the window title be? Test Tauri App
? What UI recipe would you like to add? Dominator (https://crates.io/crates/dominator/)
? Add "@tauri-apps/api" npm package? Yes
  1. cd test-tauri-app/
  2. yarn add -D wasm-pack
  3. yarn tauri build
  4. Note error:
Error: failed to rename `/Users/edgex004/Code/test-tauri-app/src-tauri/target/release/app` to `/Users/edgex004/Code/test-tauri-app/src-tauri/target/release/test-tauri-app`
  1. Add a package.description to test-tauri-app/Cargo.toml :
[package]
name = "test-tauri-app"
version = "1.0.0"
categories = ["wasm"]
edition = "2018"
description = ""
  1. yarn tauri build
  2. Build succeeds.

Expected behavior

Build succeeds without modifying test-tauri-app/Cargo.toml .

Screenshots

Platform and Versions (required):

yarn run v1.22.11
warning package.json: No license field
$ tauri info
 app:spawn Running "/Users/edgex004/Code/test-tauri-app/node_modules/@tauri-apps/cli/bin/tauri-cli tauri info" +0ms


Operating System - Mac OS, version 11.2.3 X64

Node.js environment
  Node.js - 16.7.0
  @tauri-apps/cli - 1.0.0-beta.7
  @tauri-apps/api - 1.0.0-beta.6

Global packages
  npm - 7.20.3
  yarn - 1.22.11

Rust environment
  rustc - 1.56.0-nightly
  cargo - 1.56.0-nightly

App directory structure
/dist
/target
/node_modules
/src-tauri
/src

App
  tauri.rs - 1.0.0-beta.6 (no lockfile)
  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 - http://localhost:10001/
  bundler - Rollup

✨  Done in 6.52s.

Additional context

Stack Trace

@edgex004
Copy link
Contributor Author

edgex004 commented Aug 21, 2021

Recommend:

  1. Fix npm x create-tauri-app to add package.description in the top-level Cargo.toml.
  2. Adding a warning printout to cli.rs for when get_workspace_dir finds a Cargo.toml in a parent directory, but fails to parse it for some reason. Print the parser error context here. Split into suggestion Add more verbose logging when tauri fails to parse a Cargo.toml in a parent workspace #2515

I have started making a patch for item 2, but the only challenge is that cargo_tauri::interface::rust functions could be called by any context (build, run, etc), so adding warnings/logging directly to those functions does not seem to the be correct approach.

@amrbashir
Copy link
Member

Last time I checked the dominator recipe, it was working fine but sure lets add a description to Cargo.toml , would love to see a PR, the template is in tooling/create-tauri-app/src/templates/dominator

@edgex004
Copy link
Contributor Author

@amrbashir also, would it make sense to add "wasm-pack": "^0.10.0" to the template package.json so that step 3 in steps to reproduce can be skipped?

@amrbashir
Copy link
Member

The recipe uses rollup-plugin-rust which uses wasm-pack so it is not needed.

@edgex004
Copy link
Contributor Author

Ah, okay. That makes sense. I am not sure why it kept telling me to install manually. Perhaps I was not actually running yarn install in the top directory.

@nothingismagick
Copy link
Sponsor Member

NPM / Yarn will warn you to make sure you install transitive deps, because they are not smart enough to figure that out.

@edgex004 edgex004 changed the title Creating a project with npm x create-tauri-app leaves description blank, causes builds to fail Creating a project with npm x create-tauri-app leaves description undefined, causes builds to fail Aug 23, 2021
lucasfernog pushed a commit that referenced this issue Aug 24, 2021
Co-authored-by: David Von Edge <david.vonedge@smiths.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants