Installing Crystal on Your Machine

You can find detailed installation instructions and remarks for the various Linux distros, OS X, and Windows on this page.[122]

The easiest way to get up and running with a stable version is to download the binary installer[123] for your platform. Simply unzip it and add the folder with the binary executable (e.g., /usr/bin/crystal on Linux) to your path.

Installing Crystal for Mac OS X users is a breeze, thanks to Homebrew.

$ brew update

$ brew install crystal

To update to a newer version, you do the following:

$ brew update

$ brew upgrade crystal-lang

Now let’s follow the steps for a Debian/Ubuntu installation, which uses the official Crystal repository. (The procedure is very similar for other Linux-based systems.) Debian doesn’t (yet) know about Crystal by default, so first, add the repository to your software installer:

$ curl https://dist.crystal-lang.org/apt/setup.sh | sudo bash

If you have concerns about the security of this command, you can instead execute the following commands as root:

$ curl -sL "https://keybase.io/crystal/pgp_keys.asc" | sudo apt-key add -

$ echo "deb https://dist.crystal-lang.org/apt crystal main" | sudo tee /etc/apt/sources.list.d/crystal.list

$ apt-get update

Install the stable Crystal version with:

$ sudo apt install crystal

That’s all there is to it! Upgrading to a newer version will probably happen when you update your system generally. If not, do the following:

$ sudo apt-get update

and repeat the install step.

Note that at the time of this writing, the complete Windows port is a work in progress. For now, you can run Crystal only on Windows 10 through Bash, so you have to install the Linux subsystem and run your Crystal program in it. Here[124] is an easy way to get started. (You might want to install the Linux libraries mentioned here.[125] They are needed to run the Crystal Playground.)

If you really want to get into examining Crystal and contributing, clone the source code[126] and compile it with a previous Crystal version. Look up the details here.[127]

Verify your installation by typing the following command at the terminal:

$ crystal –v or $ crystal --version

This shows that you the installed version—for example: Crystal 0.26.1 [391785249] (2018-08-27) LLVM: 4.0.0 Default target: x86_64-unknown-linux-gnu

Now you’re ready to go!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.0.145