本文介绍了如何在Julia的导入路径中添加本地项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用我正在目录〜/projects/ExamplePkg 中编写的程序包导入 Julia REPL的主要版本/来自其他项目或环境.

I want to be able to import or using a package that I'm writing in a directory ~/projects/ExamplePkg from my main Julia REPL / from another project or environment.

推荐答案

通过] foo 我的意思是在Julia Pkg REPL上使用foo命令".在Julia REPL上键入] 以输入Pkg REPL.使用]帮助<命令名称> 以获得更多信息,或查看下面的链接.

By ]foo I mean "use the foo command at the Julia Pkg REPL". Type ] at the Julia REPL to enter the Pkg REPL. Use ]help <command name> for more info or check the link below.

确保您的程序包具有一个Project.toml,并为其提供一个UUID并命名(使用Julia REPL或PkgTemplates程序包中的] generate 生成一个),并且该文件位于git中至少要提交一次包含所有相关文件的回购.

Ensure that your package has a Project.toml that gives it a UUID and names it (generate one with ]generate from the Julia REPL or with the PkgTemplates package) and that it is in a git repo with at least one commit including all the relevant files.

然后选择您要如何使用该软件包.

Then choose how you would like to use the package.

您可能要运行] dev〜/projects/ExamplePkg :

如果使用 dev 并更改了 dev 程序包中的依赖项,则可能应该在所有环境中运行] resolve 取决于包装.

If you use dev and you change the dependencies in the dev'd package, then you should probably run ]resolve in all environments that depend on the package.

或者您可以运行] add〜/projects/ExamplePkg :

在Julia版本< 1.4中:如果在正确设置git repo之前意外地]添加一个包,则可能会出现 ERROR:GitError(Code:EUNBORNBRANCH,Class:Reference,则找不到参考'refs/heads/master').不幸的是,Julia可能已经缓存了不良回购,因此您需要将其从〜/.julia/clones/< gibberish>/中删除.您可以找到要使用grep删除的目录: $ grep ExamplePkg〜/.julia/clones/*/config .

In Julia versions <1.4: If you accidentally ]add a package before the git repo is set up correctly then you might get ERROR: GitError(Code:EUNBORNBRANCH, Class:Reference, reference 'refs/heads/master' not found). Unfortunately, Julia will probably have cached the bad repo, and you will need to remove that from ~/.julia/clones/<gibberish>/. You can find the dir to remove with grep: $ grep ExamplePkg ~/.julia/clones/*/config.

文档: https://julialang.github.io/Pkg.jl/v1/managing-packages/

这篇关于如何在Julia的导入路径中添加本地项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 20:38