{"id":129,"date":"2025-08-30T20:53:16","date_gmt":"2025-08-30T12:53:16","guid":{"rendered":"https:\/\/caoxunyi.cn\/?p=129"},"modified":"2025-08-30T20:53:16","modified_gmt":"2025-08-30T12:53:16","slug":"arch-linux-%e4%b8%8b-rust-%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%e5%ae%89%e8%a3%85%e4%b8%8e%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/caoxunyi.cn\/index.php\/129\/","title":{"rendered":"Arch Linux \u4e0b Rust \u5f00\u53d1\u73af\u5883\u5b89\u88c5\u4e0e\u914d\u7f6e\u6307\u5357"},"content":{"rendered":"<p>\u672c\u6587\u6863\u65e8\u5728\u4e3a Arch Linux \u7528\u6237\u63d0\u4f9b\u4e00\u4efd\u6e05\u6670\u3001\u5b8c\u6574\u7684 Rust \u5f00\u53d1\u73af\u5883\u642d\u5efa\u6307\u5357\uff0c\u6db5\u76d6\u4ece\u8bed\u8a00\u672c\u8eab\u7684\u5b89\u88c5\u5230\u4ee3\u7801\u7f16\u8f91\u5668\u7684\u914d\u7f6e\u3002<\/p>\n<h2>\u6838\u5fc3\u7406\u5ff5<\/h2>\n<p>\u73b0\u4ee3 Rust \u5f00\u53d1\u73af\u5883\u7684\u6838\u5fc3\u7531\u4e24\u90e8\u5206\u6784\u6210\uff1a<\/p>\n<ol>\n<li><strong><code>rustup<\/code><\/strong>: \u5b98\u65b9\u7684 Rust \u5de5\u5177\u94fe\u7ba1\u7406\u5668\uff0c\u7528\u4e8e\u5b89\u88c5\u548c\u7ba1\u7406 Rust \u7f16\u8bd1\u5668 (<code>rustc<\/code>) \u548c\u5305\u7ba1\u7406\u5668 (<code>cargo<\/code>)\u3002<\/li>\n<li><strong><code>rust-analyzer<\/code><\/strong>: \u5b98\u65b9\u7684\u8bed\u8a00\u670d\u52a1\u5668 (LSP)\uff0c\u4e3a\u4ee3\u7801\u7f16\u8f91\u5668\u63d0\u4f9b\u667a\u80fd\u63d0\u793a\u3001\u9519\u8bef\u68c0\u67e5\u7b49\u9ad8\u7ea7\u529f\u80fd\u3002<\/li>\n<\/ol>\n<h2>\u7b2c\u4e00\u90e8\u5206\uff1a\u5b89\u88c5 Rust \u5de5\u5177\u94fe (<code>rustup<\/code>)<\/h2>\n<p>\u6211\u4eec\u91c7\u7528\u5b98\u65b9\u6700\u63a8\u8350\u7684 <code>rustup<\/code> \u65b9\u5f0f\u6765\u5b89\u88c5 Rust\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u65e0\u4e0e\u4f26\u6bd4\u7684\u7075\u6d3b\u6027\u3002<\/p>\n<h3>1. \u8fd0\u884c\u5b89\u88c5\u811a\u672c<\/h3>\n<p>\u9996\u5148\uff0c\u786e\u4fdd\u7cfb\u7edf\u5df2\u5b89\u88c5 <code>curl<\/code> \u548c <code>base-devel<\/code> \u5305\u7ec4\u3002\u7136\u540e\uff0c\u5728\u7ec8\u7aef\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>Bash<\/p>\n<pre><code># \u786e\u4fdd\u6838\u5fc3\u7f16\u8bd1\u5de5\u5177\u5df2\u5b89\u88c5\nsudo pacman -S base-devel curl\n\n# \u8fd0\u884c rustup \u5b98\u65b9\u5b89\u88c5\u811a\u672c\ncurl --proto '=https' --tlsv1.2 -sSf https:\/\/sh.rustup.rs | sh<\/code><\/pre>\n<p>\u5728\u51fa\u73b0\u7684\u4ea4\u4e92\u63d0\u793a\u4e2d\uff0c\u76f4\u63a5\u6309 <code>Enter<\/code> \u9009\u62e9\u9ed8\u8ba4\u9009\u9879 <code>1<\/code> \u7ee7\u7eed\u5b89\u88c5\u3002<\/p>\n<h3>2. \u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h3>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9700\u8981\u8ba9\u5f53\u524d Shell \u52a0\u8f7d Rust \u7684\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<p>Bash<\/p>\n<pre><code>source &quot;$HOME\/.cargo\/env&quot;<\/code><\/pre>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u4e3a\u4e86\u8ba9\u914d\u7f6e\u6c38\u4e45\u751f\u6548\uff0c\u8bf7<strong>\u5173\u95ed\u5e76\u91cd\u65b0\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u7a97\u53e3<\/strong>\u3002<\/p>\n<h3>3. \u9a8c\u8bc1\u5b89\u88c5<\/h3>\n<p>\u5728\u65b0\u7ec8\u7aef\u4e2d\uff0c\u68c0\u67e5 <code>rustc<\/code> \u548c <code>cargo<\/code> \u7684\u7248\u672c\u4ee5\u786e\u8ba4\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p>Bash<\/p>\n<pre><code>rustc --version\n# \u793a\u4f8b\u8f93\u51fa: rustc 1.79.0 (129f3b996 2024-06-10)\n\ncargo --version\n# \u793a\u4f8b\u8f93\u51fa: cargo 1.79.0 (ffa9cf99a 2024-06-04)<\/code><\/pre>\n<h3>4. \u5b89\u88c5\u6838\u5fc3\u7ec4\u4ef6<\/h3>\n<p>\u4e3a\u4e86\u83b7\u5f97\u5b8c\u6574\u7684\u5f00\u53d1\u4f53\u9a8c\uff08\u4ee3\u7801\u63d0\u793a\u3001\u683c\u5f0f\u5316\u3001\u9759\u6001\u5206\u6790\uff09\uff0c\u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u51e0\u4e2a\u6838\u5fc3\u7ec4\u4ef6\uff1a<\/p>\n<p>Bash<\/p>\n<pre><code>rustup component add rust-analyzer clippy rustfmt<\/code><\/pre>\n<ul>\n<li><strong><code>rust-analyzer<\/code><\/strong>: \u8bed\u8a00\u670d\u52a1\u5668\u540e\u7aef\uff0c\u4f9b VS Code \u7b49\u7f16\u8f91\u5668\u4f7f\u7528\u3002<\/li>\n<li><strong><code>clippy<\/code><\/strong>: \u5f3a\u5927\u7684\u9759\u6001\u4ee3\u7801\u5206\u6790\u5de5\u5177\u3002<\/li>\n<li><strong><code>rustfmt<\/code><\/strong>: \u5b98\u65b9\u4ee3\u7801\u683c\u5f0f\u5316\u5de5\u5177\u3002<\/li>\n<\/ul>\n<h2>\u7b2c\u4e8c\u90e8\u5206\uff1a\u914d\u7f6e Visual Studio Code (VS Code)<\/h2>\n<p>VS Code \u662f Rust \u793e\u533a\u6700\u4e3b\u6d41\u7684\u4ee3\u7801\u7f16\u8f91\u5668\u3002<\/p>\n<h3>1. \u5b89\u88c5 VS Code<\/h3>\n<p>\u5728 Arch Linux \u4e0a\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u5f00\u6e90\u6784\u5efa\u7248\u6216\u5fae\u8f6f\u5b98\u65b9\u7248\u3002\u63a8\u8350\u4f7f\u7528 AUR \u4e2d\u7684\u5b98\u65b9\u7248\uff0c\u56e0\u4e3a\u5b83\u80fd\u63d0\u4f9b\u6700\u5b8c\u6574\u7684\u4f53\u9a8c\u3002<\/p>\n<p>Bash<\/p>\n<pre><code># \u5b89\u88c5 AUR \u52a9\u624b, \u5982 yay (\u5982\u679c\u5df2\u5b89\u88c5\u53ef\u8df3\u8fc7)\nsudo pacman -S yay\n\n# \u4f7f\u7528 yay \u5b89\u88c5 VS Code \u5b98\u65b9\u4e8c\u8fdb\u5236\u7248\nyay -S visual-studio-code-bin<\/code><\/pre>\n<h3>2. \u5b89\u88c5 VS Code \u6269\u5c55<\/h3>\n<p>\u542f\u52a8 VS Code\uff0c\u6253\u5f00\u6269\u5c55\u89c6\u56fe (<code>Ctrl+Shift+X<\/code>)\uff0c\u641c\u7d22\u5e76\u5b89\u88c5\u4ee5\u4e0b\u6269\u5c55\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6269\u5c55\u540d<\/th>\n<th>\u53d1\u5e03\u8005<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong><code>rust-analyzer<\/code><\/strong><\/td>\n<td>The Rust Programming Language<\/td>\n<td><strong>\u6838\u5fc3\u6269\u5c55<\/strong>\u3002\u8fde\u63a5 <code>rust-analyzer<\/code> \u540e\u7aef\uff0c\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u3001\u8bca\u65ad\u3001\u8df3\u8f6c\u7b49\u529f\u80fd\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong><code>CodeLLDB<\/code><\/strong><\/td>\n<td>Vadim Chugunov<\/td>\n<td><strong>\u5f3a\u70c8\u63a8\u8350<\/strong>\u3002\u63d0\u4f9b\u5f3a\u5927\u7684\u4ee3\u7801\u8c03\u8bd5\u529f\u80fd\uff0c\u652f\u6301\u8bbe\u7f6e\u65ad\u70b9\u3001\u5355\u6b65\u6267\u884c\u7b49\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong><code>crates<\/code><\/strong><\/td>\n<td>Seray Uzgur<\/td>\n<td><strong>\u63a8\u8350<\/strong>\u3002\u65b9\u4fbf\u5730\u68c0\u67e5 <code>Cargo.toml<\/code> \u4e2d\u4f9d\u8d56\u7684\u7248\u672c\u4fe1\u606f\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong><code>Even Better TOML<\/code><\/strong><\/td>\n<td>tamasfe<\/td>\n<td><strong>\u63a8\u8350<\/strong>\u3002\u4e3a <code>Cargo.toml<\/code> \u6587\u4ef6\u63d0\u4f9b\u66f4\u597d\u7684\u8bed\u6cd5\u9ad8\u4eae\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u7b2c\u4e09\u90e8\u5206\uff1a\u5de5\u4f5c\u6d41\u6f14\u793a - \u521b\u5efa\u5e76\u8fd0\u884c\u9879\u76ee<\/h2>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u9879\u76ee<\/strong>\uff1a<\/p>\n<p>Bash<\/p>\n<pre><code>cargo new my_first_rust_app<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u5728 VS Code \u4e2d\u6253\u5f00<\/strong>\uff1a<\/p>\n<p>Bash<\/p>\n<pre><code>cd my_first_rust_app\ncode .<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u7f16\u7801\u4e0e\u8fd0\u884c<\/strong>\uff1a<\/p>\n<ul>\n<li>\u6253\u5f00 <code>src\/main.rs<\/code> \u6587\u4ef6\uff0c\u5373\u53ef\u4f53\u9a8c <code>rust-analyzer<\/code> \u5e26\u6765\u7684\u667a\u80fd\u63d0\u793a\u3002<\/li>\n<li>\u6309 `Ctrl+`` \u6253\u5f00 VS Code \u7684\u96c6\u6210\u7ec8\u7aef\u3002<\/li>\n<li>\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165 <code>cargo run<\/code> \u7f16\u8bd1\u5e76\u8fd0\u884c\u4f60\u7684\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5<\/strong>\uff1a<\/p>\n<ul>\n<li>\u5728\u4ee3\u7801\u884c\u53f7\u5de6\u4fa7\u5355\u51fb\u8bbe\u7f6e\u65ad\u70b9\u3002<\/li>\n<li>\u6309 <code>F5<\/code> \u6216\u5207\u6362\u5230\u201c\u8fd0\u884c\u548c\u8c03\u8bd5\u201d\u89c6\u56fe\u70b9\u51fb\u7eff\u8272\u7bad\u5934\uff0c<code>CodeLLDB<\/code> \u5c06\u542f\u52a8\u8c03\u8bd5\u4f1a\u8bdd\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<p>\u9075\u5faa\u672c\u6307\u5357\uff0c\u60a8\u5c06\u642d\u5efa\u8d77\u4e00\u5957\u529f\u80fd\u5b8c\u5907\u3001\u4f53\u9a8c\u4e00\u6d41\u7684 Rust \u5f00\u53d1\u73af\u5883\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u6863\u65e8\u5728\u4e3a Arch Linux \u7528\u6237\u63d0\u4f9b\u4e00\u4efd\u6e05\u6670\u3001\u5b8c\u6574\u7684 Rust \u5f00\u53d1\u73af\u5883\u642d\u5efa\u6307\u5357\uff0c\u6db5\u76d6\u4ece\u8bed\u8a00\u672c\u8eab\u7684\u5b89\u88c5\u5230\u4ee3\u7801\u7f16\u8f91\u5668\u7684\u914d\u7f6e\u3002 &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[9],"tags":[10],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-rust","tag-rust"],"_links":{"self":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":1,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":130,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/129\/revisions\/130"}],"wp:attachment":[{"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/caoxunyi.cn\/index.php\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}