我在 Julia 中创建了一个包(我们称之为 package_name);文件结构已经与 Project.toml 和 Manifest.toml 文件一起生成,并且在创建包时我已经添加了一些依赖项。
我忘记添加依赖项,我想让 REPL 显示:
(package_name) pkg >
Run Code Online (Sandbox Code Playgroud)
这样我就可以输入
add dependency_name
Run Code Online (Sandbox Code Playgroud)
我如何让 REPL 来显示这一点?我想我需要转到包文件夹并(重新)激活该包,但我无法使用 cd 导航到它。
显示我应该在 REPL 中输入的确切命令会很有帮助。
ffe*_*tte 14
为了获得包 REPL 模式],您应该在光标位于行首时键入右括号。同样,在包 REPL 模式下,您需要BackSpc在提示后立即键入才能返回标准 REPL 模式:
julia> # type ] here to enter the Pkg REPL
# We're now in the Pkg REPL, but the default environment is active
# Let's activate the environment we want
# (replace the path below with "." to activate the environment defined in the current working directory)
(@v1.5) pkg> activate /path/to/package
# Now we see that the correct environment is active
# This is where new dependencies will be added
(package_name) pkg> add DepName
(package_name) pkg> # type BackSpace here to get back to the standard REPL
julia>
Run Code Online (Sandbox Code Playgroud)
pkg"..."此外,通过使用库中定义的字符串宏,您可以在不进入 Pkg REPL 模式的情况下实现相同的效果Pkg:
julia> using Pkg
julia> pkg"activate /path/to/package"
julia> pkg"add DepName"
Run Code Online (Sandbox Code Playgroud)