How to contribute to existing package

How to develop existing packages? If I want to develop Example.jl, should I use pkg and

pkg> develop --local Example

or fork the repo and then clone to desktop? If so, how do I load my local copy of package to Julia? How do I run tests?

Right now I think I would do the following:

  1. Fork the repo on GitHub.
  2. Clone the forked repo to my desktop.
  3. Somehow make my Julia REPL recognize the clone of the forked repo on desktop as the correct package to run.
  4. Code in Juno and test in REPL.
  5. Push to my forked repo.
  6. Open pull request.

Past 3 is a complete mystery to me.

1 Like

If you have already git cloned the package, you can avoid develop and directly activate the package.

Assuming you just did $ git clone https://github.com/MyUser/SomePackage.jl, you can either use the --project startup flag:

$ cd SomePackage.jl
$ julia --project
julia> import SomePackage

Or use activate:

$ julia
pkg> activate ./SomePackage.jl
julia> import SomePackage
3 Likes

How would one use pkg> dev for creating forks and making pull requests?

I don’t think the order of 1 and 2 matters.

  1. pkg> develop Example
    (Example package is in dir ~/.julia/dev)

  2. fork repo on github

    • go to ~/.julia/dev/Example and use git:
      git remote -v (origin should be pointing to where the package is from)
      add a new remote pointing to your fork:
      git remote add myfork https://github.com/yourname/reponame
  3. myfork can be any name

  4. git push myfork

4 Likes

You can

pkg> dev SomeRegisteredPackage

but then you need to fork, and add the forked repository as a remote:

https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

Alternatively, you can

pkg> dev forked-repository-url
1 Like

I do an example start to finish in this video:

First developing a new package, then making a PR to an existing package.

9 Likes

This is what I did in the end:

  1. Use pkg > dev Example
  2. Fork on GitHub (steps 1 and 2 can be exchanged)
  3. Go to the folder that looks like ~/.julia/dev/Example and open a git terminal there, and add my GitHub fork repo as its “remote origin”.Optionally add the original GitHub repo as “remote upstream”.
  4. Develop on my desktop.
  5. Push to my GitHub repo
  6. Open pull request on original GitHub repo
1 Like