# Missing Relocatability of Tulip

**URL:** https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886
**Category:** General Usage
**Tags:** package-compiler
**Created:** [February 19, 2023, 5:16pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886 "2023-02-19T17:16:16Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [February 19, 2023, 5:16pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/1 "2023-02-19T17:16:16Z")

</div>

## [Relocatability](https://julialang.github.io/PackageCompiler.jl/stable/apps.html#relocatability)

I try to compile a project into an application that depends on `Tulip.jl`, but the resulting App is not portable, see:  
[https://github.com/ds4dm/Tulip.jl/issues/131](https://github.com/ds4dm/Tulip.jl/issues/131)  
Has someone managed a similar situation and has some advice.  
Is it possible to handle this missing relocatibility inside my project or is it necessary that this issue need to be handled inside the conflicting package `Tulip.jl`?

---

<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: [February 19, 2023, 5:30pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/2 "2023-02-19T17:30:03Z")

</div>

You might want to consider calling `real_main` from ` __init__ ()` rather than the module top level.

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [February 20, 2023, 10:04am UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/3 "2023-02-20T10:04:03Z")

</div>

Thanks for the idea with ` __init__ ()`!  
I found the [function ` __init__ ()` in the project `Tulip.jl`](https://github.com/ds4dm/Tulip.jl/blob/master/src/Tulip.jl) does it make sense to fork the project and add something myself into this function?  
And if so, can someone suggest a good example what and how to do this?

---

<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: [February 20, 2023, 2:22pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/4 "2023-02-20T14:22:48Z")

</div>

See [Modules · The Julia Language](https://docs.julialang.org/en/v1/manual/modules/#Module-initialization-and-precompilation)

---

<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: [February 20, 2023, 2:55pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/5 "2023-02-20T14:55:26Z")

</div>

Looking at [fatal: error thrown and no exception handler available. · Issue #789 · JuliaLang/PackageCompiler.jl · GitHub](https://github.com/JuliaLang/PackageCompiler.jl/issues/789) I see the ` __init__ ` of Tulip is an issue.

We probably do not need to load the version number loke that on module load. For your purposes,

```julia
using Pkg
pkg"dev Tulip"

```

This will clone Tulip into your .julia/dev folder.

Then modify Tulip’s ` __init__ ` as follows:

```julia
function __init__ ()
    _TULIP_VERSION[] = v"0.9.4"
end

```

There is a better way to do this with Pkg, but this will work for you for now.

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [February 20, 2023, 3:10pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/6 "2023-02-20T15:10:51Z")

</div>

For this particular case there is no need for an ` __init__ ` at all, the version number can be set during precompilation ([Tulip.jl#132](https://github.com/ds4dm/Tulip.jl/pull/132)).

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [February 20, 2023, 3:15pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/7 "2023-02-20T15:15:42Z")

</div>

The problem is not the content of function `__init()__`.  
The package `Tulip` is not even listed in [the `Project.toml` of the project that I try to compile](https://github.com/StefanPofahl/Stefans_Julia_RePo/blob/main/AppDir/InteractiveEquivalentCircuit/Project.toml) into a portable application. One of the packages used relay on it. ☹  
The main issue is the missing Relocatibility of `Tulip.jl` …

---

<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: [February 20, 2023, 5:10pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/8 "2023-02-20T17:10:19Z")

</div>

Look at the error you reported on the PackageCompiler.jl issue:

```julia
InitError(mod=:Tulip, error=ErrorException(""C:\\Users\\stefanpofahl\\.julia\\packages\\Tulip\\BVHPO\\src\\..\\Project.toml":
 No such file"))

```

Why is it looking for that file?

It’s because of this line:

> <https://github.com/ds4dm/Tulip.jl/blob/master/src/Tulip.jl#L15>

```julia
    tlp_ver = VersionNumber(TOML.parsefile(joinpath(@ __DIR__ , "..", "Project.toml"))["version"])

```

Get rid of that line, then that is one less issue to deal with.

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [February 22, 2023, 11:03am UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/9 "2023-02-22T11:03:46Z")

</div>

@fredrikekre & @mkitti  
First of all thank you for your help! 🙂  
It was haphazardly that I included the function `Tulip. __init__ ()` in my minimal example  
and it was not obvious to me that this was already the part of the `Tulip`-code that causes the trouble.

Ok, I understand the root cause of my problem. Consistently, I have added my local clone of `Tulip.jl` as development package to the primary environment, but this does not cure the problem ☹  
During package compilation the standard `Tulip.jl` is taken to build the library “sys.dll”.  
Is there a way to specify the local `Tulip.jl`-package to be utilized during package compilation?

---

<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: [February 22, 2023, 4:10pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/10 "2023-02-22T16:10:56Z")

</div>

You would want to create specific environment for your project, and then dev your local copy into that environment. I would not recommend using the default primary environment (e.g. `@1.8` or `@1.9`) for this purpose. In fact, I would consider backing up that primary environment (copy the Project.toml and Manifest.toml) and clearing it out to make sure it does not interfere with system image building. Then, I would activate an environment in a local folder and add exactly the packages you need via `Pkg.add` or `Pkg.dev`.

To clarify, `Tulip. __init__ ()` will be invoked the first time your code does `using Tulip`.

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [February 22, 2023, 4:29pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/11 "2023-02-22T16:29:47Z")

</div>

Thanks, for the idea! - It seems that the `PackageCompiler` is a little bit an anarchist, …  
Meanwhile I did exactly this. I established my own primary environment and added the local clone of `Tulip` in this private primary environment. And started in this environment the process `create_app()`.  
But `PackageCompiler` took again the wrong version of `Tulip`☹

---

<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: [February 22, 2023, 5:18pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/12 "2023-02-22T17:18:13Z")

</div>

Could you should the result of the following in the activated environment?

```julia
using Pkg
pkg"status"
pkg"status -m"

```

Paging @kristoffer.carlsson

---

<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: [February 22, 2023, 5:19pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/13 "2023-02-22T17:19:47Z")

</div>

Just to make sure, consider bumping the version number of your Tulip.jl clone and make sure that version is added to the environment. Another consideration, is to create a git branch, commit your changes, and add it via `add /path/to/Tulip.jl#branchname`.

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [February 22, 2023, 9:22pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/14 "2023-02-22T21:22:22Z")

</div>

> [@mkitti](#):
>
> ```julia
> using Pkg
> pkg"status"
> pkg"status -m"
> 
> ```

```julia
julia> pkg"status"
      Status `C:\Users\stefanpofahl\.julia\environments\v1.6\MyAppCompileEnv\Project.toml`
  [9b87118b] PackageCompiler v2.1.5
  [295af30f] Revise v3.5.1
  [6dd1b50a] Tulip v0.9.4 `https://github.com/ds4dm/Tulip.jl.git#master`

```

the output of `pkg"status -m"` is quite long, it includes more then 20 packages.  
I have [coded a script `compile_app.jl` to control the compilation procedure](https://github.com/StefanPofahl/Stefans_Julia_RePo/blob/main/AppDir/compile_app.jl), myabe it is of interest for some of you.

P.S.:  
Meanwhile, the package maintainer of `Tulip.jl` agreed to publish a new version.  
Therefore, the `Tulip`-issue might be resolved soon.  
But the topic / question remains:  
How can I specify, which version of a package (a local development version or a registered one) is going to be taken for the compilation.

---

<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: [February 22, 2023, 10:48pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/15 "2023-02-22T22:48:28Z")

</div>

As you can see from the status, the version of Tulip.jl that you are using in your environment is the master branch of the Github version, not your local copy.

You either need to `dev` the package pointing to the local copy or use `add` the package as I noted above.

```julia
using Pkg
pkg"dev /local/path/to/your/modified/Tulip.jl"

```

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [February 22, 2023, 11:57pm UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/16 "2023-02-22T23:57:20Z")

</div>

Thank you so much for your tips! - I still not know what my mistake was,  
I really tried to make it correct.  
As the master-branch is already fixed, I used:  
`pkg> add Tulip#master`

This made the error disappear.

Unfortunately, I found the next issue:

> <https://github.com/JuliaPackaging/Yggdrasil/issues/6300>
>
> The package \`LLVMExtra\_jll\` cause the following fatal error in compiled packages…:
> \`\`\`
> fatal: error thrown and no exception handler available.
> InitError(mod=:LLVMExtra\_jll, error=ErrorException("Cannot locate artifact 'LLVMExtra' in 'C:\\Users\\stefanpofahl\\.julia\\packages\\LLVMExtra\_jll\\UUk9t\\Artifacts.toml'"))
> error at .\\error.jl:33
> \`\`\`
> The problematic line in the file \`select\_artifacts\` is the following one:
> \`\`\`
> artifacts\_toml = joinpath(dirname(@\_\_DIR\_\_), "Artifacts.toml")
> \`\`\`
> Unfortunatly, I do not know, how to correct this ...

The problematic part is the following line in side `LLVMExtra_jll`:

```julia
artifacts_toml = joinpath(dirname(@ __DIR__ ), "Artifacts.toml")

```

Any suggestions, how to modify this part of the code?

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [February 23, 2023, 10:44am UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/17 "2023-02-23T10:44:55Z")

</div>

> [@ellocco](#):
>
> The problematic part is the following line in side `LLVMExtra_jll`:

In Julia v1.8.5 I am able to compile a portable app containing “Tulip.jl” 🙂

P.S.:  
I found some bugs in my [compile\_app.jl-script](https://github.com/StefanPofahl/Stefans_Julia_RePo/blob/main/AppDir/compile_app.jl) these errors are fixed now.  
I am open for further corrections and suggestions.

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [March 7, 2023, 10:58am UTC](https://discourse.julialang.org/t/missing-relocatability-of-tulip/94886/18 "2023-03-07T10:58:35Z")

</div>

New version of compile script is online: [compile\_app.jl](https://github.com/StefanPofahl/Stefans_Julia_RePo/blob/cc46f0f0bcd16a4c5228706849b070850792da00/AppDir/compile_app.jl)
