# Force update const in module

**URL:** <https://discourse.julialang.org/t/force-update-const-in-module/93594>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [January 26, 2023, 8:33pm UTC](https://discourse.julialang.org/t/force-update-const-in-module/93594 "2023-01-26T20:33:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![harsh\_kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/harsh_kumar/32/46042_2.png) [@harsh\_kumar](https://discourse.julialang.org/u/harsh_kumar)\
**Post date:** [January 26, 2023, 8:33pm UTC](https://discourse.julialang.org/t/force-update-const-in-module/93594/1 "2023-01-26T20:33:43Z")

</div>

I have created a module that read some data from files. I tried storing the file content in a variable like shown below. But this method doesn’t update the name variable from the file even if i restart the julia session. Is there any way to force reading the file and redefine the constant when I import the package?

```julia
module TestModule

const name = open(expanduser("~/name")) do io
    String(read(io))
end

greet() = print("Hello $name")

end # module TestModule

```

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [January 26, 2023, 8:43pm UTC](https://discourse.julialang.org/t/force-update-const-in-module/93594/2 "2023-01-26T20:43:50Z")

</div>

Add

```julia
include_dependency(expanduser("~/name"))

```

to the module definition. Then any time you change that file, the package will be recompiled.

But if you just want it to be a runtime constant, then use

```julia
const name = Ref{String}()

function __init__ ()
    name[] = open(expanduser("~/name")) do io
        String(read(io))
    end
end

```

and then use `name[]` everywhere you’re using `name` now. Then it will be reloaded in every fresh Julia session.
