# How to properly use \[compat\] section of project.toml?

**URL:** <https://discourse.julialang.org/t/how-to-properly-use-compat-section-of-project-toml/79855>\
**Category:** Package Management\
**Created:** [April 22, 2022, 4:53pm UTC](https://discourse.julialang.org/t/how-to-properly-use-compat-section-of-project-toml/79855 "2022-04-22T16:53:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane\_Kelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shane_kelly/32/23496_2.png) [@Shane\_Kelly](https://discourse.julialang.org/u/Shane_Kelly)\
**Post date:** [April 22, 2022, 4:53pm UTC](https://discourse.julialang.org/t/how-to-properly-use-compat-section-of-project-toml/79855/1 "2022-04-22T16:53:05Z")

</div>

I am attempting to use the [compat] section to fix the version of a package, say package C, in a package, say A, that I am developing. Suppose the most up to date version of C is C@1.4 while my project.toml for project A looks like:

```julia
[compat]
C = "1.1"

```

The issue I face occurs when, in a different project I am working on, say project B, I add the local version of package A:

```julia
]add /Users/local/path/to/A/

```

but then I see something like:

```julia
[0230ef0123] + C v1.4

```

in the log produced while adding package A to project B.

I then go back and look at the project.toml in package A, and it has been overwritten with the [compat] section removed.

How should add package A to project B instead such that package C v1.1 is added and not Cv1.4?

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [April 22, 2022, 5:52pm UTC](https://discourse.julialang.org/t/how-to-properly-use-compat-section-of-project-toml/79855/3 "2022-04-22T17:52:55Z")

</div>

Note that `C = "1.1"` doesnt mean exactly 1.1, it means anything [semver compatible](https://pkgdocs.julialang.org/v1/compatibility/) with 1.1, so basically `[1.1, 2)`, which includes `1.4`. For exactly 1.1 you want `C = "=1.1"`.

That may be playing a role. I’m not sure why this is happening though:

> [@Shane\_Kelly](#):
>
> I then go back and look at the project.toml in package A, and it has been overwritten with the [compat] section removed.

---

<div class="post-metadata">

**Author:** ![Shane\_Kelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shane_kelly/32/23496_2.png) [@Shane\_Kelly](https://discourse.julialang.org/u/Shane_Kelly)\
**Post date:** [April 25, 2022, 10:53am UTC](https://discourse.julialang.org/t/how-to-properly-use-compat-section-of-project-toml/79855/4 "2022-04-25T10:53:13Z")

</div>

Thanks for clarifying how to specify versions. I do still have this odd issue of the project.toml being overwritten.

---

<div class="post-metadata">

**Author:** ![Shane\_Kelly](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shane_kelly/32/23496_2.png) [@Shane\_Kelly](https://discourse.julialang.org/u/Shane_Kelly)\
**Post date:** [March 20, 2023, 5:32pm UTC](https://discourse.julialang.org/t/how-to-properly-use-compat-section-of-project-toml/79855/5 "2023-03-20T17:32:36Z")

</div>

The issue regarding [compat] section being overwritten had to do with the difference between develop and add, and having not preformed a git commit.
