# Problem with PackageCompiler

**URL:** <https://discourse.julialang.org/t/problem-with-packagecompiler/78130>\
**Category:** General Usage\
**Tags:** package-compiler\
**Created:** [March 19, 2022, 2:38pm UTC](https://discourse.julialang.org/t/problem-with-packagecompiler/78130 "2022-03-19T14:38:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [March 19, 2022, 2:38pm UTC](https://discourse.julialang.org/t/problem-with-packagecompiler/78130/1 "2022-03-19T14:38:38Z")

</div>

We have the following MWE. Project structure:

![image](https://global.discourse-cdn.com/julialang/original/3X/2/9/29a366ab2620176b33e98ae151863557a3d126d9.png)

`package1.jl`

```julia
module package1

Base.@ccallable function julia_main()::Cint
    try
        testApp()
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 1
    end
    return 0
end

function testApp()
    filehandle = open("$(@ __DIR__ )/input.txt", "w")
    write(filehandle, "Hello world!")
    close(filehandle)
end 

end 

```

`compile.jl`

```julia
using Pkg
Pkg.activate("$(@ __DIR__ )")
Pkg.resolve()
Pkg.instantiate()

using PackageCompiler
create_app("$(@ __DIR__ )", "$(@ __DIR__ )\\generated"; force=true)

```

`Project.toml`

```julia
name = "package1"
uuid = "6c5e6a99-2dd1-4d89-97f7-17c00267c19c"

[deps]
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"

```

Running `include("compile.jl")` on Julia 1.8.0-beta1 onward we see

```julia
julia> include("compile.jl")
  Activating project at `C:\Users\Win10\source\repos\julia\discourse\package1.jl`
  No Changes to `C:\Users\Win10\source\repos\julia\discourse\package1.jl\Project.toml` 
  No Changes to `C:\Users\Win10\source\repos\julia\discourse\package1.jl\Manifest.toml`
✔ [02m:21s] PackageCompiler: compiling base system image (incremental=false)
Precompiling project...
  7 dependencies successfully precompiled in 46 seconds
✔ [03m:03s] PackageCompiler: compiling incremental system image

```

On Julia 1.7.2 and below we get

```julia
julia> include("compile.jl")
  Activating project at `C:\Users\Win10\source\repos\julia\discourse\package1.jl`
  No Changes to `C:\Users\Win10\source\repos\julia\discourse\package1.jl\Project.toml`
  No Changes to `C:\Users\Win10\source\repos\julia\discourse\package1.jl\Manifest.toml`
✔ [02m:30s] PackageCompiler: compiling base system image (incremental=false)
Precompiling project...
  7 dependencies successfully precompiled in 44 seconds
⠙ [00m:21s] PackageCompiler: compiling incremental system imageAssertion failed: isa<X>(Val) && "cast<Ty>() argument of incompatible type!", file /cygdrive/c/buildbot/worker/package_win64/build/usr/include/llvm/Support/Casting.h, line 269

signal (22): SIGABRT

```

Who is to blame?

```julia

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [March 19, 2022, 3:12pm UTC](https://discourse.julialang.org/t/problem-with-packagecompiler/78130/2 "2022-03-19T15:12:04Z")

</div>

Of course T.J. is to blame… wait, oops, wrong game…

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [March 19, 2022, 6:46pm UTC](https://discourse.julialang.org/t/problem-with-packagecompiler/78130/3 "2022-03-19T18:46:53Z")

</div>

Seriously, is this a problem of `PackageCompiler`, Julia or are we to blame?

Edit: I filed an [issue](https://github.com/JuliaLang/PackageCompiler.jl/issues/674).

---

<div class="post-metadata">

**Author:** ![moyner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moyner/32/30277_2.png) [@moyner](https://discourse.julialang.org/u/moyner)\
**Post date:** [March 21, 2022, 9:47am UTC](https://discourse.julialang.org/t/problem-with-packagecompiler/78130/4 "2022-03-21T09:47:08Z")

</div>

I can confirm this issue - found this thread after googling the cast assertion for my own app. 1.8.0-beta1 works fine.
