# Error while including a file

**URL:** <https://discourse.julialang.org/t/error-while-including-a-file/24238>\
**Category:** General Usage\
**Created:** [May 15, 2019, 1:01pm UTC](https://discourse.julialang.org/t/error-while-including-a-file/24238 "2019-05-15T13:01:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [May 15, 2019, 1:01pm UTC](https://discourse.julialang.org/t/error-while-including-a-file/24238/1 "2019-05-15T13:01:40Z")

</div>

Sometimes I get this error while including a file `include("filename.jl")`. Then I have to restart Julia and it works again. I am using Revise.  
No a single line of the included file is executed.  
What could be the problem? Thanks in advance.

```julia
ERROR: MethodError: no method matching getindex(::Array{UInt8,1}, ::UnitRange{UInt64})
Closest candidates are:
  getindex(::Array, ::Int64) at array.jl:729
  getindex(::Array, ::Int64, ::Int64, ::Int64...) at array.jl:730
  getindex(::Array, ::UnitRange{Int64}) at array.jl:734
  ...
Stacktrace:
 [1] pwd() at ./file.jl:54
 [2] abspath at ./path.jl:325 [inlined]
 [3] _include_dependency(::Module, ::String) at ./loading.jl:742
 [4] include_relative(::Module, ::String) at ./loading.jl:1030
 [5] include(::Module, ::String) at ./sysimg.jl:29
 [6] include(::String) at ./client.jl:403
 [7] top-level scope at none:0

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 15, 2019, 1:25pm UTC](https://discourse.julialang.org/t/error-while-including-a-file/24238/2 "2019-05-15T13:25:21Z")

</div>

It’s kinda odd because the method

```julia
  getindex(::Array, ::UnitRange{Int64}) at array.jl:734

```

that is suggested should match?

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [May 15, 2019, 1:34pm UTC](https://discourse.julialang.org/t/error-while-including-a-file/24238/3 "2019-05-15T13:34:33Z")

</div>

> [@kristoffer.carlsson](#):
>
> that is suggested should match?

The method it’s complaining is missing is

```julia
getindex(::Vector{UInt8}, ::UnitRange{UInt64})

```

note that the second argument is `UInt64` not `Int64`.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 15, 2019, 1:43pm UTC](https://discourse.julialang.org/t/error-while-including-a-file/24238/4 "2019-05-15T13:43:34Z")

</div>

Ah, good catch.

Even so:

```julia
julia> a = UInt8[1,2,3,4,5,6];

julia> a[1:UInt64(3)]
3-element Array{UInt8,1}:
 0x01
 0x02
 0x03

```

Perhaps Revise is deleting some method?

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [May 15, 2019, 2:10pm UTC](https://discourse.julialang.org/t/error-while-including-a-file/24238/5 "2019-05-15T14:10:55Z")

</div>

It does seem as if the generic fallback method at `abstractarray.jl:925` is gettind deleted.

It’s pretty strange that Revise could do that. I’m wondering if there should be some kind of check to make sure it does not delete methods from `Base`, perhaps unless some global flag is set.

---

<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:** [May 15, 2019, 2:38pm UTC](https://discourse.julialang.org/t/error-while-including-a-file/24238/6 "2019-05-15T14:38:23Z")

</div>

Please file as a Revise issue. Might be similar to [https://github.com/timholy/Revise.jl/issues/234](https://github.com/timholy/Revise.jl/issues/234) (which is a Julia bug, not a Revise bug). Theoretically Revise shouldn’t do this, but it does depend on accurate subtyping. Or there could be a bug.

---

<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:** [May 16, 2019, 9:13am UTC](https://discourse.julialang.org/t/error-while-including-a-file/24238/7 "2019-05-16T09:13:01Z")

</div>

@RaulDurand, to catch this in the act, turn on [Revise’s logging](https://timholy.github.io/Revise.jl/dev/debugging/). This is what I do in my `startup.jl` file:

```julia
 atreplinit() do repl
    try
        @eval using Revise
        @async Revise.debug_logger()
        @async Revise.wait_steal_repl_backend()
    catch
    end
end

```

Then if the error happens again, you can retrospectively examine `rlogger = Revise.debug_logger()` and figure out what happened. See instructions in those docs about how to capture info and submit a bug report.
