Debian/Ubuntu

  1. curl https://dist.crystal-lang.org/apt/setup.sh | sudo bash
  2. apt-key adv --keyserver keys.gnupg.net --recv-keys 09617FD37CC06B54
  3. echo "deb https://dist.crystal-lang.org/apt crystal main" > /etc/apt/sources.list.d/crystal.list
  4. apt-get update
  5. sudo apt-get install crystal
  6. # 更新
  7. sudo apt-get update
  8. sudo apt-get install crystal

Redhat/Centos

  1. curl https://dist.crystal-lang.org/rpm/setup.sh | sudo bash
  2. rpm --import https://dist.crystal-lang.org/rpm/RPM-GPG-KEY
  3. cat > /etc/yum.repos.d/crystal.repo <<END
  4. [crystal]
  5. name = Crystal
  6. baseurl = https://dist.crystal-lang.org/rpm/
  7. END
  8. sudo yum install crystal
  9. #更新
  10. sudo yum update crystal

Arch

  1. sudo pacman -S crystal

Gentoo

  1. # equery u dev-lang/crystal
  2. [ Legend : U - final flag setting for installation]
  3. [ : I - package is installed with flag ]
  4. [ Colors : set, unset ]
  5. * Found these USE flags for dev-lang/crystal-0.18.7:
  6. U I
  7. - - doc : Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
  8. - - examples : Install examples, usually source code
  9. + + xml : Use the dev-libs/libxml2 library to enable Crystal xml module
  10. + - yaml : Use the dev-libs/libyaml library to enable Crystal yaml module
  11. su -
  12. emerge -a dev-lang/crystal

Mac-Osx

  1. brew update
  2. brew install crystal-lang

Linuxbrew

  1. brew update
  2. brew install crystal-lang

Ubuntu bash - windows

需要win10自带的Ubuntu环境, 安装方法同Ubuntu安装一样。

预编译文件安装

到此处 下载已编译好的二进制,把它放到环境变量的目录下就可以直接在命令行中运行。

源码安装

  1. git clone https://github.com/crystal-lang/crystal.git
  2. # 运行 make命令创建自己的crystal编译器
  3. # 运行 make spec命令测试新的版本是否存在错误
  4. # 使用 bin/crystal
  5. # 事实上 ,编译生成的crystal是 .build/crystal