# Dependency on an un-registered fork

**URL:** <https://discourse.julialang.org/t/dependency-on-an-un-registered-fork/23132>\
**Category:** General Usage\
**Tags:** package-manager\
**Created:** [April 14, 2019, 6:23am UTC](https://discourse.julialang.org/t/dependency-on-an-un-registered-fork/23132 "2019-04-14T06:23:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [April 14, 2019, 6:23am UTC](https://discourse.julialang.org/t/dependency-on-an-un-registered-fork/23132/1 "2019-04-14T06:23:57Z")

</div>

Hello,

(_short_) I’m contributing to a package (say `B`) that depends upon a unregistered patched fork (`fork/A`) of a registered package (`A`). I’d like to make sure that if a user uses `B`, it uses `fork/A` and not `A` if by any chance they already have `A` on their system. This seems to require that they add `fork/A` explicitly which seems odd?

(_long_) this is if the short paragraph above doesn’t make sense

- `A` is a registered and reasonably mature package with a (currently) slow development schedule
- `B` is a package I’m contributing to that has `using A` in it
- `A` has a bug which causes `B` to not work properly
- fixing the bug well is not trivial though a simple hack is possible and works fine but is unlikely to be merged in `A`, this simple fix is applied in my fork of `A`: `fork/A`

I’ve added `fork/A` to `B` using the usual package approach (`activate .` and `add url/fork/A`) and it shows up in the `Manifest.toml` as it should. If a user adds `B` on a system that doesn’t already have `A` somewhere, it works fine and uses `fork/A`.  
However, on a system where `A` is already present, if I just do `add url/B` it uses `A` and not `fork/A` even though it is `fork/A` that is mentioned in the manifest ( **why?** )

I can bypass this problem by requiring users to add the patched fork explicitly doing

```julia
pkg> add url/fork/A
pkg> add url/B

```

that works fine but is not ideal because it forces the user to go from `A` to `fork/A` on their system (in this case it changes nothing for them but they may still not want to do it e.g. if they’re using an older version of `A` for another project of theirs)

So I guess my questions are:

1. why does it use `A` instead of `fork/A` if `A` exists on the system even though the manifest specifies `fork/A`
2. is there any better alternative than the double `add` above or requiring users to activate an environment every time they want to use the package?

thanks!

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [April 14, 2019, 8:53am UTC](https://discourse.julialang.org/t/dependency-on-an-un-registered-fork/23132/2 "2019-04-14T08:53:32Z")

</div>

> [@tlienart](#):
>
> why does it use `A` instead of `fork/A` if `A` exists on the system even though the manifest specifies `fork/A`

An enviroment’s Manifest.toml is **only** used if an enviroment is activated.  
Only the Project.toml is used if a project is depended upon.

> [@tlienart](#):
>
> is there any better alternative than the double `add` above or requiring users to activate an environment every time they want to use the package?

If you can’t get you patch merged upstream,  
then you could perhaps monkey patch your dependency from within your pacakge.  
via overloading its methods with your patched ones.

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [April 14, 2019, 12:44pm UTC](https://discourse.julialang.org/t/dependency-on-an-un-registered-fork/23132/3 "2019-04-14T12:44:49Z")

</div>

Makes sense, thanks!

I did consider monkey patching too but there’s a lot of nested dependencies so I was hoping for an alternative. It might just be the better option though, cheers!

---

<div class="post-metadata">

**Author:** ![hustf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hustf/32/2374_2.png) [@hustf](https://discourse.julialang.org/u/hustf)\
**Post date:** [July 18, 2019, 6:59pm UTC](https://discourse.julialang.org/t/dependency-on-an-un-registered-fork/23132/4 "2019-07-18T18:59:06Z")

</div>

I have perhaps been overly depending on ‘Base.delete’ and monkey patching.

Somewhere between Julia 1.0 and 1.2, new warnings against the practice seems to have been added:

```julia
**incremental compilation may be fatally broken for this module**
WARNING: method deletion during Module precompile may lead 
to undefined behavior

```

This may motivate many hardly necessary forks, which is quite bad for the development of the ecosystem. Is there a workaround?
