If some of my libraries locate out of default directory lib
, could I indicate the require path to compile successfully without lib
directory nor shards.yml
.
Crystal lang : How to indicate require path for crystal compiler
Asked Answered
Yes, change the CRYSTAL_PATH
environment variable. By default it's $CRYSTAL_ROOT/src:lib
(the src
directory of the installation, and then the relative lib
directory). Just add :some_other_dir
at the end of that.
Example: CRYSTAL_PATH=$CRYSTAL_ROOT/src:lib:~/my_lib_dir
It didn't work as mentioned in another answer, this won't work CRYSTAL_PATH=$CRYSTAL_ROOT/src:lib:~/my_lib_dir
.
Because in my case the CRYSTAL_ROOT
was blank.
The solution was to execute crystal env
and copy from there whatever paths it has for CRYSTAL_PATH
and then re-set it as CRYSTAL_PATH=whatever-paths-you-just-copied:~/my_lib_dir
© 2022 - 2024 — McMap. All rights reserved.
Crystal 0.32.0
? Not working for me. – Vociferate