# I get errors when using module

**URL:** <https://discourse.julialang.org/t/i-get-errors-when-using-module/125351>\
**Category:** General Usage\
**Tags:** modules\
**Created:** [January 29, 2025, 4:12pm UTC](https://discourse.julialang.org/t/i-get-errors-when-using-module/125351 "2025-01-29T16:12:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fahim](https://avatars.discourse-cdn.com/v4/letter/f/8baadc/32.png) [@Fahim](https://discourse.julialang.org/u/Fahim)\
**Post date:** [January 29, 2025, 4:12pm UTC](https://discourse.julialang.org/t/i-get-errors-when-using-module/125351/1 "2025-01-29T16:12:29Z")

</div>

Dear Julia friends,

First of all, I apologize for my poor English skills. I have a problem developing a module that uses Embeddings.jl:

```julia
module Portal
include("./t.jl")
export get_embedding
end # module Portal

```

```julia
using Embeddings
const embtable = load_embeddings(FastText_Text{:de})
const get_word_index = Dict(word => i for (i, word) in enumerate(embtable.vocab))

function get_embedding(word)
    ind = get_word_index[word]
    emb = embtable.embeddings[:,ind]
    return emb
end

```

When using Portal I get the following error messages:  
julia\> using Pkg

julia\> Pkg.activate(“.”)  
Activating project at `~/JuliaProjects/Portal`

julia\> using Revise

julia\> using Portal  
Precompiling Portal…  
lld: error: /home/fahim/.julia/compiled/v1.11/Portal/jl\_ysPtHq(text#0.o):(.rodata+0x114): relocation R\_X86\_64\_PC32 out of range: 2562091264 is not in [-2147483648, 2147483647]

> > > referenced by text  
> > > _GLOBAL\_OFFSET\_TABLE_  
> > > referenced by dict.jl:199

lld: error: /home/fahim/.julia/compiled/v1.11/Portal/jl\_ysPtHq(text#0.o):(.rodata+0x14c): relocation R\_X86\_64\_PC32 out of range: 2562091408 is not in [-2147483648, 2147483647]

> > > referenced by text  
> > > …  
> > > …

Stacktrace:  
[1] pipeline\_error  
@ ./process.jl:598 [inlined]  
[2] run(::Cmd, ::Base.DevNull, ::Vararg{Any}; wait::Bool)  
@ Base ./process.jl:513  
[3] run  
@ ./process.jl:510 [inlined]  
[4] link\_image (repeats 2 times)  
@ ./linking.jl:166 [inlined]  
[5] compilecache(pkg::Base.PkgId, path::String, internal\_stderr::IO, internal\_stdout::IO, keep\_loaded\_modules::Bool; flags::Cmd, cacheflags::Base.CacheFlags, reasons::Dict{…}, loadable\_exts::Nothing)  
@ Base ./loading.jl:3085  
[6] (::Base.var"#1110#1111"{Base.PkgId})()  
@ Base ./loading.jl:2579  
[7] mkpidlock(f::Base.var"#1110#1111"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale\_age::Int64, wait::Bool})  
@ FileWatching.Pidfile /opt/julia-1.11.3/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:95  
[8] #mkpidlock#6  
@ /opt/julia-1.11.3/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:90 [inlined]  
[9] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale\_age::Int64})  
@ FileWatching.Pidfile /opt/julia-1.11.3/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:116  
[10] #invokelatest#2  
@ ./essentials.jl:1057 [inlined]  
[11] invokelatest  
@ ./essentials.jl:1052 [inlined]  
[12] maybe\_cachefile\_lock(f::Base.var"#1110#1111"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale\_age::Int64)  
@ Base ./loading.jl:3698  
[13] maybe\_cachefile\_lock  
@ ./loading.jl:3695 [inlined]  
[14] \_require(pkg::Base.PkgId, env::String)  
@ Base ./loading.jl:2565  
[15] \_\_require\_prelocked(uuidkey::Base.PkgId, env::String)  
@ Base ./loading.jl:2388  
[16] #invoke\_in\_world#3  
@ ./essentials.jl:1089 [inlined]  
[17] invoke\_in\_world  
@ ./essentials.jl:1086 [inlined]  
[18] \_require\_prelocked(uuidkey::Base.PkgId, env::String)  
@ Base ./loading.jl:2375  
[19] macro expansion  
@ ./loading.jl:2314 [inlined]  
[20] macro expansion  
@ ./lock.jl:273 [inlined]  
[21] \_\_require(into::Module, mod::Symbol)  
@ Base ./loading.jl:2271  
[22] #invoke\_in\_world#3  
@ ./essentials.jl:1089 [inlined]  
[23] invoke\_in\_world  
@ ./essentials.jl:1086 [inlined]  
[24] require(into::Module, mod::Symbol)  
@ Base ./loading.jl:2260  
Some type information was truncated. Use `show(err)` to see complete types.

But if I include the file and then call the method, it works.

```julia
julia> include("./src/t.jl")
get_embedding (generic function with 1 method)

julia> get_embedding("Buch")
300-element Vector{Float32}:
 -0.0781
 -0.0145
  ⋮

```

Thank you in advance for any tips or solutions.  
Fahim

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [February 2, 2025, 3:29pm UTC](https://discourse.julialang.org/t/i-get-errors-when-using-module/125351/2 "2025-02-02T15:29:14Z")

</div>

Hi Fahim,

Welcome to the Julia community!

On Windows 10 I get a (presumably) somewhat similar issue:

```julia-repl
julia> using Portal
ERROR: Error opening package file (...)\.julia\compiled\v1.11\Portal\bI5Dh_Imu6F.dll: %1 is not a valid Win32 application.

```

Looking at the file in question, it is about 2.5 GB in size. It then seems likely that the precompiled files can be at most 2^{31} - 1 bytes (`typemax(Int32) == 2147483647`) for 32-bit compatibility. In this case the two `const`s (in particular `embtable`) will be too large to cache.

One option would be to disable precompilation by adding ` __precompile__ (false)` to `Portal.jl`. Or (and a bit better) you could use Preferences.jl to [achieve the same](https://julialang.github.io/PrecompileTools.jl/stable/#Package-developers:-reducing-the-cost-of-precompilation-during-development). The downside is obviously that when `using Portal` you’ll need to compute `embtable` and `get_word_index`, which at least on my pc takes quite a while (for some reason). I suppose you could just manually save and load `embtable.embeddings` and `get_word_index` to and from disk.

---

<div class="post-metadata">

**Author:** ![Fahim](https://avatars.discourse-cdn.com/v4/letter/f/8baadc/32.png) [@Fahim](https://discourse.julialang.org/u/Fahim)\
**Post date:** [February 3, 2025, 4:00pm UTC](https://discourse.julialang.org/t/i-get-errors-when-using-module/125351/3 "2025-02-03T16:00:35Z")

</div>

Thank you for the welcome and support.

FYI:  
it now works by calling the function **precompile** (false). But the following exception is thrown:  
exception = Error when precompiling module, potentially caused by a **precompile** (false) declaration in the module

Best regards  
Fahim

---

<div class="post-metadata">

**Author:** ![eldee](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@eldee](https://discourse.julialang.org/u/eldee)\
**Post date:** [February 3, 2025, 4:24pm UTC](https://discourse.julialang.org/t/i-get-errors-when-using-module/125351/4 "2025-02-03T16:24:14Z")

</div>

> [@Fahim](#):
>
> But the following exception is thrown:  
> exception = Error when precompiling module, potentially caused by a **precompile** (false) declaration in the module

Yeah, it seems that ` __precompile__ (false)` disables/interrupts precompilation by making it throw an exception. With the Preferences.jl approach you can get rid of this (minor) annoyance.
