# Help with Package Dependencies

**URL:** <https://discourse.julialang.org/t/help-with-package-dependencies/47819>\
**Category:** New to Julia\
**Created:** [October 6, 2020, 12:11am UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819 "2020-10-06T00:11:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [October 6, 2020, 12:11am UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/1 "2020-10-06T00:11:28Z")

</div>

I am experimenting with creation of my first package called OHTLCSM.jl. I followed the steps at the link below to add the package to my local repository:

Link: [Simple Package Tutorial](https://tlienart.github.io/pub/julia/dev-pkg.html)

StaticArrays.jl was among the dependencies I added from the repl via:

```julia
(@v1.5) pkg > activate .
(OHTLCSM) pkg > add StaticArrays Updating registry at `C:\Users\myusername\.julia\registries\General`
   Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Resolving package versions...
   No Changes to `C:\Users\myusername\.julia\dev\OHTLCSM\Project.toml`
   No Changes to `C:\Users\myusername\.julia\dev\OHTLCSM\Manifest.toml`
(@v1.5) pkg > activate
   Activating environment at `C:\Users\myusername\.julia\environments\v1.5\Project.toml`

```

The package pre-compiles ok, but I get the following error when I run the one function in the package:

`UndefVarError: SVector not defined`

It seems like the dependency was not established properly. Is the procedure I used above valid? The code works fine outside the package environment.

Is it necessary to include the `using StaticArrays` statement inside the module if dependencies have been added via the repl?

---

<div class="post-metadata">

**Author:** ![timquelch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timquelch/32/18278_2.png) [@timquelch](https://discourse.julialang.org/u/timquelch)\
**Post date:** [October 6, 2020, 12:15am UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/2 "2020-10-06T00:15:30Z")

</div>

> [@jleman](#):
>
> Is it necessary to include the `using StaticArrays` statement inside the module if dependencies have been added via the repl?

Yes

Pkg `add` makes it available, but to actually use it in your module you need to `using` or `import` the module

---

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [October 6, 2020, 12:41am UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/3 "2020-10-06T00:41:08Z")

</div>

Just to be clear, I would need to include it inside the module, like this?

```julia
module OHTLCSM
export csm

using StaticArrays

function csm()
    #my function that uses StaticArrays.jl as a dependency
end

end

```

---

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [October 6, 2020, 1:08am UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/4 "2020-10-06T01:08:38Z")

</div>

I added the line:

```julia
using StaticArrays

```

inside the module as shown in my previous post. I now get the following warning:

```julia
┌ Info: Precompiling OHTLCSM [792a8791-1285-4c47-952b-f0f8acb5a785]
└ @ Base loading.jl:1278
┌ Warning: Package OHTLCSM does not have StaticArrays in its dependencies:
│ - If you have OHTLCSM checked out for development and have
│ added StaticArrays 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 OHTLCSM
└ Loading StaticArrays into OHTLCSM from project dependency, future warnings for OHTLCSM are suppressed.

```

I tried the resolve() function as it states, but I continue to get the warning. However, the package seems to work fine. Any suggestions as to why I still get this warning?

---

<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:** [October 6, 2020, 2:03am UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/5 "2020-10-06T02:03:29Z")

</div>

You still have to activate/instantiate the package OHTLCSM. Then `using OHTLCSM` should run without a warning.

---

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [October 6, 2020, 5:04am UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/6 "2020-10-06T05:04:15Z")

</div>

For the benefit of any other folks who are also very new to this process, I assume by activate/instantiate you mean execution of:

```julia
(@v1.5) pkg> add OHTLCSM

```

I had not done that, but assumed this is what you meant and it did fix the problem.

---

<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:** [October 6, 2020, 2:58pm UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/7 "2020-10-06T14:58:25Z")

</div>

Actually, no. I assumed the mode where one has a folder with the package. One could then start Julia in that folder and activate/instantiate followed by `using`.

---

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [October 6, 2020, 3:02pm UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/8 "2020-10-06T15:02:17Z")

</div>

Ok, that makes sense as well. Thank you.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [October 6, 2020, 3:21pm UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/9 "2020-10-06T15:21:37Z")

</div>

> [@jleman](#):
>
> I assume by activate/instantiate you mean execution of:

No, “activate” and “instantiate” are terms specific to the Julia package manager here, and they refer to literally using the `pkg> activate` and `pkg> instantiate` commands. You can learn more about what those commands do over at [Pkg · The Julia Language](https://docs.julialang.org/en/v1.0/stdlib/Pkg/#Using-someone-else's-project-1)

---

<div class="post-metadata">

**Author:** ![jleman](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@jleman](https://discourse.julialang.org/u/jleman)\
**Post date:** [October 6, 2020, 3:29pm UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/10 "2020-10-06T15:29:31Z")

</div>

Following the steps listed in the link on my previous post I entered shell from the repl and cd’d to the package folder. I then entered `activate .` , then I added dependencies, finally I exited with `activate`. However, I did not use `instantiate`. When I added my package in the repl with `add OHTLCSM` it seemed to fix the problem I was having. Is that a lucky accident or did that also instantiate?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [October 6, 2020, 3:34pm UTC](https://discourse.julialang.org/t/help-with-package-dependencies/47819/11 "2020-10-06T15:34:45Z")

</div>

It sounds like you did everything right. `instantiate` takes an existing `Project` and `Manifest` and installs all of the packages listed in those files for the active package environment. Since you’ve already installed those packages via `pkg> add` in this environment, there is nothing for `instantiate` to do.
