পাঠ ১.১

Rust install করা

Installation

এই পাঠে আমরা rustup দিয়ে Rust toolchain install করব। Linux, macOS, এবং Windows — তিনটি platform-এর জন্যই step আলাদা করে দেখানো হলো।

rustup কী?

rustup হলো Rust-এর official toolchain manager — এটা rustc (compiler), cargo (build tool ও package manager), এবং অন্যান্য component install ও update করার দায়িত্বে থাকে। Rust-এর নতুন version বেরোলে শুধু rustup update চালালেই হবে — তোমাকে আবার installer download করতে হবে না।

এই পাঠে যে command-গুলো দেখাবো, সেগুলোতে terminal-এর prompt-হিসেবে $ বা > ব্যবহার করা হবে। এই চিহ্নটা type করতে হবে না — এটা শুধু বোঝায় যে এরপরের অংশটা তোমার type করার কথা। যেসব line-এর শুরুতে prompt নেই, সেগুলো command-এর output।

Linux বা macOS-এ install করা

Terminal খুলে নিচের command চালাও — এটা rustup-এর install script download করে চালাবে:

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

Script-টা তোমাকে কয়েকটা option জিজ্ঞেস করবে — default (1) Proceed with standard installation) বেছে নিলেই হবে। শেষে এই message দেখলে বুঝবে install successful হয়েছে:

terminal outputtext
Rust is installed now. Great!

Rust-এর কিছু crate compile করতে linker দরকার হয় (linker হলো compile-হওয়া object file-গুলোকে join করে final binary বানানোর tool)। সাধারণত system-এ আগে থেকেই থাকে, কিন্তু না থাকলে এই ভাবে install করো:

macOS-এ:

terminalbash
$ xcode-select --install

Ubuntu/Debian-এ:

terminalbash
$ sudo apt-get install build-essential

অন্যান্য Linux distribution-এ GCC বা Clang install করতে হবে — তোমার distribution-এর documentation দেখো।

Windows-এ install করা

Windows-এ install করতে rust-lang.org/tools/install page থেকে installer download করে on-screen instruction follow করো। কিছু সময় Visual Studio install করতে বলবে — Rust-এর linker এবং native library দরকার, তাই এটা install করতেই হবে। বিস্তারিত guide আছে rustup-এর Windows MSVC documentation-এ।

Install শেষ হলে cmd.exe বা PowerShell — দু'জায়গাতেই rust-এর command কাজ করবে।

Install verify করা

নতুন একটা terminal খুলে (পুরোনোটায় PATH update না-ও হতে পারে) এই command চালাও:

terminalbash
$ rustc --version

এই ধরনের output দেখলে বুঝবে সব ঠিক আছে:

terminal outputtext
rustc x.y.z (abcabcabc yyyy-mm-dd)

এখানে x.y.z হলো version number, পরের অংশটা সেই version-এর commit hash এবং তারিখ। তোমার দেখা output-এ এগুলো আলাদা হবে — সেটা স্বাভাবিক।

Command না পেলে — Troubleshoot

rustc: command not found error এলে বুঝতে হবে rustup ঠিকমতো PATH environment variable-এ নিজেকে যোগ করতে পারেনি। PATH check করো:

Linux / macOS:

terminalbash
$ echo $PATH

Windows CMD:

cmdbat
> echo %PATH%

Windows PowerShell:

PowerShellpowershell
> echo $env:Path

Output-এ ~/.cargo/bin (Linux/macOS) বা %USERPROFILE%\\.cargo\\bin (Windows) দেখা না গেলে terminal restart করো। তারপরও না হলে Rust community page থেকে সাহায্য নাও।

Update এবং uninstall

Rust-এর নতুন version এলে এই command দিয়ে update করো:

terminalbash
$ rustup update

সম্পূর্ণ uninstall করতে চাইলে:

terminalbash
$ rustup self uninstall

Local documentation

Rust install করার সময় তোমার machine-এ standard library-এর সম্পূর্ণ documentation-ও copy হয়ে যায়। Internet ছাড়াই browser-এ দেখতে পারবে:

terminalbash
$ rustup doc

কোনো type বা function নিয়ে confusion হলে এই docs-ই সবচেয়ে authoritative source — Rust-এর প্রতিটা stable API এখানে আছে।

এই পাঠ থেকে যা শিখলে

  • rustup হলো Rust toolchain manager — এটা rustccargo install ও update করে।
  • Linux/macOS-এ curl ... | sh command দিয়ে install হয়; Windows-এ rust-lang.org থেকে installer।
  • Linker (build-essential / Xcode CLT / Visual Studio) লাগে — Rust-এর জন্য আলাদা component।
  • rustc --version চালিয়ে install verify করতে হয়।
  • rustup update দিয়ে update, rustup self uninstall দিয়ে uninstall, rustup doc দিয়ে offline docs।