How to get system and architecture?

The constant Crystal::TARGET_TRIPLE provides the target triple which the program is built for.

(Unfortuntately, the constant does not show up in the API docs, see Fix generate docs for builtins `HOST_TRIPLE` and `TARGET_TRIPLE` by straight-shoota · Pull Request #14570 · crystal-lang/crystal · GitHub)

Note that the compile-time target triple is not necessarily an accurate representation of the runtime system due to cross-execution capabilities. I.e. an exectuable could be built for one target but can still be able to run on different ones.

2 Likes