# ConcurrencyViolationError in UnitfulExt

**URL:** <https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069>\
**Category:** General Usage\
**Tags:** question, package, plots\
**Created:** [March 25, 2024, 9:08am UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069 "2024-03-25T09:08:43Z")\
**Posts on this page:** 11\
**Page:** 1

<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:** [March 25, 2024, 9:08am UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/1 "2024-03-25T09:08:43Z")

</div>

I get the following pre-compilation error:

```julia
⠇ [00m:15s] PackageCompiler: compiling incremental system image┌ Error: Error during loading of extension UnitfulExt of Plots, use `Base.retry_load_extensions()` to retry.
│ exception = 1-element ExceptionStack:
ConcurrencyViolationError("deadlock detected in loading UnitfulLatexify -> UnitfulLatexify && UnitfulExt")
Stacktrace:
  [1] start_loading(modkey::Base.PkgId)
    @ Base ./loading.jl:1637
  [2] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::Nothing, sourcepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1469
  [3] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1574
  [4] _require(pkg::Base.PkgId, env::Nothing)
    @ Base ./loading.jl:1938
  [5] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
    @ Base ./loading.jl:1812
  [6] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
  [7] invokelatest
    @ ./essentials.jl:889 [inlined]
  [8] _require_prelocked
    @ ./loading.jl:1805 [inlined]
  [9] _require_prelocked
    @ ./loading.jl:1802 [inlined]
 [10] run_extension_callbacks(extid::Base.ExtensionId)
    @ Base ./loading.jl:1295
 [11] run_extension_callbacks(pkgid::Base.PkgId)
    @ Base ./loading.jl:1330
 [12] run_package_callbacks(modkey::Base.PkgId)
    @ Base ./loading.jl:1164
 [13] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::Nothing, sourcepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1487
 [14] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1574
 [15] _require(pkg::Base.PkgId, env::Nothing)
    @ Base ./loading.jl:1938
 [16] __require_prelocked(uuidkey::Base.PkgId, env::Nothing)
    @ Base ./loading.jl:1812
 [17] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [18] invokelatest
    @ ./essentials.jl:889 [inlined]
 [19] _require_prelocked
    @ ./loading.jl:1805 [inlined]
 [20] _require_prelocked
    @ ./loading.jl:1802 [inlined]
 [21] macro expansion
    @ ./lock.jl:267 [inlined]
 [22] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:1797
 [23] top-level scope
    @ /tmp/jl_FIJiV8Hk7q:278
 [24] include(mod::Module, _path::String)
    @ Base ./Base.jl:495
 [25] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:318
 [26] _start()
    @ Base ./client.jl:552
└ @ Base loading.jl:1301

```

Is that a bug in `Plots.jl` ?

So far I cannot reproduce it without using PackageCompiler…

---

<div class="post-metadata">

