Crystal lang : How to indicate require path for crystal compiler
Asked Answered
C

2

5

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.

Classroom answered 1/9, 2018 at 7:30 Comment(0)
S
6

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

Scepter answered 2/9, 2018 at 0:46 Comment(1)
Does this still expected to work in Crystal 0.32.0? Not working for me.Vociferate
V
1

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

Vociferate answered 8/8, 2021 at 9:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.