是否可以指定自定义“lib /”分片安装目录?

Crystal项目中Crystal分片的默认安装目录是“lib /” . 是否可以自定义路径?

回答(2)

3 years ago

看来你可以设置一个环境变量 SHARDS_INSTALL_PATH . 然而,这没有记录,应小心处理 .

为什么还需要不同的安装目录?

3 years ago

# This sets the install path when you do `crystal deps`.
# It needs to be an absoluete path, not a relative path.
export SHARDS_INSTALL_PATH="$PWD/my/dir" 

# This is needed for the Crystal compiler to the find the shards.
#  The Crystal compiler does not use SHARDS_INSTAL_PATH.
#  Unlike SHARDS_INSTALL_PATH, it can be a relative path.
#  You must also specify the place for the Crystal source directory
#  in order to find the Standard Lib .cr files:
export CRYSTAL_PATH="$SHARDS_INSTALL_PATH:the/crystal/src"

# Now you can do:
crystal deps                  # uses SHARDS_INSTALL_PATH
crystal build src/my-file.cr  # uses CRYSTAL_PATH

来源:试错法和grep-ing shardsCrystal的源代码 .

注意:正如Johannes Müller先前所述,这是无证件的 .