# Relocability problems about Requires.jl

**URL:** <https://discourse.julialang.org/t/relocability-problems-about-requires-jl/96110>\
**Category:** General Usage\
**Created:** [March 15, 2023, 7:17am UTC](https://discourse.julialang.org/t/relocability-problems-about-requires-jl/96110 "2023-03-15T07:17:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsjie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jsjie/32/22477_2.png) [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Post date:** [March 15, 2023, 7:17am UTC](https://discourse.julialang.org/t/relocability-problems-about-requires-jl/96110/1 "2023-03-15T07:17:30Z")

</div>

I compiled my package, which depends on `HDF5.jl`. I compiled it in docker and then use the compiled executable directly in the host machine. It generally works fine, but there is a warning:

```julia
┌ Warning: Error requiring `MPI` from `HDF5.Drivers`
│ exception =
│ IOError: stat("/root/.julia/packages/HDF5/HtnQZ/src/drivers/mpio.jl"): permission denied (EACCES)
│ ... something omitted
│ [15] __init__ ()
│ @ HDF5.Drivers /root/.julia/packages/HDF5/HtnQZ/src/drivers/drivers.jl:92
└ @ Requires /root/.julia/packages/Requires/Z8rfN/src/require.jl:51

```

The problematic line is very clear:

```julia
@require MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" include("mpio.jl")

```

The reason seems to be simple: the `@require` macro make the include happen in run time, when I can no longer get `mpio.jl`, because I compile the package in docker but run it in the host machine.

After check, I found `Requires.jl` offers a `@include` macro, which seems to be fit for the problem.

If this is the case, should every package that currently use `@require...include` change to `@require...@include`?

There are currently many such packages, like `Adapt.jl`, `ArrayInterface.jl`, `StaticArrayInterface.jl`, `MPI.jl`, `HDF5.jl`, to name but a few.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 15, 2023, 9:20am UTC](https://discourse.julialang.org/t/relocability-problems-about-requires-jl/96110/2 "2023-03-15T09:20:42Z")

</div>

In this case, it might be easier dev the package and either remove the line or always include it depending on if you are using MPI or not.

With pkgimages around the corner with Julia 1.9, we’ll probably be engineering this a bit differently.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [March 15, 2023, 9:39am UTC](https://discourse.julialang.org/t/relocability-problems-about-requires-jl/96110/3 "2023-03-15T09:39:36Z")

</div>

> [@jsjie](#):
>
> ```julia
> ┌ Warning: Error requiring `MPI` from `HDF5.Drivers`
> │ exception =
> │ IOError: stat("/root/.julia/packages/HDF5/HtnQZ/src/drivers/mpio.jl"): permission denied (EACCES)
> │ ... something omitted
> │ [15] __init__ ()
> │ @ HDF5.Drivers /root/.julia/packages/HDF5/HtnQZ/src/drivers/drivers.jl:92
> └ @ Requires /root/.julia/packages/Requires/Z8rfN/src/require.jl:51
> 
> ```

To be clear, are you running Julia as the `root` user?

---

<div class="post-metadata">

**Author:** ![jsjie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jsjie/32/22477_2.png) [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Post date:** [March 15, 2023, 9:45am UTC](https://discourse.julialang.org/t/relocability-problems-about-requires-jl/96110/4 "2023-03-15T09:45:58Z")

</div>

I run the executable as a normal user. But, since I compile the package in docker, I suppose it should be as the root user in the docker.

---

<div class="post-metadata">

**Author:** ![jsjie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jsjie/32/22477_2.png) [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Post date:** [March 15, 2023, 9:54am UTC](https://discourse.julialang.org/t/relocability-problems-about-requires-jl/96110/5 "2023-03-15T09:54:02Z")

</div>

It is a workable solution, at least for packages I directly depend on. But my package only depends on `Adapt.jl` indirectly through `StructArrays.jl`, I suppose I also need to dev `StructArrays.jl`?  
I’m not familiar with `PkgImages.jl`, maybe I can have a look at it.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [March 15, 2023, 5:30pm UTC](https://discourse.julialang.org/t/relocability-problems-about-requires-jl/96110/6 "2023-03-15T17:30:46Z")

</div>

It’s not PkgImages.jl that I’m thinking about. Rather it’s the integration into Julia 1.9. From Julia 1.9 on, we will replace Requires.jl with the Julia 1.9 package extension mechanism.

> [@jsjie](#):
>
> I suppose I also need to dev `StructArrays.jl`?  
> I’m not familiar with `PkgImages.jl`, maybe I can have a look at it.

No, you should only need to `dev` HDF5.jl. All dependencies will use your modified version.
