# Management of Packages in Julia

**URL:** <https://discourse.julialang.org/t/management-of-packages-in-julia/29098>\
**Category:** General Usage\
**Created:** [September 24, 2019, 1:52am UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098 "2019-09-24T01:52:21Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 24, 2019, 1:52am UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/1 "2019-09-24T01:52:21Z")

</div>

Hi All,

I’m using PkgTemplates to create new custom Pkgs for my own use, and as per PkgTemplate defaults, they save to the .julia/dev/ directory.

I was able to call my first package, SatPrecip, with “using SatPrecip”. However, the second package I create, dnt2str, cannot be found at all even though they are found in the same .julia/dev/ directory. Might anyone know what the issue is?

The screenshot of my projects and codes in the Juno IDE are found below.

Best  
Nat!

 ![52%20(2)](https://global.discourse-cdn.com/julialang/original/3X/e/f/ef28ce829d5e4786f9eed31909f8693114e39ea3.png)

---

<div class="post-metadata">

**Author:** ![Amin\_Yahyaabadi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amin_yahyaabadi/32/9826_2.png) [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Post date:** [September 24, 2019, 3:15am UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/2 "2019-09-24T03:15:02Z")

</div>

You can `add` or `dev` your package to your registry.

```julia
] dev path/to/your/package

```

Alternatively for doing development, you can use this simple code that pushes the path of your current package to the registry temporarily .  
Set developing to true. For real usage, you need to add your package to your registry and set the developing to false.  
[https://github.com/juliamatlab/MatLang/blob/4598efdcfd0d575ceb67e4ea5d8af09f6fa8046b/examples/Language\_Fundamentals/usage\_Matrices\_and\_Arrays.jl#L1](https://github.com/juliamatlab/MatLang/blob/4598efdcfd0d575ceb67e4ea5d8af09f6fa8046b/examples/Language_Fundamentals/usage_Matrices_and_Arrays.jl#L1)

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 24, 2019, 3:30am UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/3 "2019-09-24T03:30:00Z")

</div>

Thanks!

I didn’t need to do this for the first project I created though, so that’s what got me wondering.

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 24, 2019, 12:21pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/4 "2019-09-24T12:21:40Z")

</div>

I would not change the `LOAD_PATH` and use `Pkg` instead to keep track of dependencies. That’s the whole point of having packages, after all.

So the question is what `SatPrecip`’s `Project.toml` looks like. It should have `dnt2str` as a dependency. If so, once you `activate` `SatPrecip`, `using dnt2str` will work.

As the error message in your screenshot suggests, you need to `Pkg.add` or `Pkg.develop` `dnt2str` while in `SatPrecip`’s environment.

Instead of writing out all the details, it would probably be easier to read [Notes on the Julia language](https://lhendricks.org/julia_notes.pdf) (see section on packages).

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 24, 2019, 2:05pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/5 "2019-09-24T14:05:40Z")

</div>

Mmmm actually I wanted SatPrecip and dnt2str as separate projects and packages, not dnt2str as part of SatPrecip. Is there a way to have both available in the .julia/dev/ folder (because they are still very new projects) without one being a dependency on another?

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 24, 2019, 2:42pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/6 "2019-09-24T14:42:13Z")

</div>

I misunderstood.

Then you could just `cd` to the directory that would want to work on (e.g. `.julia/dev/SatPrecip` and issue `>pkg activate .` followed by `using SatPrecip`.

But I have a feeling you want to do something else / more?

The general point is: for `using X` to work you either need to `activate` X’s directory (`.julia/dev/X`) or you need to add `X` as a dependency to the environment that you are working in.

You could also add `.julia/dev/X` to the `LOAD_PATH` but this really defeats the point of having packages.

---

<div class="post-metadata">

**Author:** ![zaki](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zaki/32/10300_2.png) [@zaki](https://discourse.julialang.org/u/zaki)\
**Post date:** [September 24, 2019, 3:05pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/7 "2019-09-24T15:05:07Z")

</div>

Adding to the previous answer:  
If the goal is to use/develop both `SatPrecip` and `dnt2str` together, but not have them be dependencies of one another, then a new environment can be activated and those two packages can be `dev`’d in.

This can be done by making/navigating to a new folder and then

```julia
]activate .
]dev SatPrecip
]dev dnt2str

```

Hopefully the packages get identified since they are in the `.julia/dev/` folder.  
Then it should be possible to use/develop both packages at the same time.  
When opening a new Julia session in the same folder, the `]activate .` line will need to be repeated.  
(Or skip the activating part and just `dev` the packages to make them available everywhere, but I’m not a fan of that)

Though I’m not sure why `using SatPrecip` worked out of the box.

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 24, 2019, 3:27pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/8 "2019-09-24T15:27:32Z")

</div>

I … am not sure either, likely I did something that isn’t quite right either HAHAHA.

But thanks so much! I will try the dev option.

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 24, 2019, 3:46pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/9 "2019-09-24T15:46:18Z")

</div>

Update: The ]dev option works and I’m using it now.

Another question, I keep getting this error during my first time using SatPrecip and ClimateTools (another personal package) when I restart julia:

┌ Warning: Package ClimateTools does not have Dates in its dependencies:  
│ - If you have ClimateTools checked out for development and have  
│ added Dates as a dependency but haven’t updated your primary  
│ environment’s manifest file, try `Pkg.resolve()`.  
│ - Otherwise you may need to report an issue with ClimateTools  
└ Loading Dates into ClimateTools from project dependency, future warnings for ClimateTools are suppressed.

