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

Tauri forced layout of src-tauri prevents some organizational strategies #2643

Closed
ghost opened this issue Sep 23, 2021 · 3 comments
Closed

Comments

@ghost
Copy link

ghost commented Sep 23, 2021

Describe the bug

Tauri right now assumes that its source always live in a src-tauri folder.

To Reproduce

  1. Take any valid Tauri app.
  2. Rename the src-tauri folder to anything else.
  3. Try to run any command like cargo tauri dev or cargo tauri build.

Expected behavior

The application builds as usual.

Screenshots

N/A.

Platform and Versions (required):

Operating System - Windows, version 10.0.19043 X64
Webview2 - 93.0.961.52

Node.js environment
  Node.js - 16.9.1
  @tauri-apps/cli - 1.0.0-beta.10

Global packages
  npm - 7.24.0
  yarn - 1.22.11

Rust environment
  rustc - 1.54.0
  cargo - 1.54.0

Additional context

We use Tauri in our monorepo of Rust code which contains many binaries, several of which are actually Tauri applications. Their frontends are generated in various ways and not tied to a particular frontend framework (like vue.js for instance).

My understanding is that Tauri assumes so far that it lives on top of an existing frontend code but there seem to be no strong technical reason why it couldn't be considered as an entrypoint that just loads an opaque dist folder of web-related files.

To give some context, our current Rust repository structure looks like:

lib/
  ...
client/
  editor/    <-- Tauri app.
    Cargo.toml
    tauri.conf.json
    src/
    frontend/  <-- Root of the web frontend project.
      dist/    <-- Compiled web files.
      package.json
      node_modules/
        ...
      ...
  viewer/   <-- Another Tauri app.
    ...
  compiler/  <-- A Rust app, but not a Tauri one.
    Cargo.toml
    src/
      ...
    ...
  merger/
    ...
   ...

Any attempt to run cargo tauri dev or cargo tauri build in that structure yields an error, as this line clearly expects the Cargo.toml and associated Rust directory-structure to be under a src-tauri-named folder.

While we could technically add an extra folder on top of all Tauri-based clients, we'd like to avoid it as:

  • It breaks symmetry with the other clients that are not Tauri-based.
  • It really doesn't look nice from a cosmetic PoV.

Are we attempting something that just should not be done and are we missing obvious reasons why it cannot work ?

I wonder if just looking for the first folder that contains the tauri.conf.json file, regardless of whether it is actually called src-tauri instead would work equally well, while permitting more liberal directory structures.

If that's a scenario that you think should be supported, I'd be more than happy to contribute to this awesome project and make the necessary changes and PRs to make this happen. Let me know!

Stack Trace

PS C:\Users\<redacted>\monorepo\client\editor> cargo tauri dev
thread 'main' panicked at 'Couldn't recognize the current folder as a Tauri project.', src\helpers\app_paths.rs:29:3
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@lucasfernog
Copy link
Member

Can you test #2654 and see if it works on your workspace? :)

@ghost
Copy link
Author

ghost commented Sep 27, 2021

@lucasfernog I can confirm the version from that branch works perfectly! For both cargo tauri dev and cargo tauri build.

That was amazingly fast!

Assuming this is merged soon, is there a known timeline for a release that includes those changes?

@lucasfernog
Copy link
Member

We'll make new releases after our audit is finished, sometime next month. We'll decide if we should cut releases before or after applying the audit changes.

U-C-S added a commit to U-C-S/The-Tauri-Experiment that referenced this issue Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant