Manjaro Rust環境搭建


系統基本設置

更換為國內源

使用國內的源有更快的下載速度,pacman能夠測試不同源的速度並排名,我選擇的是上海交大sjtu的源。

sudo pacman-mirrors -i -c China -m rank
sudo pacman -Syy
sudo pacman -Syyu

添加arch源

編輯/etc/pacman.conf文件,加入下面的內容:

[archlinuxcn]
SigLevel = Optional TrustedOnly
Server = https://mirrors.sjtug.sjtu.edu.cn/archlinux-cn/$arch

然后

sudo pacman -Syy && sudo pacman -S archlinuxcn-keyring

現在可以全面升級系統:

sudo pacman -Su

輸入法

安裝fcitx和搜狗拼音輸入法:

sudo pacman -S fcitx-sogoupinyin
sudo pacman -S fcitx-im
sudo pacman -S fcitx-configtool

設置環境變量,在~/.xprofile文件(如果文件不存在就新建一個)末尾加上:

export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"

Fcitx配置

常用軟件

sudo pacman -S yay                     # AUR助手
sudo pacman -S google-chrome           # 最流行的瀏覽器
sudo pacman -S clang make cmake gdb    # 編譯調試環境
sudo pacman -S visual-studio-code-bin  # 牛逼的編輯器
sudo pacman -S vim                     # 命令行下的編輯器
sudo pacman -S qtcreator               # IDE for Qt
sudo pacman -S wireshark-qt            # 抓包工具
sudo pacman -S git                     # 版本管理工具
sudo pacman -S octave                  # Matlab的開源替代

Rust

下載Rust

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

之后配置環境,

vim  ~/.bashrc 

在最后加入

export PATH=$PATH:$home/.caogo/bin
export PATH=$PATH:$home/.cargo/env

之后reboot就可以了

輸入rustc --version和cargo查看是否安裝成功

修改Rust Crates 源

在 $HOME/.cargo/config 中添加如下內容:

[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

VSCode

擴展安裝:Rust

 VSCode 中設置 rust-client.channel 為 stable。 同時建議設置 editor.formatOnSave 為 true,以便在保存時使用 rust-fmt 格式化代碼。

Manjaro安裝 Rust 輔助工具

cargo

# 編譯工具
rustup install nightly
# 實現代碼自動補齊
cargo +nightly install racer
# 由於以下工具默認安裝里存在占位程序,需要使用 --force 選項強制安裝
cargo install --force rustfmt
cargo install --force rls

rustup

rustup component add rls-preview
rustup component add rust-analysis
rustup component add rust-src

依次選擇Tasks->Run Task,根據提示可以執行Rust: cargo build,Rust: cargo run等操作

GitHub連接

# 生成ssh
ssh-keygen -t rsa -C "youremail@example.com"
# ...略github后台配置
# 添加ssh
ssh-agent -s
ssh-add ~/.ssh/ssh_private_filename
# 測試
ssh -v git@github.com

Git設置

git config --global user.name "Your Name"
git config --global user.email "email@example.com"

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM