# Install own fork of package instead of "official" version

**URL:** <https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456>\
**Category:** Package Management\
**Created:** [June 6, 2021, 12:41am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456 "2021-06-06T00:41:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [June 6, 2021, 12:41am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/1 "2021-06-06T00:41:03Z")

</div>

I have a fork of a package. That package is a dependency of many other packages, some of which I use heavily. How can I install my fork so that the dependent packages use my fork instead of the “official” dependency? is it just as simple as remove the “official” pkg and install my fork instead?

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [June 6, 2021, 1:54am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/2 "2021-06-06T01:54:06Z")

</div>

If you’re developing your fork, I would `] dev Pkg`. Then it’ll use your local version.  
Otherwise, you could `] add path_(optionally_URL)_to_your_fork`.

---

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [June 6, 2021, 2:03am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/3 "2021-06-06T02:03:34Z")

</div>

That’s what I was thinking, first `]rm` the official package, then `]add` my fork on GitHub. Not at home at the moment, so can’t test it. I’m afraid it may produce some conflict.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [June 6, 2021, 2:30am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/4 "2021-06-06T02:30:06Z")

</div>

> [@amrods](#):
>
> I’m afraid it may produce some conflict.

why?

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [June 6, 2021, 5:11am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/5 "2021-06-06T05:11:44Z")

</div>

(untested)

I believe if you keep the original uuid/pkg name, then the other packages of your local installation don’t care if your git remote is the original package address or your fork one…

Of course, if you are then developing your fork further and adding versions, then you may have problems…

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [June 6, 2021, 6:18am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/6 "2021-06-06T06:18:28Z")

</div>

Why not `]dev`? This is exactly what that is for.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 6, 2021, 7:17pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/7 "2021-06-06T19:17:08Z")

</div>

Probably a good idea is to add your fork to a specific environment, activated by, for example,

```julia
] activate "MyFork"

] dev MyFork # or add your fork

```

Then you can use your fork without creating conflicts with the installation in the main or other environments.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 6, 2021, 7:29pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/8 "2021-06-06T19:29:05Z")

</div>

To “use” a package different from its official version, but not to develop it, one can also use `add SomePackage`.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [June 7, 2021, 1:36am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/9 "2021-06-07T01:36:47Z")

</div>

`]dev` is the right answer if you’re just doing this for yourself on your own machine, but I think it won’t be reproducible (that is, one won’t be able to use the Manifest to `instantiate` it), right?

---

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [June 7, 2021, 1:39am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/10 "2021-06-07T01:39:27Z")

</div>

I don’t know, but I’m only doing it for myself before a new release of the package with the fixed gets released. There is already a PR for that.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [June 7, 2021, 11:24am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/11 "2021-06-07T11:24:00Z")

</div>

In that case, `] dev` souds like the right call (or `] add ThePackage#fork-name`). Just remember to do `] free ThePackage` once the PR is merged and tagged.

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [November 18, 2022, 9:15am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/12 "2022-11-18T09:15:35Z")

</div>

I still do not anderstand.

```julia
pkg> activate "MyFork"

```

Is `"MyFork"` just a arbitrary label?  
And what about

```julia
pkg> dev PackageName

```

After I have cloned the package “PackageName” the code is cloned as described [here](https://pkgdocs.julialang.org/v1/managing-packages/#developing).  
No I wonder how can I link this to the official repository.  
The package I would like to work on and maybe create a `Merge Request` is hosted  
on the platform [github](https://github.com).  
What would be the next step to file a `MR`?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 18, 2022, 1:30pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/13 "2022-11-18T13:30:28Z")

</div>

The environment is a suggestion to not mix the use of your own fork of the package with the official version of the package in all other uses of it you may do in other contexts.

Suppose you forked the package, you then can:

1. Create a new environment. This is done simply by creating a directory, starting Julia and doing

```julia
import Pkg; Pkg.activate(".")

```

That will activate an environment with the same name of the directory.

1. Add your for:

```julia
import Pkg; Pkg.add(url="https://github.com/user/MyFork.jl")

```

This will create the `Project.toml` and `Manifest.toml` that contain the information about the packages used in that environment.

That won’t intefere with the use of the “oficial” version of the package in other contexts, meaning, in environments different from that one.

Afterwards, just start julia again in the same directory and use `] activate .` to activate the environment where you are working with that version of the package.

If you are **developing** the for of the package, instead of `Pkg.add(...)` use `Pkg.develop(...)`)

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [November 18, 2022, 2:21pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/14 "2022-11-18T14:21:54Z")

