为 Linux 设置
此设置仅用于开发。 Tauri 应用程序的使用者将不必执行任何这些操作。
此页面提供了安装 Tauri 及其依赖项的完整指南。 因为 Tauri 是一个多语言工具链并且涉及复杂的安装说明,我们希望确保任何人都能够通过阅读本指南来设置它,而无需打开其他文档。
初次之外,这里也有很好的技巧和工具。如果你从 Node.js 或 Rust 和安全性开始,它们将对您有所帮助。
: 这个步骤是必须的: 如果已经满足可以跳过这一步(例如你已经安装好了Node.js/Rust)
: 此步骤仅供参考
#
1. System Dependencies- Debian
- Arch
- Fedora
$ sudo apt update && sudo apt install libwebkit2gtk-4.0-dev \
build-essential \
curl \
wget \
libssl-dev \
libgtk-3-dev \
libappindicator3-dev \
patchelf \
librsvg2-dev
$ sudo pacman -Syy && sudo pacman -S webkit2gtk \
base-devel \
curl \
wget \
openssl \
appmenu-gtk-module \
gtk3 \
libappindicator-gtk3 \
patchelf \
librsvg \
libvips
$ sudo dnf check-update && sudo dnf install webkit2gtk3-devel.x86_64 \
openssl-devel \
curl \
wget \
libappindicator-gtk3 \ #
patchelf \
librsvg2-devel \
&& sudo dnf group install "C Development Tools and Libraries"
#
Optional dependencies:libappindicator
: needed to use the system tray feature.patchelf
andlibrsvg
: needed to bundleAppImage
.
#
2. Node.js Runtime and Package Manager#
Node.js (npm included)We recommend using nvm to manage your Node.js runtime. It allows you to easily switch versions and update Node.js.
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
Once nvm is installed, close and reopen your terminal, then install the latest version of Node.js and npm:
$ nvm install node --latest-npm
$ nvm use node
If you have any problems with nvm, please consult their project readme.
#
Optional Node.js Package ManagerYou may want to use an alternative to npm:
#
3. Rustc and Cargo Package ManagerThe following command will install rustup, the official installer for Rust.
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
To make sure that Rust has been installed successfully, run the following command:
$ rustc --version
latest update on 2019-12-19, rust version 1.40.0
You may need to restart your terminal if the command does not work.
#
4. For Windows Subsystem for Linux (WSL) UsersIn order to run a graphical application with WSL, you need to download one of these X servers: Xming, Cygwin X, and vcXsrv. Since vcXsrv has been used internally, it's the one we recommend to install.
#
WSL Version 1Open the X server and then run export DISPLAY=:0
in the terminal. You should now be able to run any graphical application via the terminal.
#
WSL Version 2You'll need to run a command that is slightly more complex than WSL 1: export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
and you need to add -ac
to the X server as an argument. Note: if for some reason this command doesn't work you can use an alternative command such as: export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | sed 's/.* //g'):0
or you can manually find the Address using cat /etc/resolve.conf | grep nameserver
.
Don't forget that you'll have to use the "export" command anytime you want to use a graphical application, for each newly opened terminal.
You can download some examples to try with sudo apt-get install x11-apps
. xeyes is always a good one. It can be handy when troubleshooting WSL issues.
#
ContinueNow that you have set up the Linux-specific dependencies for Tauri, learn how to add Tauri to your project.