Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Julia adding package from github

Tags:

julia

I want to install the following package from github. I tried using the following command in my environment to install

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

But I get the following error,

ERROR: could not find project file in package at https://github.com/yeesian/LeafletJS.jl maybe subdir needs to be specified

Any ideas on how I can get installed? Do I have to clone it first to my local repo? If so how do I install from local path?

Cheers Thanks in advance

like image 281
imantha Avatar asked Jan 27 '21 07:01

imantha


People also ask

How do I import packages into Julia?

To install packages, use Pkg , Julia's built-in package manager, to add packages to your active environment. To use packages already in your active environment, write import X or using X , as described in the Modules documentation.

Where does Julia install packages?

Julia uses Git as a repository for itself and for its package and that the installation has a built-in package manager called pkg. jl.


2 Answers

You do not need to install locally, but you have to put the URL official to clone it.

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

Sometimes, if the package is already registered and you only want the master version in github you can directly do

add PackageName#master
like image 121
Daniel Molina Avatar answered Sep 20 '22 18:09

Daniel Molina


You have to clone it locally and then use Pkg.generate in order to import it as a package. It needs a Project.toml file to be added.

Thus, you have to:

$ 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`
like image 38
Oskar Avatar answered Sep 22 '22 18:09

Oskar