Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In my Julia 1.0.0 REPL, LOAD_PATH returns unexpected results

Tags:

julia

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?

like image 234
Julia Learner Avatar asked Sep 18 '18 04:09

Julia Learner


1 Answers

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"
like image 61
carstenbauer Avatar answered Oct 10 '22 22:10

carstenbauer