if my file sh/hello
contains:
#!/usr/bin/crystal
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.
thoughts?
Edit: Solution:
this works as expected on both OSX and debian:
#!/usr/bin/env crystal
oprypin
December 22, 2020, 9:06pm
2
Well yea, "/usr/bin/crystal: no such file or directory
on OSX" is certainly true. What’s your point?
@oprypin is trying to tell you that /usr/bin/crystal is not there. You have to install it.
oprypin
December 22, 2020, 11:36pm
5
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.
@carcinocron 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:
#!/usr/local/bin/crystal
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. hello.cr) and run it with
$ crystal run hello.cr
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…
4 Likes
@carcinocron 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.
3 Likes
j8r
December 24, 2020, 8:00pm
9
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.