**Author:** ![phduk](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phduk/32/50470_2.png) [@phduk](https://discourse.julialang.org/u/phduk)\
**Post date:** [April 17, 2024, 11:26pm UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/2 "2024-04-17T23:26:15Z")

</div>

I got the same error message while creating a sysimage with my package.

---

<div class="post-metadata">

**Author:** ![Baptiste\_Labat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baptiste_labat/32/208950_2.png) [@Baptiste\_Labat](https://discourse.julialang.org/u/Baptiste_Labat)\
**Post date:** [May 1, 2024, 9:27pm UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/3 "2024-05-01T21:27:20Z")

</div>

Hi Uwe, I am reproducing the same error trying to install KiteSimulators.jl.

---

<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:** [May 2, 2024, 1:19am UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/4 "2024-05-02T01:19:53Z")

</div>

Welcome in the forum!

What is the output of

```julia
versioninfo()

```

from the Julia prompt?

---

<div class="post-metadata">

**Author:** ![Baptiste\_Labat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baptiste_labat/32/208950_2.png) [@Baptiste\_Labat](https://discourse.julialang.org/u/Baptiste_Labat)\
**Post date:** [May 2, 2024, 4:52am UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/5 "2024-05-02T04:52:21Z")

</div>

Here is the output of

> versioninfo()

> Julia Version 1.10.3  
> Commit 0b4590a5507 (2024-04-30 10:59 UTC)  
> Build Info:  
> Official [https://julialang.org/](https://julialang.org/) release  
> Platform Info:  
> OS: Linux (x86\_64-linux-gnu)  
> CPU: 12 × Intel(R) Core™ i7-9850H CPU @ 2.60GHz  
> WORD\_SIZE: 64  
> LIBM: libopenlibm  
> LLVM: libLLVM-15.0.7 (ORCJIT, skylake)  
> Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

---

<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:** [May 2, 2024, 5:59am UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/6 "2024-05-02T05:59:14Z")

</div>

I think I will remove `Plots.jl` from `KiteSimulators.jl` and replace it with `ControlPlots.jl`, it is just causing too many hard-to-debug issues.

For the time beeing I suggest to use `KiteControllers.jl` directly:

```julia
mkdir repos
cd repos 
git clone https://github.com/aenarete/KiteControllers.jl
cd KiteControllers.jl/bin
time ./create_sys_image --update
./autopilot

```

`repos` is just the directory where I store my source code, could be any other directory.

Does this work for you? Creating the system image might take 30 minutes, but is only required once.

Instead of `./autopilot` you can also do `./run_julia` and then, at the julia prompt run `include("examples/autopilot.jl")`. I have `alias jl='./bin/run_julia'` in my .bashrc file to make my life easier.

On Linux you can also install the app as normal program running `./install` .

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 2, 2024, 6:17am UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/7 "2024-05-02T06:17:02Z")

</div>

I don’t know anything about your package but isn’t the normal way to integrate Plots in a larger package to define recipes and let the user take care of installing and then `using Plots`?

---

<div class="post-metadata">

**Author:** ![Baptiste\_Labat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baptiste_labat/32/208950_2.png) [@Baptiste\_Labat](https://discourse.julialang.org/u/Baptiste_Labat)\
**Post date:** [May 2, 2024, 10:04am UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/8 "2024-05-02T10:04:05Z")

</div>

Thanks Uwe for this workaround, it worked (I just had one error as matplotlib was not used in the conda environment PyCall was pointing to, but after solving this, it was OK).

---

<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:** [May 2, 2024, 4:12pm UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/9 "2024-05-02T16:12:43Z")

</div>

I just tested this myself, and the error you got is actually only a warning and can safely be ignored… Just in case anybody else is reading this.

---

<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:** [May 6, 2024, 1:37pm UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/10 "2024-05-06T13:37:13Z")

</div>

I am trying to get rid of this error without success. I removed all dependencies of Plots in my project, but the error sustains:

```julia
⢰ [00m:19s] PackageCompiler: compiling incremental system image┌ Error: Error during loading of extension UnitfulExt of Plots, use `Base.retry_load_extensions()` to retry.
│ exception = 1-element ExceptionStack:
ConcurrencyViolationError("deadlock detected in loading UnitfulLatexify -> UnitfulLatexify && UnitfulExt")
Stacktrace:
  [1] start_loading(modkey::Base.PkgId)
    @ Base ./loading.jl:1637
  [2] _tryrequire_from_serialized(modkey::Base.PkgId, path::String, ocachepath::Nothing, sourcepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1469

```

I do not have UnitfulLatexify in my Manifest.toml, and Unitful appears only as extension of DiffEqBase:

```julia
[[deps.DiffEqBase]]
deps = ["ArrayInterface", "ConcreteStructs", "DataStructures", "DocStringExtensions", "EnumX", "EnzymeCore", "FastBroadcast", "FastClosures", "ForwardDiff", "FunctionWrappers", "FunctionWrappersWrappers", "LinearAlgebra", "Logging", "Markdown", "MuladdMacro", "Parameters", "PreallocationTools", "PrecompileTools", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "Setfield", "SparseArrays", "Static", "StaticArraysCore", "Statistics", "Tricks", "TruncatedStacktraces"]
git-tree-sha1 = "531c53fd0405716712a8b4960216c3b7b5ec89b9"
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
version = "6.149.1"

    [deps.DiffEqBase.extensions]
    DiffEqBaseChainRulesCoreExt = "ChainRulesCore"
    DiffEqBaseDistributionsExt = "Distributions"
    DiffEqBaseEnzymeExt = ["ChainRulesCore", "Enzyme"]
    DiffEqBaseGeneralizedGeneratedExt = "GeneralizedGenerated"
    DiffEqBaseMPIExt = "MPI"
    DiffEqBaseMeasurementsExt = "Measurements"
    DiffEqBaseMonteCarloMeasurementsExt = "MonteCarloMeasurements"
    DiffEqBaseReverseDiffExt = "ReverseDiff"
    DiffEqBaseTrackerExt = "Tracker"
    DiffEqBaseUnitfulExt = "Unitful"

    [deps.DiffEqBase.weakdeps]
    ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
    Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
    Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
    GeneralizedGenerated = "6b9d7cbe-bcb9-11e9-073f-15a7a543e2eb"
    MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
    Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
    MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
    ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
    Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
    Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

```

Is this a bug in DiffEqBase?

---

<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:** [May 6, 2024, 2:29pm UTC](https://discourse.julialang.org/t/concurrencyviolationerror-in-unitfulext/112069/11 "2024-05-06T14:29:44Z")

</div>

I found a workaround/ solution:  
Adding the parameter:

```julia
    include_transitive_dependencies=false

```

solves the issue.

The whole call now looks like this:

```julia
PackageCompiler.create_sysimage(
    [:KiteSimulators, :ControlPlots];
    sysimage_path="kps-image_tmp.so",
    include_transitive_dependencies=false,
    precompile_execution_file=joinpath("test", "test_for_precompile.jl")
)

```