</div>

> [@lmiq](#):
>
> `import Pkg; Pkg.activate(".")`

Thank you for your fast reply!

Is it mandatory to be sure that the current directory:

```julia
pwd()

```

is identical with the root directory of the repository-clone?  
Is is also possible to use an explicit path instead, e.g.:

```julia
import Pkg; Pkg.activate(raw"C:\data\git_repos\extern\EquivalentCircuits.jl")

```

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 18, 2022, 2:27pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/15 "2022-11-18T14:27:43Z")

</div>

These are two different things. If what you want is “simply” develop your fork of the package, yes, just activate the project of that package (which is what you do there). You can also do that by going to the directory and starting julia with `julia --project`. This is the standard way to develop a package. (If you are using VSCode, developing that directory does all that).

Another thing (which is, apparently, the original question of this thread), is how to use that fork, not necessarily to develop it. In this case, you can add the fork, as I mentioned, to any other environment.

The environment and the versions of the packages are not associated, necessarily. You can `dev` a package in any environment. Only it is common to develop a package in the environment of the package itself, though that is not mandatory, and particularly common if one is developing two packages at the same time.

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [November 21, 2022, 1:12pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/16 "2022-11-21T13:12:43Z")

</div>

Sorry I have to admit, I am still lost.  
Is the following correct:  
1.) fork a repository  
2.) clone the repository on a local machine  
3.) activate the local root directory of the package via `activate`  
Here I struggle already.  
Is is mandatory to go there via `cd()`  
and then specify as location `"."`  
or is it appropriate to specify the full directory name, e.g.:

```julia
import Pkg; Pkg.activate(raw"C:\data\git_repos\extern\EquivalentCircuits.jl")

```

5.) change the content of the fork in the remote repository  
6.) pull the fork from the remote repository  
7.) next …  
Is this already all I need to do to use the new pulled fork?  
Do I need to use a Pkg command to enable the use of the new content  
of the pulled fork?  
E.g. is a restart mandatory?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [November 21, 2022, 1:32pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/17 "2022-11-21T13:32:52Z")

</div>

The problem is that you are mixing three things: the activation of the environment, the use, and the development of the local fork.

1. The activation of **an** environment is important so that your changes to this local fork of your package do not affect other uses of the package in other instances of Julia. For instance, let us say you are developing something in `Plots`, you wouldn’t want that a perhaps broken local fork of `Plots` does not let you use `Plots` in other scripts. Thus you want to isolate the fork in a an environment. It can be **any** new environment. For instance, you can start all this by doing:

```julia
import Pkg; Pkg.activate("MyNewEnv")

```

and this will create a directory `MyNewEnv` to contain the files of that new environment.

1. If you are developing that package, it is frequently convenient and practical to just use the environment that is already defined by the package you are developing. Then you activate the directory of the package, as you propose (or by cd’ing to it, or by loading in VSCode).

2. To develop the package, use:

```julia
import Pkg; Pkg.develop(raw"c:\data...\MyPackage") # not sure if you need that raw
using Revise
using MyPackage

```

By using Revise before the package, the changes to the functions of the package will be automatically tracked, and you can modify the code and rerun the functions to test them. VSCode sort of does all that automatically for you.

1. To just **use** the package in the local folder, use `import Pkg; Pkg.add("c:\....\MyPackage"); using MyPackage`. Preferably in a specific environment, again not to mix your local version of the package with the “official” version that might be in some other script.

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [November 21, 2022, 1:47pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/18 "2022-11-21T13:47:43Z")

</div>

Thanks that clarifies. 🙂

First I decide in which environment I would like to work. This can be done in at least three  
alternative ways:

- VScode: Open new window and use the command `open folder`  
(such a root directory of an Julia-Pkg-Environment includes a file `Project.toml`)

- Inside Comand Line Interface (CLI): move to the environment root dir via command  
`cd` and give the command `import Pkg; Pkg.activate(".")`

- Explicit Pkg.command with the name of the environment, if no argument is given,  
the native Julia version specific environment will be taken: `import Pkg; Pkg.activate()`  
or `import Pkg; Pkg.activate("MyEnvironmentName")`

If I introduce a new environment I need to install inside the current environment the  
packages that I need inside this particular environment.  
With the command `import Pkg; Pkg.status()` I can see which packages are installed  
inside the chosen / current environment.

After some trial, I prefere to seperate the folder of the package I am working on and  
the host folder of a specific `Julia-Pkg-Environment`.  
Default location of the environments can be printed by using:

```julia
import Pkg; Pkg.envdir()

```

If I create a new `Julia-Pkg-Environment` via:

```julia
Pkg.activate("MyDevEnv") # no directory path is specified

```

This new environment does not include installed packages, that needs to be done  
by means of `Pkg.add("PackageName")`.  
In Julia version `v1.6.7` the corresponding file: `Project.toml` & `Manifest.toml` will be created in a subfolder of

```julia
joinpath(Pkg.envdir(), "vX.Y") # "vX.Y" might be: "v1.6"

```

On MS-windows in Julia `v1.8.3` the default environment folder is located in the personal profile folder / home-directory.  
As soon as a package is added to this new environment, e.g. by:

```julia
import Pkg; Pkg.add("Revise")

```

In Julia `v1.6.7` this folder will be populated with the two environment definition / configuration files `Project.toml` & `Manifest.toml`.  
In Julia `v1.8.3` however the environment will be set-up in the current folder,  
which can be displayed via `pwd()`

If I would like to switch back to the original environment of the current Julia-Version  
I can use the command `activate()` without argument:

```julia
Pkg.activate() 

```

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [November 23, 2022, 10:28pm UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/19 "2022-11-23T22:28:59Z")

</div>

Regarding the activation of user defined environments see also: [julia-environments-list](https://discourse.julialang.org/t/julia-environments-list/37774/6)

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [November 24, 2022, 10:58am UTC](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456/20 "2022-11-24T10:58:01Z")

</div>

I am still struggling.  
I have used the parameter `url` of command `Pkg.add()` to be sure that I add my own fork to the new userdefined environment `MyDefEnv` as follows:

```julia
Pkg.add(url=raw"C:\folder\to\my\local\fork\EquivalentCircuits.jl")

```

And I can see that this development package / this fork is attached to the environment:

```julia
(@MyDevEnv) pkg> st
      Status `C:\Users\stefanpofahl\.julia\environments\v1.6\MyDevEnv\Project.toml`
  [da5bd070] EquivalentCircuits v0.2.1 `C:\folder\to\my\local\fork\EquivalentCircuits.jl#master`
  [5789e2e9] FileIO v1.16.0
[...]

```

But unfortunatly, it is still the standard package (not my fork of the package) that is used.  
If I use in addition the command `Pkg.develop(path=)` the following error-message is thrown:

```julia
Pkg.develop(path=raw"C:\folder\to\my\local\fork\EquivalentCircuits.jl")

```

The error message is:

```julia
ERROR: expected a `name` entry in project file at `C:\folder\to\my\local\fork\EquivalentCircuits.jl\Project.toml`

```

What do I miss?

[Next page](https://discourse.julialang.org/t/install-own-fork-of-package-instead-of-official-version/62456.md?page=2)
