もがき系プログラマの日常

もがき系エンジニアの勉強したこと、日常のこと、気になっている技術、備忘録などを紹介するブログです。

tauri触ってみた01

はじめに

なんとなくChatGPTと話してて、ふと、昔作ってみたいなーと思ってたデスクトップアプリをChatGPTに教わりながら作ってみようと思いました。

脳死でelectronで作るのかなぁと思っていたら Rust製のtauriとかいうツールが最近のモダンということらしいのでせっかくなのでそれで作ってみ用途思いました。

v2.tauri.app

本題

tauriインストール

$ npm create tauri-app@latest tauri_example01 -- --template vue-ts

✔ Identifier · example.tauri_example01
✔ Choose your package manager · yarn

Template created!

Your system is missing dependencies (or they do not exist in $PATH):
╭──────┬───────────────────────────────────────────────────────────────────╮
│ Rust │ Visit https://www.rust-lang.org/learn/get-started#installing-rust │
╰──────┴───────────────────────────────────────────────────────────────────╯

Make sure you have installed the prerequisites for your OS: https://tauri.app/start/prerequisites/, then run:
  cd tauri_example01
  yarn
  yarn tauri android init
  yarn tauri ios init

For Desktop development, run:
  yarn tauri dev

For Android development, run:
  yarn tauri android dev

For iOS development, run:
  yarn tauri ios dev
  
$ cd tauri_example01  
$ yarn        
yarn install v1.22.22
info No lockfile found.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 16.90s.

動作確認(失敗)

$ yarn tauri dev

yarn run v1.22.22
$ tauri dev
failed to run 'cargo metadata' command to get workspace directory: No such file or directory (os error 2)
       Error failed to run 'cargo metadata' command to get workspace directory: No such file or directory (os error 2)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Command failed: node /path/to/.yvm/versions/v1.22.22/bin/yarn.js tauri dev

エラーでた。

Rust入れてなかったです。

Rustインストール

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

.
..
...
Rust is installed now. Great!

$ source "$HOME/.cargo/env"
$ cargo -V      
cargo 1.89.0 (c24e10642 2025-06-23)

動作確認(成功)

$ yarn tauri dev
yarn run v1.22.22
$ tauri dev
     Running BeforeDevCommand (`yarn dev`)
$ vite

  VITE v6.3.5  ready in 154 ms

  ➜  Local:   http://localhost:1420/
     Running DevCommand (`cargo  run --no-default-features --color always --`)
        Info Watching /path/to/projects/study/tauri/tauri_example01/src-tauri for changes...
   Compiling tauri_example01 v0.1.0 (/path/to/projects/study/tauri/tauri_example01/src-tauri)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.93s
     Running `target/debug/tauri_example01`

終わりに

いったんここまで

次はgptさんに聞きながらとりあえずTODOアプリでも作ってみます。