# Weird Module Error

**URL:** <https://discourse.julialang.org/t/weird-module-error/90144>\
**Category:** New to Julia\
**Tags:** question, package\
**Created:** [November 12, 2022, 1:56am UTC](https://discourse.julialang.org/t/weird-module-error/90144 "2022-11-12T01:56:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elzair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elzair/32/44323_2.png) [@Elzair](https://discourse.julialang.org/u/Elzair)\
**Post date:** [November 12, 2022, 1:56am UTC](https://discourse.julialang.org/t/weird-module-error/90144/1 "2022-11-12T01:56:10Z")

</div>

I just developed a Package for Julia [https://github.com/Elzair/merchantjl](https://github.com/Elzair/merchantjl). First I just created one module in the main file and just `include()`d all code under it.

**Merchant.jl**

```julia
module Merchant
include("worldinfo.jl")
# ...
export World, seekAllPassengers, # ...
end

```

```julia-repl
@v1.8) pkg> activate .
  Activating project at `~/Development/misc/julia/Merchant`

julia> using Merchant: seekAllPassengers, World

julia> seekAllPassengers(2, 2, World("A434934-F"), World("A560565-8"), 2)
Output...

```

It works, but I would like to split the code into multiple modules, so I created a “modules” branch for that. However, to use `World` (defined in module `WorldInfo`), I now need to import the main module as well and specify a full path (even though I import and re-export in my main module).

**Merchant.jl**

```julia
module Merchant

include("worldinfo.jl")
include("passenger.jl")
# ...

using .WorldInfo: World
using .Passenger: seekAllPassengers
# ...
export World, seekAllPassengers, # ...
end

```

**worldinfo.jl**

```julia
module WorldInfo
export World, #...
struct World
# ...
end
end

```

**passenger.jl**

```julia
module Passenger
include("worldinfo.jl")
using .WorldInfo: World
export seekAllPassengers
function seekAllPassengers(..., source::World, ...)
# ...
end
end

```

```julia-repl
@v1.8) pkg> activate .
  Activating project at `~/Development/misc/julia/Merchant`

julia> using Merchant: seekAllPassengers, World

julia> import Merchant

julia> seekAllPassengers(2, 2, Merchant.Passenger.WorldInfo.World("A434934-F"), Merchant.Passenger.WorldInfo.World("A560565-8"), 2)
Output...

```

The problem is I have three main functions in three different modules, and they all use `World`.

```julia-repl
julia> seekAllFreight(2, Merchant.Freight.WorldInfo.World("A434934-F"), Merchant.Freight.WorldInfo.World("A560565-8"), 2)
Output

```

Does anyone know how to fix this?

---

<div class="post-metadata">

**Author:** ![Elzair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elzair/32/44323_2.png) [@Elzair](https://discourse.julialang.org/u/Elzair)\
**Post date:** [November 12, 2022, 7:07pm UTC](https://discourse.julialang.org/t/weird-module-error/90144/2 "2022-11-12T19:07:36Z")

</div>

I found [Defining Multiple Modules in a Package](https://discourse.julialang.org/t/defining-multiple-modules-in-a-package/52702/5), and it suggested that my first approach was the correct one, so I will stick with that.
