Bad interpreter: /usr/bin/crystal: no such file or directory

if my file sh/hello contains:


p "hello world"

and I run sh/hello

  • it runs as expected on ubuntu
  • it returns zsh: sh/drop_all_tables: bad interpreter: /usr/bin/crystal: no such file or directory on OSX
  • crystal run sh/drop_all_tables runs as expected on OSX.


Edit: Solution:

this works as expected on both OSX and debian:

#!/usr/bin/env crystal

Well yea, "/usr/bin/crystal: no such file or directory on OSX" is certainly true. What’s your point?

I like things working

@oprypin is trying to tell you that /usr/bin/crystal is not there. You have to install it.

The main thing is that there isn’t any currently known installation method for macOS that will end up putting Crystal at that path.

You can certainly try #!/usr/bin/env crystal instead, but it would mostly just be frowned upon.

@InstanceOfMichael the position of the Crystal executable is different on Mac, try

$ which crystal

On my Mac returns /usr/local/bin/crystal
change the first line accordingly:


p "hello world"

For not having that problem remove the first line and save the file as a Crystal source file with a .cr suffix (e.g. and run it with

$ crystal run
that works on any os

I don’t think your sarcasm can help a newcomer to appreciate the language and the community.
I don’t know what @bcardiff, @asterite or other core team members think about that but I don’t think is in the spirit of “For humans and machine” motto…


@InstanceOfMichael You almost always want to use #!/usr/bin/env foo to avoid hardcoding the location of foo, as software may be installed into /usr/ or /usr/local/.

#!/usr/bin/env crystal

Is what you want.


Generally, on UNI*Xes, if a file is not found:

  • if it is a binary, which can be in the PATH, try which the_command
  • otherwise, you can use find, like find / -name "some_name*" (to modify depending of the need). Appending 2>/dev/null to the command can be useful to.