I have tried using Pkg.resolve() but this doesn’t solve the issue. In the Manifest.toml file I can see that Dates is added as a dependency in the main environment (which is what I am developing my packages in).

---

<div class="post-metadata">

**Author:** ![zaki](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zaki/32/10300_2.png) [@zaki](https://discourse.julialang.org/u/zaki)\
**Post date:** [September 24, 2019, 3:57pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/10 "2019-09-24T15:57:21Z")

</div>

I think the package itself may need to be activated before resolving, e.g.

```julia
]activate path/to/ClimateTools
]resolve # or, ]add MissingDependency

```

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 24, 2019, 4:44pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/11 "2019-09-24T16:44:12Z")

</div>

I do suggest that you adjust your workflow to work with rather than against the package manager.

If you develop all packages while the Main Julia environment is active, you are mixing together the dependencies for all the packages that you are working on.

What you want is for each package to be a stand-alone, self-contained code base. All dependencies should be defined in its Project.toml.

My suggestion is to keep the Main environment minimal. Just `Pkg.add` development tools (`Revise`, `OhMyREPL`, etc).

When you want to work on package `A`, it’s best to activate its environment, and explicitly `add` or `dev` dependencies there.

As for the `ClimateTools` package, it sounds like you need to `>pkg add Dates` in its environment.

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 24, 2019, 7:21pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/12 "2019-09-24T19:21:44Z")

</div>

It’s a bit … complicated per se. I’m still very used to a MATLAB-kind of workflow where if I needed to I could just point the program to look at a certain directory that stores relevant codes.

So, for example in this case, ClimateTools and SatPrecip are different packages. But in the end, I still would want SatPrecip to be able to use some functions from the ClimateTools package, because ClimateTools is a general set of personal-developed functions that can be used for a variety of purposes while SatPrecip is meant for the download and plotting of specific datasets. But I am developing ClimateTools at the same time while I am developing SatPrecip.

In this case, what sort of workflow should I use?

---

<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 24, 2019, 9:25pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/13 "2019-09-24T21:25:13Z")

</div>

You are describing a very common workflow:

```julia
pkg> activate /path/to/SatPrecip
pkg> develop /path/to/ClimateTools

```

This will allow you to `import ClimateTools` from within `SatPrecip`. In general, before you work on any project, you first have to `Pkg.activate()` it.

I agree with the advice given by @hendri54: people should rarely modify `LOAD_PATH`.

---

<div class="post-metadata">

**Author:** ![Amin\_Yahyaabadi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amin_yahyaabadi/32/9826_2.png) [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Post date:** [September 24, 2019, 10:13pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/14 "2019-09-24T22:13:52Z")

</div>

> [@Management of Packages in Julia](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/12):
>
> It’s a bit … complicated per se. I’m still very used to a MATLAB-kind of workflow where if I needed to I could just point the program to look at a certain directory that stores relevant codes. So, for example in this case, ClimateTools and SatPrecip are different packages. But in the end, I still would want SatPrecip to be able to use some functions from the ClimateTools package, because ClimateTools is a general set of personal-developed functions that can be used for a variety of purposes w…

Advantage of my code which uses `LOAD_Path` is that the code runs wherever it is on the drive.  
You don’t need to add or dev anything. You just cd to the directory and run the code (very similar to Matlab)!

For real usage or distributing, it makes sense to add the package permanently.

---

<div class="post-metadata">

**Author:** ![natgeo-wong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/natgeo-wong/32/10965_2.png) [@natgeo-wong](https://discourse.julialang.org/u/natgeo-wong)\
**Post date:** [September 25, 2019, 4:40am UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/15 "2019-09-25T04:40:40Z")

</div>

What if I was working on another package (e.g. ERApkg), while at the same time developing ClimateTools?

Is it possible to have ClimateTools be developed on two different activated environments/packages or whatever the term is?

Apologies, very new to Julia, but would like to learn about using Julia most efficiently in its native format.

---

<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 25, 2019, 5:23am UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/16 "2019-09-25T05:23:51Z")

</div>

Sure, `pkg> develop /some/path` just tells `Pkg` to _directly_ use whatever package happens to be at `/some/path`. You can think of it as the simplest(least structured) way to add a dependency to the active environment. Multiple packages can depend on the same package, this is not an issue.

Please ask more questions if this is still confusing 🙂

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 25, 2019, 12:25pm UTC](https://discourse.julialang.org/t/management-of-packages-in-julia/29098/17 "2019-09-25T12:25:39Z")

</div>

It would probably be a good idea to read the `Pkg.jl` docs.

Think of `Pkg.develop` as editing the `Project.toml` for the _currently active environment_ (and only for that environment). `develop` adds a line to that environment that points to (by default) `julia/dev/MyPackage`. That’s all that happens.

Then, when you issue `using MyPackage` _in this environment_, Julia looks up where to find `MyPackage` in the environment’s `Project.toml`. Any changes you make to the code in `julia/dev/MyPackage` gets “tracked.”

`Pkg.add` edits `Project.toml` adding a line that points to `https://github.com/user/MyPackage.git` with one fixed `sha` (commit) code. That’s the version of the code that will be used _in that environment_.

So you can `develop MyPackage` in one environment and `add MyPackage` in another. No Problem.
