在我的 Julia 1.0.0 REPL 中,LOAD_PATH 返回意外结果 [英] In my Julia 1.0.0 REPL, LOAD_PATH returns unexpected results

查看:9
本文介绍了在我的 Julia 1.0.0 REPL 中,LOAD_PATH 返回意外结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

帮助?>加载路径搜索:LOAD_PATH加载路径用于使用和导入语句的路径数组,以便在以下情况下用作项目环境或包目录加载代码.请参阅代码加载.

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

朱莉娅>LOAD_PATH # 下面的输出是什么?三元素数组{String,1}:@"@v#.#"@stdlib"

上面显示的 LOAD_PATH 输出看起来很奇怪.

有什么建议吗?

解决方案

你看到的是 DEFAULT_LOAD_PATH.

让我引用源中相关部分的评论代码:

## LOAD_PATH, HOME_PROJECT &活动项目### JULIA_LOAD_PATH: 在 `:` 上拆分(或 Windows 上的 `;`)# 第一个空条目被 DEFAULT_LOAD_PATH 替换,其余的被跳过# 以 `@` 开头的条目是命名环境:# - 命名环境中的前三个 `#` 被替换为版本号# - `@stdlib` 是标准库的特殊名称,并扩展到其路径

换句话说,

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

这可能应该在某处的 Pkg 文档中更准确地解释.介意在那里提交问题?(更新:见 https://github.com/JuliaLang/Pkg.jl/issues/第757章

更新:

可以使用 Base.load_path_expand(a::AbstractString) 方法来看看最终会变成什么:

朱莉娅>Base.load_path_expand.(LOAD_PATH.*"/test")三元素数组{String,1}:\test\Project.toml""C:\Users\carsten\.julia\environments\v1.0\test\Project.toml""C:\Users\carsten\.julia\environments\stdlib\test\Project.toml"

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?

解决方案

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"

这篇关于在我的 Julia 1.0.0 REPL 中,LOAD_PATH 返回意外结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