Tauri 実行時にエラー「Error failed to get project out directory: failed to get cargo metadata: No such file or directory (os error 2)」が発生した場合の対処法

Tauri 実行時にエラー「Error failed to get project out directory: failed to get cargo metadata: No such file or directory (os error 2)」が発生した場合の対処法

Tauriで実行時にエラー「Error failed to get project out directory: failed to get cargo metadata: No such file or directory (os error 2)」が発生した場合の対処法を記述してます。「rust」がインストールされていない場合に発生します。

環境

  • OS Ubuntu 22.10
  • Tauri 1.1

エラー全文

「yarn」環境で「yarn tauri dev」時に発生。

$ yarn tauri dev

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

  VITE v3.1.4  ready in 684 ms

  ➜  Local:   http://localhost:1420/
  ➜  Network: use --host to expose
       Error failed to get project out directory: failed to get cargo metadata: 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.

原因

「rust」がインストールされていなかったため

対処法

「rust」をインストールする

$ sudo dnf install -y gcc

$ curl https://sh.rustup.rs -sSf | sh

   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1 ← 1を選択

$ source "$HOME/.cargo/env"