跳到內容
Crystal CodeDocs
繁繁體中文

安裝

最新的自包含發行版可以安裝在 Linux x64、Linux ARM64、macOS ARM64 或 Windows x64 上。安裝器會下載相符的標準發行資產 CrystalCode-<os>-<architecture>.zip,然後取代 ~/.crystal/binaries/code/ 中的完整發佈內容。

在 Linux 或 macOS 上,執行:

終端機視窗
curl --fail --location --show-error \
https://crystalcode.ink/install.sh | sh

在 Windows PowerShell 中:

終端機視窗
Invoke-RestMethod `
-Uri https://crystalcode.ink/install.ps1 | Invoke-Expression

若要在執行安裝器前檢查它,請先下載到檔案,再手動執行。

安裝器不會寫入憑證。在 Linux 和 macOS 上,安裝器會向所選的 zsh 或 bash 設定檔加入一個 # Crystal Code CLI (Installer) 區塊。該區塊會將 CrystalCode 目錄加入 PATH,並把 crystal 別名到 CrystalCode。在 Windows 上,安裝器會將該目錄加入使用者層級 PATH。安裝後開啟新的終端機,然後在 Linux 或 macOS 上執行 crystal,在 Windows 上執行 CrystalCode。

推薦使用 Linux 和 macOS。在 Windows 上,請安裝 Git for Windows,以便 Git Bash 在 PATH 中提供 bash。

  • 所選提供商的 API 金鑰,放在 ~/.crystal/credentials.json,或僅用於一次啟動的行程環境變數中(見憑證)
  • 用於互動式替代畫面 UI 的 TTY。crystal run 不需要 TTY
  • PATH 中有 bash(在 Windows 上,存在 Git Bash 時會使用它)

從原始碼建置還需要:

  • .NET 10 或 .NET 11 SDK
  • 位於 ../Crystal 的 Crystal 同級檢出(相對於本儲存庫根目錄)

把兩個儲存庫複製到同一個上層目錄:

終端機視窗
git clone https://github.com/YELANDAOKONG/CrystalCode.git
git clone https://github.com/YELANDAOKONG/Crystal.git

所需的目錄配置、建置、測試和本地安裝步驟見從原始碼建置。

crystal version 和 crystal --version 印出建置身分並結束。它們不會開啟終端機,也不會讀取設定。

crystal plugins 和 crystal tools 列出、顯示、啟用或停用一個目錄。除非設定 --format text,否則它們印出 Spectre.Console 表格。它們不會開啟工作階段,也不會寫入 config.json。

crystal promptsets 和 crystal prompt-attachments 對 prompt.json 做同樣的事。提示集僅限 Home:list、show、enable 和 disable 接受 --home 和 --format text。啟用一個集會關閉其他集。提示附件還接受 --workspace 和 --source home|project。這兩個命令都不會建立缺少的目錄,也不會寫入 config.json。

Crystal Code 3f2a1b0c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a
Crystal 1a2b3c4d5e6f708192a3b4c5d6e7f8091a2b3c4d
SDK 10.0.201
Configuration Debug
Runtime .NET 10.0.4
OS Ubuntu 24.04.2 LTS x64

Crystal Code 是本儲存庫的提交。Crystal 是 Crystal 程式庫儲存庫的提交。SDK 是編譯該執行檔的 .NET SDK。Configuration 是記錄在執行檔上的 MSBuild 組態,通常是 Debug 或 Release。空行會將該建置與行程主機分開。Runtime 是裝載此行程的共用框架。OS 是執行階段的作業系統描述加上架構。某個值未記錄時會省略該行,空區段會連同空行一起省略。上面的提交、SDK 版本、組態、執行階段和作業系統都是範例。