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

Support Tauri #20738

Open
birkskyum opened this issue Sep 29, 2023 · 15 comments
Open

Support Tauri #20738

birkskyum opened this issue Sep 29, 2023 · 15 comments
Labels
bug Something isn't working correctly node compat

Comments

@birkskyum
Copy link
Contributor

Tauri - Website - GitHub

Platform

Darwin 23.0.0 arm64 arm

Version

deno 1.37.1

Repro

  • deno run -A npm:create-tauri-app
    • Select i.e. Typescript, Solid
  • deno run -A npm:tauri dev

Expected

I.e. npx tauri dev gives:

➜ npx tauri dev     
     Running BeforeDevCommand (`npm run dev`)

> [email protected] dev
> vite
  VITE v4.4.9  ready in 227 ms

  ➜  Local:   http://localhost:1420/
  ➜  Network: use --host to expose
        Info Watching /Users/admin/repos/tauri-test/create-tauri-app/src-tauri for changes...
   Compiling create-tauri-app v0.0.0 (/Users/admin/repos/tauri-test/create-tauri-app/src-tauri)

    Finished dev [unoptimized + debuginfo] target(s) in 0.68s

Actual

➜ deno run -A npm:tauri dev
error: package 'tauri' did not have a bin property in its package.json
@bartlomieju bartlomieju added bug Something isn't working correctly node compat labels Oct 9, 2023
@denyncrawford
Copy link

Any update?

@ninjadev64
Copy link

I'm in a Tauri setup with a SvelteKit frontend. Deno is panicking with this backtrace.

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.43.6
Args: ["/home/aman/.deno/bin/deno", "run", "-A", "npm:[email protected]", "dev"]

thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/notify-5.0.0/src/inotify.rs:596:32:
called `Result::unwrap()` on an `Err` value: "SendError(..)"
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <notify::inotify::INotifyWatcher as notify::Watcher>::watch
   4: deno_runtime::ops::fs_events::op_fs_events_open::op_fs_events_open::v8_fn_ptr
   5: Builtins_CallApiCallbackOptimizedNoProfiling
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Deno v1.43.6
Rustc v1.78.0
Tauri v1.6.6
Vite v5.2.11

@birkskyum
Copy link
Contributor Author

birkskyum commented May 30, 2024

I upgraded to Deno 1.44 to assess if it was feasible for me to use deno for tauri now, because this is one of the tickets relying on binaries and hoped this would help:

this is what I get

➜ DENO_FUTURE=1 deno install npm:tauri
⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
Add tauri - npm:tauri@^0.15.0
error: Can't set up 'vite' bin at ../.deno/[email protected]/node_modules/vite/bin/vite.js

Caused by:
    File exists (os error 17)

and

➜ DENO_FUTURE=1 deno run npm:tauri dev
error: '/Users/admin/repos/deno-kitchensink/create-tauri-app/node_modules/.deno/[email protected]/node_modules/tauri/package.json' did not have a bin property

@birkskyum
Copy link
Contributor Author

With the binary install resolved, this seems to mainly be a matter of confusion/mess with the DENO_FUTURE=1 and the npm:tauri. For instance, the package scripts has an entry called "tauri": "tauri", and it doesn't work well with DENO_FUTURE=1 deno task tauri dev, and DENO_FUTURE=1 deno run npm:tauri.

@birkskyum
Copy link
Contributor Author

birkskyum commented Sep 15, 2024

For Deno 2 rc.2 + Tauri 1, things run as expected, except the "Greet" button in the demo, it'll give this console error:

@tauri-apps_api_tauri.js?v=152d049d:30 Uncaught (in promise) TypeError: window.__TAURI_IPC__ is not a function
    at @tauri-apps_api_tauri.js?v=152d049d:30:12
    at new Promise (<anonymous>)
    at invoke (@tauri-apps_api_tauri.js?v=152d049d:21:10)
    at greet (main.ts:9:36)
    at HTMLFormElement.<anonymous> (main.ts:20:5)

