In my Julia 1.0.0 REPL, LOAD_PATH returns unexpected results

谁说我不能喝 提交于 2020-01-14 18:59:47

问题


My Julia REPL Help provides the following for 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.

Here is my output for LOAD_PATH at the prompt:

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

The output shown above for LOAD_PATH seems strange.

Any suggestions?


回答1:


What you see there is the DEFAULT_LOAD_PATH.

Let me cite comments from the 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

In other words,

  • "@": is for loading things relative to the current path (not completely sure here, see update below)
  • "@v#.#": will become the path to the v1.0 environment (assuming you are on 1.0).
  • "@stdlib": will become the path to the stdlibs

This should probably be explained more precisely in the Pkg docs somewhere. Mind filing an issue over there? (UPDATE: See https://github.com/JuliaLang/Pkg.jl/issues/757)

UPDATE:

One can play around with the method Base.load_path_expand(a::AbstractString) to see what things become eventually:

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"


来源:https://stackoverflow.com/questions/52378974/in-my-julia-1-0-0-repl-load-path-returns-unexpected-results

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!