Julia 从 github 添加包

问题描述 投票:0回答:2

我想从 github 安装以下包。我尝试在我的环境中使用以下命令来安装

(nlpEnvJl) pkg> add "https://github.com/yeesian/LeafletJS.jl/tree/master/src"

但是我收到以下错误,

错误:无法在包中找到项目文件

https://github.com/yeesian/LeafletJS.jl
,也许需要指定
subdir

关于如何安装有什么想法吗?我必须先将其克隆到本地存储库吗?如果是这样,我如何从本地路径安装?

干杯 预先感谢

julia
2个回答
17
投票

本地不需要安装,但是要放官方的URL才能克隆。

add https://github.com/yeesian/LeafletJS.jl.git

有时,如果包已经注册,而你只想要 github 中的主版本,你可以直接这样做

add PackageName#main

8
投票

您必须在本地克隆它,然后使用

Pkg.generate
才能将其作为包导入。它需要添加一个
Project.toml
文件。

因此,你必须:

$ git clone [email protected]:yeesian/LeafletJS.jl.git                                                                                                                                                                                       
Cloning into 'LeafletJS.jl'...
remote: Enumerating objects: 59, done.
remote: Total 59 (delta 0), reused 0 (delta 0), pack-reused 59
Receiving objects: 100% (59/59), 14.83 KiB | 197.00 KiB/s, done.
Resolving deltas: 100% (22/22), done.
$ julia  
 
(@v1.5) pkg> generate LeafletJS
 Generating  project LeafletJS:
    LeafletJS/Project.toml
    LeafletJS/src/LeafletJS.jl

$ cp -r LeafletJS.jl/* LeafletJS/.                                                                                                                                                                                                        
$ cd LeafletJS                                                                                                                                                                                                                            
LeafletJS $ julia  

(@v1.5) pkg> dev .
[ Info: Resolving package identifier `.` as a directory at `/tmp/jl_temp/LeafletJS/`.
Path `.` exists and looks like the correct package. Using existing path.
  Resolving package versions...
Updating `~/.julia/environments/v1.5/Project.toml`
  [b1ddfcb9] + LeafletJS v0.1.0 `../../../../../tmp/jl_temp/LeafletJS`
Updating `~/.julia/environments/v1.5/Manifest.toml`
  [b1ddfcb9] + LeafletJS v0.1.0 `../../../../../tmp/jl_temp/LeafletJS`
© www.soinside.com 2019 - 2024. All rights reserved.