Where is icr?

Hi, I just installed Crystal on Ubuntu via Snap as instructed in the howto (sudo snap install crystal --classic).

I wanted to fire up icr, but it is not found. Where is it?

Are you talking about GitHub - crystal-community/icr: Interactive console for Crystal programming language or Crystal's interpreter – A very special holiday present - The Crystal Programming Language?

You should use ic instead.


I mean the equivalent to irb of Ruby, i.e. the command line interactive interpreter. Is no such thing included in Crystal? I believe it should, so that newbies like me could start tinkering right after installation of Crystal.
Also I don’t want to install random stuff of Github, etc. isnt’t there some ‘official’ way to get icr or ic, e.g. over a chrystal repository at Debian/Linux or at least snapcraft, etc.?

There is such a thing, but it’s considered experiential still so might not be enabled by default depending on how you install it. Crystal's interpreter – A very special holiday present - The Crystal Programming Language has some more information, but you can test by doing $ crystal i. If it works, then you have it. Otherwise you’ll have to build from source most likely.

1 Like

ic is totally same as official Crystal intepreter, but, you don’t need build Crystal from source code anyway. (although you still need build ic from scratch use crystal source code), some feature (like highlight, C-n/C-p keybinding support) was merged into Crystal too.

But use ic still preferred for me because following reason:

  1. You don’t need recompile compiler with interpreter support
  2. Experience new feature from ic (and more quickly response and feature from maintainer)
  3. start Crystal interpreter instantly. (compare to crystal i, it will spent 1.5~2 seconds on my laptop)

Thanks for the info! Unfortunately with the installation I got on Ubuntu via Snap what I got is:

➜  2023 crystal i
Crystal was compiled without interpreter support

Just compile ic following README, and use it instead, otherwise, you need recompile compiler yourself.