# Package compatibility constraints

**URL:** <https://discourse.julialang.org/t/package-compatibility-constraints/103217>\
**Category:** General Usage\
**Tags:** package, compatibility\
**Created:** [August 26, 2023, 9:54am UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217 "2023-08-26T09:54:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [August 26, 2023, 9:54am UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/1 "2023-08-26T09:54:40Z")

</div>

I put the following line into a Project.toml for a package and am trying to figure out what consequences it has:

```toml
[compat]
julia = "1.0 - 1.7"

```

When I try to add this package in another package from Julia 1.9.3 it is accepted without a warning and I can use it without warnings or incorrect behaviour. What consequences should I expect with compatibility specifications in a package?

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [August 26, 2023, 11:09am UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/2 "2023-08-26T11:09:06Z")

</div>

> [@GHTaarn](#):
>
> in another package from Julia 1.9.3

What do you mean by this? The version of Julia you are running is v1.9.3?

How are you installing your package? `Pkg.add` or `Pkg.develop`?

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [August 26, 2023, 11:51am UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/3 "2023-08-26T11:51:35Z")

</div>

Yes, Julia version is 1.9.3, installing with add:

````julia-repl
~/Program/UseVerExperiment.jl$ julia --project
Installing Julia 1.9.3+0.x64.linux.gnu
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.9.3 (2023-08-24)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

(UseVerExperiment) pkg> st
  Installing known registries into `~/.julia`
Project UseVerExperiment v0.1.0
Status `~/Program/UseVerExperiment.jl/Project.toml` (empty project)

(UseVerExperiment) pkg> add ../VerExperiment.jl/
     Cloning git-repo `/home/julia/Program/VerExperiment.jl`
    Updating git-repo `/home/julia/Program/VerExperiment.jl`
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `~/Program/UseVerExperiment.jl/Project.toml`
  [2296e2b5] + VerExperiment v0.1.1 `../VerExperiment.jl#master`
    Updating `~/Program/UseVerExperiment.jl/Manifest.toml`
  [2296e2b5] + VerExperiment v0.1.1 `../VerExperiment.jl#master`
Precompiling project...
  2 dependencies successfully precompiled in 1 seconds

julia> using VerExperiment

julia> VerExperiment.greet()
Hello World!
j```
````

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [August 26, 2023, 12:29pm UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/4 "2023-08-26T12:29:57Z")

</div>

I’m not sure if when you add by path like that, it enforces the Julia version. I’m also interested in the answer, let’s see if some of the Pkg people offer some wisdom.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 28, 2023, 6:10am UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/5 "2023-08-28T06:10:09Z")

</div>

> [@GHTaarn](#):
>
> ```julia
> [compat]
> julia = "1.0 - 1.7"
> 
> ```

Did you try:

```julia
[compat]
julia = "~1.0 - ~1.7"

```

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [August 28, 2023, 7:37am UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/6 "2023-08-28T07:37:46Z")

</div>

> [@ufechner7](#):
>
> Did you try:
> 
> ```julia
> [compat]
> julia = "~1.0 - ~1.7"
> 
> ```

Thanks for the suggestion, I tried it, but Julia did not accept that format. I also tried the more terse

```toml
[compat]
julia = "~1.0, ~1.1, ~1.2, ~1.3, ~1.4, ~1.5, ~1.6, ~1.7"

```

but it still does not lead to the package being rejected

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [August 28, 2023, 7:48am UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/7 "2023-08-28T07:48:03Z")

</div>

To make this easy to reproduce I have published the example on Github [GitHub - GHTaarn/VerExperiment.jl: Experiment about Julia version restrictions](https://github.com/GHTaarn/VerExperiment.jl) so one can just make a temp environment and add it:

```julia-repl
(@v1.9) pkg> activate --temp
  Activating new project at `/tmp/jl_ftvi0S`

(jl_ftvi0S) pkg> add https://github.com/GHTaarn/VerExperiment.jl
  Installing known registries into `~/.julia`
     Cloning git-repo `https://github.com/GHTaarn/VerExperiment.jl`
    Updating git-repo `https://github.com/GHTaarn/VerExperiment.jl`
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `/tmp/jl_ftvi0S/Project.toml`
  [2296e2b5] + VerExperiment v0.1.1 `https://github.com/GHTaarn/VerExperiment.jl#master`
    Updating `/tmp/jl_ftvi0S/Manifest.toml`
  [2296e2b5] + VerExperiment v0.1.1 `https://github.com/GHTaarn/VerExperiment.jl#master`
Precompiling project...
  1 dependency successfully precompiled in 0 seconds

julia> using VerExperiment

julia> VerExperiment.greet()
Hello World!
julia> 

```

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [August 28, 2023, 7:48pm UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/8 "2023-08-28T19:48:06Z")

</div>

I opened an issue about this on Github:

> <https://github.com/JuliaLang/julia/issues/51088>
>
> I created a simple package and in the compat section of Project.toml I restricte…d the compatibility with \`julia = "1.0 - 1.7"\`. I then tried to add this package to a newly activated temp environment from Julia 1.9.3, but this did not produce an error or warning. The following is a snapshot of the REPL:
> 
> \`\`\`julia-repl
> (@v1.9) pkg\> activate --temp
> Activating new project at \`/tmp/jl\_ftvi0S\`
> 
> (jl\_ftvi0S) pkg\> add https://github.com/GHTaarn/VerExperiment.jl
> Installing known registries into \`~/.julia\`
> Cloning git-repo \`https://github.com/GHTaarn/VerExperiment.jl\`
> Updating git-repo \`https://github.com/GHTaarn/VerExperiment.jl\`
> Updating registry at \`~/.julia/registries/General.toml\`
> Resolving package versions...
> Updating \`/tmp/jl\_ftvi0S/Project.toml\`
> \[2296e2b5\] + VerExperiment v0.1.1 \`https://github.com/GHTaarn/VerExperiment.jl#master\`
> Updating \`/tmp/jl\_ftvi0S/Manifest.toml\`
> \[2296e2b5\] + VerExperiment v0.1.1 \`https://github.com/GHTaarn/VerExperiment.jl#master\`
> Precompiling project...
> 1 dependency successfully precompiled in 0 seconds
> 
> julia\> using VerExperiment
> 
> julia\> VerExperiment.greet()
> Hello World!
> julia\>
> \`\`\`
> My understanding is that an error should have resulted. I made a post about this on discourse at https://discourse.julialang.org/t/package-compatibility-constraints/103217 and none of the responses convinced me that this is the intended behaviour of Julia.
> 
> The entire source code of the package is available at https://github.com/GHTaarn/VerExperiment.jl
> 
> I am using Ubuntu 22.04 on x86\_64 with Julia installed with juliaup.
> 
> \<!--
> If you have a question please search or post to our Discourse site: https://discourse.julialang.org.
> We use the GitHub issue tracker for bug reports and feature requests only.
> 
> If you're submitting a bug report, be sure to include as much relevant information as
> possible, including:
> 
> 1. The output of \`versioninfo()\`
> 2. How you installed Julia
> 3. A minimal working example (MWE), also known as a minimum reproducible example
> 
> If you're experiencing a problem with a particular package, open an issue on that
> package's repository instead.
> 
> Thanks for contributing to the Julia project!
> \--\>

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 29, 2023, 6:00am UTC](https://discourse.julialang.org/t/package-compatibility-constraints/103217/9 "2023-08-29T06:00:41Z")

</div>

And it is fixed already 😀  
but only for Julia 1.11… 😮‍💨

> <https://github.com/JuliaLang/Pkg.jl/pull/3526>
>
> Pkg now raises an error if the \`\[compat\]\` entry for \`julia\` is not met for a pac…kage.
> 
> This change was made due to new developers getting confused why their julia 1.8 does not work with a dev-ed package that has a julia compat set to 1.9.
> 
> There is no escape hatch, i.e. this behavior can not be disabled.
