在我的Julia 1.0.0 REPL中,LOAD_PATH返回意外结果

时间:2018-09-18 04:30:55

标签: julia

我的Julia REPL帮助为LOAD_PATH提供了以下内容:

help?> LOAD_PATH
search: LOAD_PATH

  LOAD_PATH

  An array of paths for using and import statements to consdier as project environments or package directories when
  loading code. See Code Loading.

这是我在提示符下的LOAD_PATH的输出:

julia> LOAD_PATH  # What is the output below?
3-element Array{String,1}:
 "@"
 "@v#.#"
 "@stdlib"

上面显示的LOAD_PATH的输出似乎很奇怪。

有什么建议吗?

1 个答案:

答案 0 :(得分:3)

您看到的是DEFAULT_LOAD_PATH

让我引用来自relevant section of the source code的评论:

## LOAD_PATH, HOME_PROJECT & ACTIVE_PROJECT ##

# JULIA_LOAD_PATH: split on `:` (or `;` on Windows)
# first empty entry is replaced with DEFAULT_LOAD_PATH, the rest are skipped
# entries starting with `@` are named environments:
#  - the first three `#`s in a named environment are replaced with version numbers
#  - `@stdlib` is a special name for the standard library and expands to its path

换句话说,

  • "@":用于加载相对于当前路径的内容(此处不确定,请参见下面的更新)
  • "@v#.#":将成为v1.0环境的路径(假设您使用的是1.0)。
  • "@stdlib":将成为标准库的路径

这可能应该在Pkg文档中的某个地方更准确地解释。介意filing an issue over there? (更新:请参见https://github.com/JuliaLang/Pkg.jl/issues/757

更新:

人们可以使用方法Base.load_path_expand(a::AbstractString)来看看最终会发生什么:

julia> Base.load_path_expand.(LOAD_PATH.*"/test")
3-element Array{String,1}:
 "\\test\\Project.toml"
 "C:\\Users\\carsten\\.julia\\environments\\v1.0\\test\\Project.toml"
 "C:\\Users\\carsten\\.julia\\environments\\stdlib\\test\\Project.toml"