# Recommended way to develop/fix with packages

**URL:** <https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436>\
**Category:** New to Julia\
**Created:** [September 2, 2018, 4:06pm UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436 "2018-09-02T16:06:08Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaap\_Haitsma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jaap_haitsma/32/32965_2.png) [@Jaap\_Haitsma](https://discourse.julialang.org/u/Jaap_Haitsma)\
**Post date:** [September 2, 2018, 4:06pm UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/1 "2018-09-02T16:06:08Z")

</div>

What’s the easiest way to provide patches to packages. I guess I should for the project on github but how do I make then sure that Julia uses my branch instead of the one I installed?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [September 2, 2018, 4:32pm UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/2 "2018-09-02T16:32:00Z")

</div>

This is my workflow (for patching a hypothetical `Example` package):

1. Get a local copy of the package, this can be done with `pkg> develop Example`. This will clone the package to `~.julia/dev/Example` by default. It will also make sure that the local copy is the one that is “installed” in the sense that `using Example` will use the files in that local folder.
2. Edit the package in `~.julia/dev/Example` and make sure your changes work as you expect.
3. Fork the package on GitHub and add your fork as a remote. Then use `git` to commit your changes, and push to your fork.
4. Open a pull request.

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [September 2, 2018, 4:35pm UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/3 "2018-09-02T16:35:10Z")

</div>

> [@fredrikekre](#):
>
> remove

Probably typo, should be “remote”.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 3, 2018, 12:02am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/4 "2018-09-03T00:02:42Z")

</div>

Why does this have to be so complicated? 🤔

Like “add your fork as a remote.” Not a one click action, not even a one command line action.

---

<div class="post-metadata">

**Author:** ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Post date:** [September 3, 2018, 1:07am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/5 "2018-09-03T01:07:20Z")

</div>

Can you explain what you find so complicated?

Forking and requesting a PR are done on GitHub’s side. The only phase Julia is involved in is locating the git project, which is a single command: `pkg> develop https://github.com/some/package`.

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [September 3, 2018, 1:29am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/6 "2018-09-03T01:29:54Z")

</div>

The order of operations for easy pull requests is to:

1. Fork the repo you’re trying to fix (on github)
2. Clone the fork to your computer
3. Make changes to the local copy
4. Push changes to your forked repo
5. Open pull request via the github app

* * *

If you happen to start developing a package you already have locally (i.e. if you find a bug and want to fix it), then you have to follow this mode of operations.

1. Checkout new branch (because you’ll be at `HEAD`)
2. Add remote branch using:

```julia
git remote add upstream <my_fork_url>

```

1. Make changes to the local copy
2. Push changes to the `upstream` remote (i.e. your fork)
3. Open pull request via the github app

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 3, 2018, 1:44am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/7 "2018-09-03T01:44:07Z")

</div>

> [@ufechner7](#):
>
> Why does this have to be so complicated? 🤔
> 
> Like “add your fork as a remote.” Not a one click action, not even a one command line action.

Because you don’t want anyone to be able to automatically add their code to your repo without review. You want them to work on their own remote and give a PR, not push to your repo. I think that’s a very very very valid concern to have.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 3, 2018, 7:47am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/8 "2018-09-03T07:47:35Z")

</div>

Thanks for the command line for adding the remote branch. 🙂

But Julia already has git integration. And I guess that github has a public api.  
So wouldn’t it possible to ad Pkg-commands for most of these steps?

---

<div class="post-metadata">

**Author:** ![tobias.knopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobias.knopp/32/7551_2.png) [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Post date:** [September 3, 2018, 7:53am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/9 "2018-09-03T07:53:49Z")

</div>

In Julia 0.6 with PkgDev it was just one command

```julia
PkgDev.publish()

```

it automatically made a fork, within that a branch with the fix and opened the web browser with the prepared pull request. Once PkgDev is ready for 1.0 we hopefully have that workflow again.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 3, 2018, 9:06am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/10 "2018-09-03T09:06:05Z")

</div>

Sounds promising! 🤗

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [September 4, 2018, 5:33am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/11 "2018-09-04T05:33:23Z")

</div>

This is a one-line command,

```
hub fork

```

Using the “hub” utility for working with GitHub repos.

---

<div class="post-metadata">

**Author:** ![sdewaele](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@sdewaele](https://discourse.julialang.org/u/sdewaele)\
**Post date:** [September 21, 2019, 7:28pm UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/12 "2019-09-21T19:28:23Z")

</div>

To expand a little on previous answers, these are the steps:

1. In the Julia REPL, ‘Develop’ the package. This will clone the package to `~/.julia/dev/Example`

```julia
pkg> develop Example

```

1. Fork the package on GitHub
2. On the command line, add your fork as a remote:

```julia
cd ~/.julia/dev/Example
git remote add upstream git@github.com:<your github username>/Example.jl.git

```

1. Create a new branch, giving it a name reflecting the change

```julia
git checkout -b new-feature

```

1. **Make your changes**
2. Use `git commit` to commit your changes. Several commits can be made.
3. On the command line, push the changes to your fork:

```julia
git push upstream new-feature

```

1. Open a pull request on Github

---

<div class="post-metadata">

**Author:** ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)\
**Post date:** [October 12, 2021, 6:01am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/13 "2021-10-12T06:01:16Z")

</div>

