# Revise.jl not updating correctly a package

**URL:** <https://discourse.julialang.org/t/revise-jl-not-updating-correctly-a-package/93711>\
**Category:** General Usage\
**Tags:** revise\
**Created:** [January 28, 2023, 8:31pm UTC](https://discourse.julialang.org/t/revise-jl-not-updating-correctly-a-package/93711 "2023-01-28T20:31:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nrontsis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nrontsis/32/38535_2.png) [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Post date:** [January 28, 2023, 8:31pm UTC](https://discourse.julialang.org/t/revise-jl-not-updating-correctly-a-package/93711/1 "2023-01-28T20:31:56Z")

</div>

I am getting incomplete package updates from Revise.jl 3.5.0 in Julia 1.8.2 Linux x64 (Docker on MacOS 13.1) which I managed to track to the following minimal example:

### Example Package

`src/Example.jl`:

```julia
module Example
     module A
         include("a.jl")
     end
     module B
        include("a.jl")
     end
     export A, B
end

```

`src/a.jl`:

```julia
f(x) = y

```

`Manifest.toml`:

```toml
name = "Example"
uuid = "1fcb2a49-e178-4b19-98f0-97e19ed5c4de"
authors = ["Some Authors"]
version = "0.1.0"

[deps]
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"

```

and empty `test` folder

### Example Session (launched via `julia --project` on the package’s dir):

```julia-repl
julia> using Revise
julia> using Example
[Info: Precompiling Example [1fcb2a49-e178-4b19-98f0-97e19ed5c4de]
julia> A.f(1)
ERROR: UndefVarError: y not defined
Stacktrace:
 [1] f(x::Int64)
   @ Example.A src/a.jl:1
 [2] top-level scope

...
[Correct src/a.jl to be f(x) = x]
...

julia> A.f(1)
1

julia> B.f(1)
ERROR: UndefVarError: y not defined
Stacktrace:
 [1] f(x::Int64)
   @ Example.B src/a.jl:1
 [2] top-level scope

```

In the example above `B.f` remains broken, even though a restart of the session would fix it!

Am I hitting a limitation of Revise.jl or is this a bug?

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [January 29, 2023, 4:31pm UTC](https://discourse.julialang.org/t/revise-jl-not-updating-correctly-a-package/93711/2 "2023-01-29T16:31:54Z")

</div>

I don’t know how Revise handles such a case, but the general recommendation is not to include the same file multiple times. See, for example

> [@Need to include one file multiple times, how to avoid warning](https://discourse.julialang.org/t/need-to-include-one-file-multiple-times-how-to-avoid-warning/27439/4):
>
> Put your “utils” into a module and use it with “using utils”.

Is there a compelling reason to include “a.jl” twice in your case?

---

<div class="post-metadata">

**Author:** ![nrontsis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nrontsis/32/38535_2.png) [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Post date:** [January 29, 2023, 4:52pm UTC](https://discourse.julialang.org/t/revise-jl-not-updating-correctly-a-package/93711/3 "2023-01-29T16:52:26Z")

</div>

To be honest, there isn’t and I will change the original code so that it doesn’t.

However the issue remains in that I didn’t get any warning, and Revise.jl updated the package only partially.

As such I think this is a bug, affecting how much Revise.jl can be trusted (especially in an codebase that I am not the sole author) unless already documented as a limitation.

---

<div class="post-metadata">

**Author:** ![nrontsis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nrontsis/32/38535_2.png) [@nrontsis](https://discourse.julialang.org/u/nrontsis)\
**Post date:** [January 30, 2023, 11:57am UTC](https://discourse.julialang.org/t/revise-jl-not-updating-correctly-a-package/93711/4 "2023-01-30T11:57:22Z")

</div>

Opened an issue in GitHub:

> <https://github.com/timholy/Revise.jl/issues/730>
>
> Copied from \[this discourse thread\](https://discourse.julialang.org/t/revise-jl-…not-updating-correctly-a-package/93711)
> 
> I am getting incomplete package updates from Revise.jl 3.5.0 in Julia 1.8.2 Linux x64 (Docker on MacOS 13.1) which I managed to track to the following minimal example:
> 
> \### Example Package
> \`src/Example.jl\`:
> \`\`\`julia
> module Example
> module A
> include("a.jl")
> end
> module B
> include("a.jl")
> end
> export A, B
> end
> \`\`\`
> \`src/a.jl\`:
> \`\`\`julia
> f(x) = y
> \`\`\`
> \`Manifest.toml\`:
> \`\`\`toml
> name = "Example"
> uuid = "1fcb2a49-e178-4b19-98f0-97e19ed5c4de"
> authors = \["Some Authors"\]
> version = "0.1.0"
> 
> \[deps\]
> Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
> \`\`\`
> and empty \`test\` folder
> 
> \### Example Session (launched via \`julia --project\` on the package's dir):
> \`\`\`julia-repl
> julia\> using Revise
> julia\> using Example
> \[Info: Precompiling Example \[1fcb2a49-e178-4b19-98f0-97e19ed5c4de\]
> julia\> A.f(1)
> ERROR: UndefVarError: y not defined
> Stacktrace:
> \[1\] f(x::Int64)
> @ Example.A src/a.jl:1
> \[2\] top-level scope
> 
> ...
> \[Correct src/a.jl to be f(x) = x\]
> ...
> 
> julia\> A.f(1)
> 1
> 
> julia\> B.f(1)
> ERROR: UndefVarError: y not defined
> Stacktrace:
> \[1\] f(x::Int64)
> @ Example.B src/a.jl:1
> \[2\] top-level scope
> \`\`\`
> 
> In the example above \`B.f\` remains broken, even though a restart of the session would fix it

---

<div class="post-metadata">

**Author:** ![AlexLewandowski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexlewandowski/32/18856_2.png) [@AlexLewandowski](https://discourse.julialang.org/u/AlexLewandowski)\
**Post date:** [June 15, 2023, 7:22pm UTC](https://discourse.julialang.org/t/revise-jl-not-updating-correctly-a-package/93711/5 "2023-06-15T19:22:39Z")

</div>

This issue, or one like it, happens to me very often in the early stages of writing a package. Essentially an error that is fixed is not picked up by Revise. Makes using it extremely annoying.

---

<div class="post-metadata">

**Author:** ![sairus7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sairus7/32/10816_2.png) [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Post date:** [October 19, 2023, 6:23pm UTC](https://discourse.julialang.org/t/revise-jl-not-updating-correctly-a-package/93711/6 "2023-10-19T18:23:06Z")

</div>

By the way, Revise also cannot check definition order for modified code. So if I add a function on a type that is defined somewhere later in code, I don’t get undefined error.
