# Confused about package management

**URL:** https://discourse.julialang.org/t/confused-about-package-management/102954
**Category:** New to Julia
**Tags:** question, package
**Created:** [August 18, 2023, 1:55pm UTC](https://discourse.julialang.org/t/confused-about-package-management/102954 "2023-08-18T13:55:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bwanab](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bwanab/32/35903_2.png) [@bwanab](https://discourse.julialang.org/u/bwanab)
#### Post date: [August 18, 2023, 1:55pm UTC](https://discourse.julialang.org/t/confused-about-package-management/102954/1 "2023-08-18T13:55:33Z")

</div>

Hi. Sorry this question might seem confused because I’m confused.

I’ve been working with a local package with no problems. Sounds good, but today I was going to set up a new project and I thought I’d use PkgTemplates as suggested in the docs. This lead to a surprise that I’m confused about. Below, I’ve got a shell dialog. I start by going into my current project, get into Pkg and get status - everything ok. I go one level up in directory from that project where I want to set up my new project, go into pkg to add PkgTemplates and there’s an error reported with my other package that I don’t understand. My understanding of packages (please correct me if I’m wrong) is that when I’m in the directory of a package and use ‘julia --project’ that I’m now in that package’s environment. Then, likewise, if I’m not in a package I’m using the global environment.

Does this error imply that I set the AZ\_Reversi.jl package up incorrectly? If so, how do I correct it? If not, how do I proceed in adding PkgTemplate?

```julia
bill@Williams-Air src % pwd
/Users/bill/src
bill@Williams-Air src % cd AZ_Reversi.jl 
bill@Williams-Air AZ_Reversi.jl % pwd
/Users/bill/src/AZ_Reversi.jl
bill@Williams-Air AZ_Reversi.jl % julia --project
... startup stuff removed ...
(AZ_Reversi) pkg> status
Project AZ_Reversi v0.1.0
Status `~/src/AZ_Reversi.jl/Project.toml`
  [8ed9eb0b] AlphaZero v0.5.4
  [c7e460c6] ArgParse v1.1.4
  [a8cc5b0e] Crayons v4.1.1
  [cd3eb016] HTTP v1.9.14
  [4138dd39] JLD v0.13.3
  [df9a0d86] Oxygen v1.1.11
  [295af30f] Revise v3.5.3
⌃ [90137ffa] StaticArrays v1.5.26
  [1b6eb727] SwaggerMarkdown v0.2.1
  [ddb6d928] YAML v0.4.9
  [cf7118a7] UUIDs
Info Packages marked with ⌃ have new versions available and may be upgradable.

(AZ_Reversi) pkg> ^C

julia> 
bill@Williams-Air AZ_Reversi.jl % cd ..
bill@Williams-Air src % julia --project
... startup stuff removed ...
(@v1.9) pkg> status
Status `~/.julia/environments/v1.9/Project.toml`
→ [479812a0] AZReversi v0.1.0 `../../../src/AZReversi`
→ [197bbe58] AZ_Reversi v0.1.0 `../../../src/AZ_Reversi`
  [8ed9eb0b] AlphaZero v0.5.4 `~/src/AlphaZero.jl`
  [a8cc5b0e] Crayons v4.1.1
⌃ [a93c6f00] DataFrames v1.5.0
⌃ [c3e4b0f8] Pluto v0.19.25
  [295af30f] Revise v3.5.3
⌃ [90137ffa] StaticArrays v1.5.26
Info Packages marked with → are not downloaded, use `instantiate` to download
Info Packages marked with ⌃ have new versions available and may be upgradable.

```

One other clue is in ~/.julia/environments/v1.9/Manifest.toml:

```julia
[[deps.AZReversi]]
deps = ["AlphaZero"]
path = "../../../src/AZReversi"
uuid = "479812a0-3da7-4be1-b6d2-59909e2c68c0"
version = "0.1.0"

[[deps.AZ_Reversi]]
deps = ["AlphaZero", "Crayons", "StaticArrays"]
path = "../../../src/AZ_Reversi"
uuid = "197bbe58-db13-46b8-9db2-48c8d20fa952"
version = "0.1.0"

```

---

<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: [August 18, 2023, 2:03pm UTC](https://discourse.julialang.org/t/confused-about-package-management/102954/2 "2023-08-18T14:03:44Z")

</div>

> [@bwanab](#):
>
> Does this error imply that I set the AZ\_Reversi.jl package up incorrectly? If so, how do I correct it? If not, how do I proceed in adding PkgTemplate?

Generally what I do is to create a _new_ package with PkgTemplates, and then copy the source files of the “project” into the `/src` directory of the new package. A package is something a little more complex than a project. A project is just a directory with a Manifest.toml and a Project.toml files. A package has a specific directory structure and a main file name called “MyProject.jl” in the ‘src’ directory.

If you want very simple instructions on how to create a new “package”, check this: [Create new package · JuliaNotes.jl](https://m3g.github.io/JuliaNotes.jl/stable/new_package/).

I would not mix those steps with your current project directory structure. Just copy what you need after the package has been created.

---

<div class="post-metadata">

### Author: ![bwanab](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bwanab/32/35903_2.png) [@bwanab](https://discourse.julialang.org/u/bwanab)
#### Post date: [August 18, 2023, 3:47pm UTC](https://discourse.julialang.org/t/confused-about-package-management/102954/3 "2023-08-18T15:47:00Z")

</div>

Thanks. That advice makes sense. However, I still have a problem in that outside of the context of my AZ\_Reversi.jl project, I can’t install PkgTemplates.

Considering my ~/.julia/environments/v1.9/Manifest.toml, would it make sense to edit that file by hand and remove the AZReversi records (since it doesn’t exist at all), and change the path of the AZ\_Reversi records to be the absolute path instead of the relative path that it’s got? I know the file says not to edit it at the top, but these seem like easy enough edits to do.

---

<div class="post-metadata">

### Author: ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)
#### Post date: [August 18, 2023, 4:10pm UTC](https://discourse.julialang.org/t/confused-about-package-management/102954/4 "2023-08-18T16:10:18Z")

</div>

I think you are better off removing these erroneous entries. No need for editing a file hand though. Simple open a REPL with the global environment, go to pkg mode by typing “]” and then remove them with `rm AZReversi AZ_Reversi` 🙂

If you ever edit a Manifest.toml, after you should activate the project and do a do a `resolve` (in pkg mode) to ensure consistency.

---

<div class="post-metadata">

### Author: ![bwanab](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bwanab/32/35903_2.png) [@bwanab](https://discourse.julialang.org/u/bwanab)
#### Post date: [August 18, 2023, 4:59pm UTC](https://discourse.julialang.org/t/confused-about-package-management/102954/5 "2023-08-18T16:59:58Z")

</div>

Thanks. Makes sense.

---

<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: [August 18, 2023, 7:44pm UTC](https://discourse.julialang.org/t/confused-about-package-management/102954/6 "2023-08-18T19:44:51Z")

</div>

It is likely better to just remove everything from your global environment, leaving there only packages that are routinely used for development (like `Revise`, for example).

For example, when using `PkgTemplates`, it is actually better to just start a temporary environment and install and use it there, so it does not clutter your default environment. Thus, use

```julia
julia> ] activate --temp 

(jl_ML0bEf) pkg> add PkgTemplates

julia> using PkgTemplates # and etc

```

---

<div class="post-metadata">

### Author: ![bwanab](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bwanab/32/35903_2.png) [@bwanab](https://discourse.julialang.org/u/bwanab)
#### Post date: [August 18, 2023, 8:17pm UTC](https://discourse.julialang.org/t/confused-about-package-management/102954/7 "2023-08-18T20:17:15Z")

</div>

Got it. Thanks!
