# Creating Package Problem with dependencies

**URL:** https://discourse.julialang.org/t/creating-package-problem-with-dependencies/59897
**Category:** General Usage
**Tags:** package
**Created:** [April 23, 2021, 8:14pm UTC](https://discourse.julialang.org/t/creating-package-problem-with-dependencies/59897 "2021-04-23T20:14:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [April 23, 2021, 8:14pm UTC](https://discourse.julialang.org/t/creating-package-problem-with-dependencies/59897/1 "2021-04-23T20:14:50Z")

</div>

I am trying to write my code to be in packages, and am having some problems. I have used PkgTemplates to create the package. There seem to be a number of problems that may be related.

Which command writes the package name in ~.julia\environments\v1.6\Project.toml? This does not seem to be working.

The [deps] section of the Package (~.julia\dev\SignalProcessing) Project.toml file does not update automatically. I put the following in manually.

```julia
[deps]
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

```

When starting a fresh Julia session and trying to use the template, I get:

```julia
julia> using SignalProcessing
[Info: Precompiling SignalProcessing [be4cc790-dfbe-46ff-92ed-31160d9fa9b4]
┌ Warning: Package SignalProcessing does not have Statistics in its dependencies:
│ - If you have SignalProcessing checked out for development and have
│ added Statistics 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 SignalProcessing
└ Loading Statistics into SignalProcessing from project dependency, future warnings for SignalProcessing are suppressed.

julia> 

```

I did review the package section in “Hands On Desigh Patterns and Best Prctices in Julia” and the blog by [Chris](https://www.juliabloggers.com/developing-julia-packages/).

---

<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: [April 23, 2021, 9:13pm UTC](https://discourse.julialang.org/t/creating-package-problem-with-dependencies/59897/2 "2021-04-23T21:13:39Z")

</div>

> [@Jake](#):
>
> Which command writes the package name in ~.julia\environments\v1.6\Project.toml? This does not seem to be working.

With the environment `v1.6` activated, issue  
`pkg> dev "~/.julia/dev/SignalProcessing"`  
This adds an entry for that package.

As a general note, it is best to keep the `v1.6` environment “clean.” Anything you add there will be visible everywhere.

To add dependencies to `SignalProcessing`, activate that environment  
`pkg> activate "~/.julia/dev/SignalProcessing"`  
and  
`pkg> add Statistics`

---

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [April 23, 2021, 10:37pm UTC](https://discourse.julialang.org/t/creating-package-problem-with-dependencies/59897/3 "2021-04-23T22:37:36Z")

</div>

Issuing the command gives me the following

```julia
(@v1.6) pkg> dev "~/.julia/dev/SignalProcessing"
ERROR: Unable to parse `~/.julia/dev/SignalProcessing` as a package.

```

and sorry if this should be obvious, but what do the commands  
`pkg> activate "~/.julia/dev/SignalProcessing"`  
and  
`pkg> add Statistics`  
actually do? Do they update the Project.toml file or something else?

I have added the using commands at the top of the SignalProcessing.jl file as shown below, so presumably these commands do something different.

```julia
module SignalProcessing

using FFTW, DSP
import Statistics: mean
include("SignalIntegrate.jl")
include("window.jl")
include("impactvalue.jl")

using Reexport
@reexport using .SignalIntegrate, .Impact, .Windows

end

```

---

<div class="post-metadata">

### Author: ![josePereiro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josepereiro/32/17322_2.png) [@josePereiro](https://discourse.julialang.org/u/josePereiro)
#### Post date: [April 23, 2021, 11:06pm UTC](https://discourse.julialang.org/t/creating-package-problem-with-dependencies/59897/4 "2021-04-23T23:06:11Z")

</div>

> [@Jake](#):
>
> pkg\> activate “~/.julia/dev/SignalProcessing”

The julia `Pkg` always act over an activated julia environment. The `activate` command tells `Pkg` which environment to use. By default when a new julia section is started (by using just a `julia` command in a terminal for instance) the activated environment is the global one according to the julia version (In your case `v1.6`)

> [@Jake](#):
>
> `pkg> add Statistics`  
> actually do? Do they update the Project.toml file or something else?

Yes, it will add the given package to the current activated environment. Here, adding means to include the package information into the `Project.toml` and `Manifest.toml` of the that environment

> [@Jake](#):
>
> I have added the using commands at the top of the SignalProcessing.jl file as shown below, so presumably these commands do something different.

Well, `using`/`import` commands are for loading code, and its actions do not have any effect on the environment state. But, it have common concepts with the previous subject. The code loading system use the information stored in the `Project.toml` and `Manifest.toml` files, of the `activate`d environment, to know what packages to load and which versions.

---

<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: [April 24, 2021, 12:28pm UTC](https://discourse.julialang.org/t/creating-package-problem-with-dependencies/59897/5 "2021-04-24T12:28:38Z")

</div>

Packages and environments tend to be confusing at first (if you come from a language that does not have them). There really is now way around reading the docs.

As it so happens, I am teaching this stuff right now (talk about the one-eyed leading the blind!). So the material at

[https://lhendricks.org/econ890/julia/outline.html](https://lhendricks.org/econ890/julia/outline.html)

and

> **[julia\_notes.pdf](https://lhendricks.org/julia/julia_notes.pdf)**
>
> 220.49 KB

may be helpful.