@birkskyum
Copy link
Contributor Author

birkskyum commented Sep 15, 2024

@birkskyum
Copy link
Contributor Author

birkskyum commented Sep 16, 2024

With deno2 rc + tauri2 rc:

Note: For creation npm is needed, because of cli issues passing --rc flag to deno run:

npm create tauri-app@latest -- --rc
deno install
deno task dev

Error in console

@tauri-apps_api_core.js?v=1934d98c:89 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'invoke')
    at invoke (@tauri-apps_api_core.js?v=1934d98c:89:37)
    at greet (App.tsx:12:23)
    at HTMLFormElement.<anonymous> (App.tsx:37:11)

@adminy
Copy link

adminy commented Oct 7, 2024

Does it work now? Sounds like tauri apps is not deno compatible from the error message. The rust bindings is probably specific to node.

What are the benefits of using deno for this? Can I still use pnpm as the package manager?

@ninjadev64
Copy link

Does it work now? Sounds like tauri apps is not deno compatible from the error message. The rust bindings is probably specific to node.

I use it just fine. There are no Rust bindings in Tauri (apart from the CLI), it is all IPC.

What are the benefits of using deno for this? Can I still use pnpm as the package manager?

You can see the benefits of Deno on its website. You shouldn't use pnpm with Deno.

@phoenisx
Copy link

phoenisx commented Oct 9, 2024

@ninjadev64 how is it working for u?

I use it just fine.

For me deno task dev still doesn't work, and failing because of the tauri cli/bin script

@phoenisx
Copy link

phoenisx commented Oct 9, 2024

The only way I see to make deno work with tauri is to write custom dev script to run tauri cli or start the vite dev server using a custom deno script.

I've never tried building the app yet, so not sure if above custom script will be sufficient to make things work with Tauri builds.

@ninjadev64
Copy link

ninjadev64 commented Oct 9, 2024

In my package.json I have the normal vite dev, build and preview scripts. In my tauri.conf.json I have the beforeDevCommand or whatever it is as deno task dev. Then cargo tauri dev and it works.

@phoenisx
Copy link

phoenisx commented Oct 9, 2024

Thanks for sharing.
I think it should work with cargo tauri dev with the changes u described above, but I am not able to run cargo tauri dev on my linux machine. It keeps on throwing no such command: tauri error
I couldn't find any details in the documentation either

No worries, I found a solution somewhere in the tauri issues. We first need to install tauri-cli, i.e. run cargo install tauri-cli to run the tauri cli commands using cargo.


Following steps works for me:

cargo install create-tauri-app tauri-cli --locked
cargo create-tauri-app foo
cd foo
deno install

# Ensure u update tauri.conf.json to use deno commands, i.e.
# change to the following:
# "beforeDevCommand": "deno task dev",
# "beforeBuildCommand": "deno task build",
# and then run the following command

cargo tauri dev # from repo's root directory.

@ninjadev64
Copy link

I believe this issue can be closed.

amrbashir added a commit to tauri-apps/tauri that referenced this issue Oct 10, 2024
amrbashir added a commit to tauri-apps/tauri that referenced this issue Oct 10, 2024
@birkskyum
Copy link
Contributor Author

birkskyum commented Oct 10, 2024

@ninjadev64 , when I made this ticket, it was all Tauri 1 + Deno 1. Now both Tauri and Deno are stable in v2, and I think there is still a few tweaks needed, but let's focus on ensuring that this forward-looking combination works.

lucasfernog added a commit to tauri-apps/tauri that referenced this issue Oct 11, 2024
* feat: add deno support

ref: denoland/deno#20738

* Update packages_nodejs.rs

* typo

---------

Co-authored-by: Lucas Nogueira <[email protected]>
lucasfernog added a commit to tauri-apps/tauri that referenced this issue Oct 11, 2024
* feat(cli): add deno support

ref: denoland/deno#20738

* Update packages_nodejs.rs

* typo

---------

Co-authored-by: Lucas Nogueira <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

No branches or pull requests

6 participants