# Failed to precompile CSV in Pluto...?

**URL:** <https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633>\
**Category:** Pluto\
**Tags:** csv, pluto\
**Created:** [February 4, 2021, 5:23pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633 "2021-02-04T17:23:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [February 4, 2021, 5:23pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/1 "2021-02-04T17:23:11Z")

</div>

Just started a fresh project environment this morning and CSV won’t compile when calling `using CSV` from within Pluto. It works just fine when calling from REPL, the error only occurs when using Pluto.

The error in my notebook is:

```julia
Failed to precompile CSV [336ed68f-0bac-5ca0-87d4-7b16caf5d00b] to C:\Users\mthel\.julia\compiled\v1.5\CSV\HHBkp_tAWrN.ji.

error(::String)@error.jl:33
compilecache(::Base.PkgId, ::String)@loading.jl:1305
_require(::Base.PkgId)@loading.jl:1030
require(::Base.PkgId)@loading.jl:928
require(::Module, ::Symbol)@loading.jl:923
top-level scope@Local: 1

```

And then the REPL looks like this:

```julia
      From worker 2: ERROR: LoadError: UndefVarError: invrefpool not defined
      From worker 2: Stacktrace:
      From worker 2: [1] getproperty(::Module, ::Symbol) at .\Base.jl:26
      From worker 2: [2] top-level scope at C:\Users\mthel\.julia\packages\PooledArrays\4I2sD\src\PooledArrays.jl:162  
      From worker 2: [3] include(::Function, ::Module, ::String) at .\Base.jl:380
      From worker 2: [4] include(::Module, ::String) at .\Base.jl:368
      From worker 2: [5] top-level scope at none:2
      From worker 2: [6] eval at .\boot.jl:331 [inlined]
      From worker 2: [7] eval(::Expr) at .\client.jl:467
      From worker 2: [8] top-level scope at .\none:3
      From worker 2: in expression starting at C:\Users\mthel\.julia\packages\PooledArrays\4I2sD\src\PooledArrays.jl:162
      From worker 2: ERROR: LoadError: Failed to precompile PooledArrays [2dfb63ee-cc39-5dd5-95bd-886bf059d720] to C:\Users\mthel\.julia\compiled\v1.5\PooledArrays\vi11X_tAWrN.ji.
      From worker 2: Stacktrace:
      From worker 2: [1] error(::String) at .\error.jl:33
      From worker 2: [2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1305
      From worker 2: [3] _require(::Base.PkgId) at .\loading.jl:1030
      From worker 2: [4] require(::Base.PkgId) at .\loading.jl:928
      From worker 2: [5] require(::Module, ::Symbol) at .\loading.jl:923
      From worker 2: [6] include(::Function, ::Module, ::String) at .\Base.jl:380
      From worker 2: [7] include(::Module, ::String) at .\Base.jl:368
      From worker 2: [8] top-level scope at none:2
      From worker 2: [9] eval at .\boot.jl:331 [inlined]
      From worker 2: [10] eval(::Expr) at .\client.jl:467
      From worker 2: [11] top-level scope at .\none:3
      From worker 2: in expression starting at C:\Users\mthel\.julia\packages\CSV\YUbbG\src\CSV.jl:15

```

So the problem appears to be with PooledArrays. Is this something wrong with setup on my end or should I file an issue?

Line 162 from PooledArrays.jl is `DataAPI.invrefpool(pa::PooledArray) = pa.invpool`.

---

<div class="post-metadata">

**Author:** ![thatcher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thatcher/32/21708_2.png) [@thatcher](https://discourse.julialang.org/u/thatcher)\
**Post date:** [February 4, 2021, 7:14pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/2 "2021-02-04T19:14:04Z")

</div>

I’m getting this same issue on Ubuntu 20.04. Hasn’t happened before today. Here are my Pluto and PooledArray versions (latest at the time of posting):

```julia
(@v1.5) pkg> status Pluto PooledArrays
Status `~/.julia/environments/v1.5/Project.toml`
  [c3e4b0f8] Pluto v0.12.20
  [2dfb63ee] PooledArrays v1.1.0

```

---

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [February 4, 2021, 7:36pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/3 "2021-02-04T19:36:30Z")

</div>

I get a similar issue on Ubuntu 20.10

---

<div class="post-metadata">

**Author:** ![thatcher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thatcher/32/21708_2.png) [@thatcher](https://discourse.julialang.org/u/thatcher)\
**Post date:** [February 4, 2021, 10:02pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/4 "2021-02-04T22:02:18Z")

</div>

I have a partial workaround! I started downgrading packages and arrived at this configuration that works:

```julia
(@v1.5) pkg> status CSV DataFrames PooledArrays CategoricalArrays
Status `~/.julia/environments/v1.5/Project.toml`
  [336ed68f] CSV v0.8.2
  [324d7699] CategoricalArrays v0.9.0
  [a93c6f00] DataFrames v0.22.3
  [2dfb63ee] PooledArrays v0.5.3

(@v1.5) pkg> 

```

I’m not sure exactly where the issue is, and it might be in just one or two of these packages. I’ll try to keep narrowing it down from here. I got to this state with

```julia
(@v1.5) pkg> rm CSV
(@v1.5) pkg> rm DataFrames
(@v1.5) pkg> rm PooledArrays
(@v1.5) pkg> rm CategoricalArrays
(@v1.5) pkg> add CSV@0.8.2
(@v1.5) pkg> add CategoricalArrays@0.9.0
(@v1.5) pkg> add DataFrames@0.22.3
(@v1.5) pkg> add PooledArrays@0.5.3

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [February 5, 2021, 12:58am UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/5 "2021-02-05T00:58:06Z")

</div>

Thanks! I opened an [issue for this at the Pluto.jl repo](https://github.com/fonsp/Pluto.jl/issues/895) since I’m not getting the error in a regular Julia session/REPL. Hopefully it’s a quick fix for @fonsp 🙂

---

<div class="post-metadata">

**Author:** ![Rob\_van\_Weelderen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rob_van_weelderen/32/7621_2.png) [@Rob\_van\_Weelderen](https://discourse.julialang.org/u/Rob_van_Weelderen)\
**Post date:** [February 5, 2021, 1:48pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/6 "2021-02-05T13:48:39Z")

</div>

Just to confirm from my side (I discovered this thread only when on issues for Pluto on github). It affects not only CSV.

CSV (0.8.3), DataFramesMeta (0.60) and DataFrames (0.18.3) load & precompile nicely when run from the REPL `include("pluto_notebook_file.jl")` but all fail to precompile in the Pluto notebook environment.

Since it doesn’t happen to any other packages, well at the moment at least, I wonder if the bug is in Pluto or in these packages (and other packages might follow suit).

---

<div class="post-metadata">

**Author:** ![forestacorn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forestacorn/32/19260_2.png) [@forestacorn](https://discourse.julialang.org/u/forestacorn)\
**Post date:** [February 5, 2021, 3:07pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/7 "2021-02-05T15:07:37Z")

</div>

I tried similar, removing `CSV`, `DataFrames` and `PooledArrays` and then added them back again, I did not specify a version but the same versions as yours were added, however it did not improve anything in my case and I had the same `Failed to precompile...` error in the Pluto notebook environment but not in the REPL.

---

<div class="post-metadata">

**Author:** ![pankgeorg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pankgeorg/32/21549_2.png) [@pankgeorg](https://discourse.julialang.org/u/pankgeorg)\
**Post date:** [February 6, 2021, 11:40am UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/8 "2021-02-06T11:40:02Z")

</div>

As j-fu said [here](https://github.com/fonsp/Pluto.jl/issues/895#issuecomment-774428598) clearing packages (`~/.julia`) and reinstalling Pluto fixes the issue. Investigating more!

---

<div class="post-metadata">

**Author:** ![fabgrei](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fabgrei/32/4214_2.png) [@fabgrei](https://discourse.julialang.org/u/fabgrei)\
**Post date:** [February 6, 2021, 1:42pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/9 "2021-02-06T13:42:08Z")

</div>

I had the same issue. I solved it by

```julia
Pkg.add(PackageSpec(name="DataAPI", version="1.4"))

```

---

<div class="post-metadata">

**Author:** ![asyrov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asyrov/32/13578_2.png) [@asyrov](https://discourse.julialang.org/u/asyrov)\
**Post date:** [February 9, 2021, 11:56pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/10 "2021-02-09T23:56:53Z")

</div>

Would it be correct to say that this error, such as below (which also happens in CSV and other components)

```julia
[Info: Precompiling DataFrames [a93c6f00-e57d-5684-b7b6-d8193f3e46c0]
ERROR: LoadError: UndefVarError: invrefpool not defined

```

is due to significant breaking change in PooledArrays.jl? And so to resolve we need to pin version PooledArrays@0.5.3?

I did it and it worked ok. Everything precompiles nicely.

---

<div class="post-metadata">

**Author:** ![qsong](https://avatars.discourse-cdn.com/v4/letter/q/d07c76/32.png) [@qsong](https://discourse.julialang.org/u/qsong)\
**Post date:** [February 12, 2021, 2:48pm UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/11 "2021-02-12T14:48:59Z")

</div>

I got `CSV` precompiled in Pluto first. Then specified `CategoricalArrays@0.9.0` following @thatcher’s post and got `DataFrames` precomplied in Pluto.  
It seems that `CategoricalArrays@0.9.1` not working with `Pluto@0.12.20` either.

---

<div class="post-metadata">

**Author:** ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)\
**Post date:** [February 19, 2021, 11:35am UTC](https://discourse.julialang.org/t/failed-to-precompile-csv-in-pluto/54633/12 "2021-02-19T11:35:10Z")

</div>

> [@fabgrei](#):
>
> I had the same issue. I solved it by
> 
> ```julia
> Pkg.add(PackageSpec(name="DataAPI", version="1.4"))
> 
> ```

This is the step that worked me. I did not have to clear anything in my `.julia` folder.
