# Got a looping of "warning: replacing module myModule"

**URL:** <https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828>\
**Category:** General Usage\
**Created:** [January 19, 2019, 9:01pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828 "2019-01-19T21:01:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [January 19, 2019, 9:01pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828/1 "2019-01-19T21:01:02Z")

</div>

Hi. I have a folder with four .jl file. One is the module file with name myModule.jl, the second one type.jl is the file with all the type definitions, the third one gen\_csv file is the file of function definitions, the forth one example.jl is the main file I’d like to test. In the module myModule.jl, I export myFunction.

Now, in the example.jl, I put  
include(“myModule.jl”)  
myFunction(myParameter)

this function myFunction is defined in the file gen\_csv.jl.

But I got an error, saying that  
UndefVarError: myFunction not defined.

I was deeply confused. :((( Any help please?

The other concern is, I’m using Atom to run the file. After keeping running it, I got an error, saying that "warning: replacing module myModule. I do not know why. Could anyone please help me?

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 19, 2019, 10:22pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828/2 "2019-01-19T22:22:43Z")

</div>

Could you please provide a complete Minimal (Non-)Working Example of what you’re trying to do? And also quote your code?

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

  

That being said, I think what you are missing is a statement which imports your module (cf. [Modules](https://docs.julialang.org/en/v1/manual/modules/#Summary-of-module-usage-1), such as

```julia
using MyModule

```

When you only `include("myModule.jl")`, you make Julia load all the code it contains (and therefore it is aware of the existence of the module). But you have to also “import” the module, _i.e._ tell Julia that you actually want (some of) what it defines to be brought into your current scope.

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [January 19, 2019, 10:35pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828/3 "2019-01-19T22:35:58Z")

</div>

@ffevotte, here is a toy example.  
file main.jl

> push!(LOAD\_PATH,“\home\devel\Desktop\123\myModule”)  
> using myModule  
> a=add1(2)  
> println(a)

file myModule.jl

> module M  
> export add1
> 
> include(“myFunc.gl”)

file myFunc.jl

> function add1(x)  
> x+1  
> end

I run the main file main.jl and got an error, Argument error, module m not found in current path.

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [January 19, 2019, 10:40pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828/4 "2019-01-19T22:40:21Z")

</div>

@ffevotte I’m using atom, if that’s helpful.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 19, 2019, 10:54pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828/5 "2019-01-19T22:54:34Z")

</div>

Something like this should work:

**/some/path/MyModule.jl** :

```julia
module MyModule

export add1

# Put your function here or in a separate file as you'd like:
# this is not what's causing the problem here...
function add1(x)
    x+1
end

end

```

  

**main.jl** :

```julia
push!(LOAD_PATH,"/some/path/")
using MyModule

a = add1(3)
println(a)

```

  

However, instead of manually fiddling with your `LOAD_PATH`, you would probably be better off creating your own [project](https://docs.julialang.org/en/v1/stdlib/Pkg/#Creating-your-own-projects-1). When you activate a project, you don’t have to tell Julia where modules are: the standard files layout helps it find your source code.

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [January 19, 2019, 11:04pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828/6 "2019-01-19T23:04:28Z")

</div>

@ffevotte, thank you so much. I’m using Julia 0.6. Does it still work with a this project layout?

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [January 19, 2019, 11:12pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828/7 "2019-01-19T23:12:32Z")

</div>

@ffevotte it works. but i think there should be a better way to do it, beside the project method you mentioned.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 19, 2019, 11:16pm UTC](https://discourse.julialang.org/t/got-a-looping-of-warning-replacing-module-mymodule/19828/8 "2019-01-19T23:16:23Z")

</div>

> [@bsnyh](#):
>
> I’m using Julia 0.6. Does it still work with a this project layout?

I’m not sure, but I would think it does not work the same way in v0.6: as far as I know, the packages / modules evolved considerably in v0.7 & v1.0…