It looks like the [GitHub CLI provides a fork operation](https://cli.github.com/manual/gh_repo_fork).

Here’s my experiment:

```bash
mkdir tmp.
cd tmp
tmp> 
julia> ]
pkg> activate .
(tmp) pkg> add Revise Example
(tmp) pkg> develop Example
   Resolving package versions...
    Updating `~/development/Julia/tmp/Project.toml`
  [7876af07] ~ Example v0.5.3 ⇒ v0.5.4 `~/.julia/dev/Example`
    Updating `~/development/Julia/tmp/Manifest.toml`
  [7876af07] ~ Example v0.5.3 ⇒ v0.5.4 `~/.julia/dev/Example`

```

in 'nother terminal:

```bash
cd ~/.julia/dev/Example
[0] % git remote -v
origin	https://github.com/JuliaLang/Example.jl.git (fetch)
origin	https://github.com/JuliaLang/Example.jl.git (push)

# you'll have to set up the GitHub CLI authentication

› : ~/.julia/dev/Example
[0] % gh repo fork 
✓ Created fork <whatsisname>/Example.jl
? Would you like to add a remote for the fork? Yes
✓ Added remote origin

% git remote -vv
origin	https://github.com/<whatsisname>/Example.jl.git (fetch)
origin	https://github.com/<whatsisname>/Example.jl.git (push)
upstream	https://github.com/JuliaLang/Example.jl.git (fetch)
upstream	https://github.com/JuliaLang/Example.jl.git (push)

```

Then you’d make a branch for your changes - and go through the normal process.

I think that has a reasonably easy workflow with a small set-up cost.

---

<div class="post-metadata">

**Author:** ![banksiaboy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/banksiaboy/32/27032_2.png) [@banksiaboy](https://discourse.julialang.org/u/banksiaboy)\
**Post date:** [October 20, 2021, 9:46pm UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/14 "2021-10-20T21:46:07Z")

</div>

I found an _interesting weirdness_ in GitHub.  
I was working on building a lab for playing with forking repositories and merging pull-requests - and found that a user cannot fork their own repository. The GitHub WebUI explicitly disallows it. The GitHub cli gives a misleading error message.

It can be done by making a local clone `C` of the eventual upstream repository - `U`. Also create a new repository on github - `A`.

In the local directory of `C`:

```julia
git remote rm origin
git remote add `A`
git remote add upstream `U`
git checkout -b <feature-branch-name>

```

This creates something that walks and quacks like a fork. I’m still trying to get _who is doing what to whom_ in push, checkout, merge and fetch with the players in the fork.

I’m not sure yet whether the semantics of pull-requests work. I’m having to dive into what a pull-request really is - I think we call this _at the plumbing level_. I’m going to need more time to dissect.

There could be some identity crisis within forking repos under the same user. Something seems to stink when doing pull-requests. I’m comparing data-models with fork of Example.jl

---

<div class="post-metadata">

**Author:** ![tienviitta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tienviitta/32/34108_2.png) [@tienviitta](https://discourse.julialang.org/u/tienviitta)\
**Post date:** [November 23, 2022, 7:30am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/15 "2022-11-23T07:30:55Z")

</div>

Hi,  
I’m working with bitbucket repository where pull request should probably done using feature branches which are then merged to develop branch when accepted. How to I work with such feature branch? Do I add the feature branch (if it is possible) or do I add the “main” branch in develop and then checkout my feature branch at ~/.julia/dev/? How is the update then done after feature is accepted?  
-p

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [November 23, 2022, 8:16am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/16 "2022-11-23T08:16:48Z")

</div>

You can either add specific branches or the main branch and then checkout locally.  
See e.g. [12. API Reference · Pkg.jl](https://pkgdocs.julialang.org/v1/api/#Pkg.add) for how add/develop can be called  
`Pkg.develop(url="https://github.com/JuliaLang/Example.jl", rev="master")`

You can also just clone the git repo to anywhere you want, and checkout any branch you want.  
Starting julia with `julia --project` in the folder will run julia in that packages environment and allow you to test it.

Updating the main branch based on the feature branch would just follow the standard bitbucket procedure I guess, not sure if that was the question?

---

<div class="post-metadata">

**Author:** ![tienviitta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tienviitta/32/34108_2.png) [@tienviitta](https://discourse.julialang.org/u/tienviitta)\
**Post date:** [November 23, 2022, 8:36am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/17 "2022-11-23T08:36:56Z")

</div>

Yes, standard bitbucket after changes done and tested, thanks! Only problem was that I got error from develop:

```julia
julia> Pkg.develop(url="ssh://git@bitbucket.<domain>.<cc>:<port>/<repo>/<package>.jl.git", rev="feature/<branch>")
ERROR: rev argument not supported by `develop`; consider using `add` instead

```

Julia Version 1.8.2 (2022-09-29). I think https access will not work, I could try but I prefer ssh.  
-p

EDITED:  
Pkg.add(…, rev=“feature/”) and (@1.8) pkg\> develop works but fetches the “main”.

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [November 23, 2022, 8:48am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/18 "2022-11-23T08:48:48Z")

</div>

Oh, my bad. I had assumed that `develop` and `add` supported the same arguments.

Does ssh work without the `rev` argument?

If you want to change things locally you don’t want add since it snapshots a specific version and will not update to changes. So the solution is probably to develop the main branch and then just go into the .julia/dev/YourPackage and checkout the feature branch.

Otherwise just clone the package normally to wherever you want to have it, checkout the feature branch and then develop there. Either activate the packages environment for testing, or add it to some other environment by doing develop on the path to the package.

---

<div class="post-metadata">

**Author:** ![tienviitta](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tienviitta/32/34108_2.png) [@tienviitta](https://discourse.julialang.org/u/tienviitta)\
**Post date:** [November 23, 2022, 8:51am UTC](https://discourse.julialang.org/t/recommended-way-to-develop-fix-with-packages/14436/19 "2022-11-23T08:51:48Z")

</div>

Yes it works that way. I’ll do “manual” checkout, seems to be viable option in this case, and I can work this way too 👍.
