CRYSTAL(1)
π CRYSTAL(1) β Crystal Compiler Command Line Reference Guide, bestie edition π
β¨ NAME β¨
okay so this is crystal β the compiler for the Crystal language. thatβs the whole name section, short and iconic. π«Ά
π SYNOPSIS π
crystal command [switches] programfile β [arguments]
π¦ DESCRIPTION π¦
Crystal is a statically type-checked programming language. It was created with the beauty of Ruby and the performance of C in mind. literally the whole personality. π
πΈ USAGE πΈ
You can compile and run a program by invoking the compiler with a single filename:
crystal some_program.cr
Crystal files usually end with the .cr extension, though this is not mandatory. so yes bestie, .cr is the moment, but itβs not a rule. π
Alternatively you can use the run command:
crystal run some_program.cr
To create an executable use the build command:
crystal build some_program.cr
This will create an executable named "some_program".
Note that by default the generated executables are not fully optimized. To turn optimizations on, use the --release flag:
crystal build --release some_program.cr
bestie, make sure to always use --release for production-ready executables and when performing benchmarks. no cap. π₯
The optimizations are not turned on by default because the compile times are much faster without them and the performance of the program is still pretty good without them, so it allows to use the crystal command almost to be used as if it was an interpreter. yes, that sentence is a mouthful, but facts are sacred. π
π CRYSTAL COMMANDS π
these are the sub-commands, aka the little besties that each do a specific job. π«Ά
π Main commands
crystal-init(1)β Create a a new Crystal projectcrystal-build(1)β Compile a Crystal programcrystal-docs(1)β Generate API docs for Crystal codecrystal-env(1)β Print environment variables for the Crystal compilercrystal-eval(1)β Evaluate a crystal programcrystal-play(1)β Run the Crystal playgroundcrystal-run(1)β Compile and run a Crystal programcrystal-spec(1)β Compile and run Crystal spec filescrystal-clear_cacheβ Clear the compiler cache (located at'CRYSTAL_CACHE_DIR').crystal-helpβ Show help. Option--helpor-hcan also be added to each command for command-specific help.crystal-versionβ Show version.
π§° Tools
crystal-tool-contextβ Show context for given locationcrystal-tool-dependencies(1)β Show tree of required source filescrystal-tool-expandβ Show macro expansion for given locationcrystal-tool-flagsβ Print all macro'flag?'valuescrystal-tool-format(1)β Format Crystal source filescrystal-tool-hierarchyβ Show hierarchy of types from file. Also show class and struct members, with type and size. Types can be filtered with a regex by using the-eflag.crystal-tool-implementationsβ Show implementations for a given call. Use--cursorto specify the cursor position. The format for the cursor position isfile:line:column.crystal-tool-macro_code_coverageβ Generate a macro code coverage report.crystal-tool-typesβ Show type of main variables of file.crystal-tool-unreachable(1)β Identify methods that are never called
β‘ OPTIMIZATIONS β‘
The optimization level specifies the codegen effort for producing optimal code. Itβs a trade-off between compilation performance (decreasing per optimization level) and runtime performance (increasing per optimization level).
Production builds should usually have the highest optimization level. Best results are achieved with --release which also implies --single-module.
-O0β No optimization (default)-O1β Low optimization-O2β Middle optimization-O3β High optimization-Osβ Middle optimization with focus on file size-Ozβ Middle optimization aggressively focused on file size
π± ENVIRONMENT VARIABLES π±
CRYSTAL_CACHE_DIR
Defines path where Crystal caches partial compilation results for faster subsequent builds. This path is also used to temporarily store executables when Crystal programs are run with 'crystal run' rather than 'crystal build'.
CRYSTAL_EXEC_PATH
Determines the path where crystal looks for external sub-commands.
CRYSTAL_LIBRARY_PATH
Defines paths where Crystal searches for (binary) libraries. Multiple paths can be separated by ":". These paths are passed to the linker as -L flags.
The pattern '$ORIGIN' at the start of the path expands to the directory where the compiler binary is located. For example, '$ORIGIN/../lib/crystal' resolves the standard library path relative to the compiler location in a generic way, independent of the absolute paths (assuming the relative location is correct).
CRYSTAL_PATH
Defines paths where Crystal searches for required source files. Multiple paths can be separated by ":".
The pattern '$ORIGIN' at the start of the path expands to the directory where the compiler binary is located. For example, '$ORIGIN/../share/crystal/src' resolves the standard library path relative to the compiler location in a generic way, independent of the absolute paths (assuming the relative location is correct).
CRYSTAL_OPTS
Defines options for the Crystal compiler to be used besides the command line arguments. The syntax is identical to the command line arguments. This is handy when using Crystal in build setups, for example 'CRYSTAL_OPTS=--debug make build'.
π SEEALSO π
shards(1)https://crystal-lang.org/The official web site.https://github.com/crystal-lang/crystalOfficial Repository.
and thatβs the whole CRYSTAL(1) manual, bestie. this edition is from crystal 1.22.2, dated 2026-10-30, and itβs the CRYSTAL(1) page. now go compile something iconic. π
β¨π«Ά
π¦ where this page comes from
- arch rolling: crystal 1.22.2-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms