Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InitError: LoadError: Evaluation into closed module CorpusLoaders breaks #43

Closed
AdarshKumar712 opened this issue May 18, 2021 · 2 comments · Fixed by #44
Closed

InitError: LoadError: Evaluation into closed module CorpusLoaders breaks #43

AdarshKumar712 opened this issue May 18, 2021 · 2 comments · Fixed by #44

Comments

@AdarshKumar712
Copy link
Contributor

AdarshKumar712 commented May 18, 2021

I am trying to use CorpusLoaders.jl as a dependency in another package. But when precompiling, I get the following error:

T1) pkg> precompile
Precompiling project...
  Progress [========================================>]  1/1
  ✗ T1
0 dependencies successfully precompiled in 16 seconds (39 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

T1 [88852414-a7b6-4fb4-ac26-6b40a70986e8]

ERROR: LoadError: InitError: LoadError: Evaluation into the closed module `CorpusLoaders` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `CorpusLoaders` with `eval` during precompilation - don't do this.
Stacktrace:
  [1] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
  [2] include
    @ ~/.julia/packages/CorpusLoaders/w40jN/src/CorpusLoaders.jl:1 [inlined]
  [3] __init__()
    @ CorpusLoaders ~/.julia/packages/CorpusLoaders/w40jN/src/CorpusLoaders.jl:17
  [4] _include_from_serialized(path::String, depmods::Vector{Any})
    @ Base ./loading.jl:674
  [5] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
    @ Base ./loading.jl:760
  [6] _require(pkg::Base.PkgId)
    @ Base ./loading.jl:998
  [7] require(uuidkey::Base.PkgId)
    @ Base ./loading.jl:914
  [8] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:901
  [9] include
    @ ./Base.jl:386 [inlined]
 [10] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base ./loading.jl:1213
 [11] top-level scope
    @ none:1
 [12] eval
    @ ./boot.jl:360 [inlined]
 [13] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [14] top-level scope
    @ none:1
in expression starting at /home/adarshkumar712/.julia/packages/CorpusLoaders/w40jN/src/WikiCorpus_DataDeps.jl:1
during initialization of module CorpusLoaders
in expression starting at /home/adarshkumar712/Projects/Test/T1/src/T1.jl:1

T1.jl looks like this:

module T1
    using CorpusLoaders
end

Referring to JuliaLang/julia#39648 , the reason for this is using @eval inside __init__() in CorpusLoaders.jl, but I wasn't able to locate any eval to cause this.

Can someone please have a look?

cc @oxinabox

@oxinabox
Copy link
Member

oxinabox commented May 18, 2021

That is annoying.
I am pretty sure the eval is actually the use of include (include basically calls eval under the hood).
which is all the includes here:

function __init__()
include(joinpath(@__DIR__, "WikiCorpus_DataDeps.jl"))
include(joinpath(@__DIR__, "SemCor_DataDeps.jl"))
include(joinpath(@__DIR__, "SemEval2007Task7_DataDeps.jl"))
include(joinpath(@__DIR__, "Senseval3_DataDeps.jl"))
include(joinpath(@__DIR__, "CoNLL_DataDeps.jl"))
include(joinpath(@__DIR__, "IMDB_DataDeps.jl"))
include(joinpath(@__DIR__, "Twitter_DataDeps.jl"))
include(joinpath(@__DIR__, "StanfordSentimentTreebank_DataDeps.jl"))
include(joinpath(@__DIR__, "WikiGold_DataDeps.jl"))
include(joinpath(@__DIR__, "CoNLL2000_DataDeps.jl"))
end

The fix is to have them all defining a function e.g. init_WikiCorpus_DataDeps() or perhaps better: init_datadeps(::Type{WikiCorpus)) which does the definition of the datadep,
and is called from the main __init__.
that function can be defined in the main fule for that corpus, e.g. WikiCorpus.jl rather than being in it's own file.

@AdarshKumar712
Copy link
Contributor Author

Thanks for the reply. I will try it. And if it works, I will also create a PR for the same.

AdarshKumar712 added a commit to AdarshKumar712/CorpusLoaders.jl that referenced this issue May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants