Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crystal lang : How to indicate require path for crystal compiler

Tags:

crystal-lang

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.

like image 320
XQY Avatar asked Sep 01 '18 07:09

XQY


2 Answers

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

like image 115
asterite Avatar answered Oct 26 '22 21:10

asterite


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

like image 1
Alex Craft Avatar answered Oct 26 '22 23:10

Alex Craft