My Package cannot be installed using Pkg.add

Hello!

I think the issue is to due with my specific package and not any bug in Pkg.

The package is: GitHub - AhmedSalih3d/SPHExample: Simple SPH dam-break simulation in Julia

When I do Pkg.add(url="https://github.com/AhmedSalih3d/SPHExample.git")

It seems to work and after installing for a few minutes it then outputs:

Precompiling project...
  ✗ SPHExample
  73 dependencies successfully precompiled in 126 seconds. 46 already precompiled.
  1 dependency errored.
  For a report of the errors see `julia> err`. To retry use `pkg> precompile` 

So SPHExample was never installed, which is unfortunate. I really am unsure where to start on this?

It works fine for me when I do a ‘git clone’ directly and then run the main script, but does not when trying to do it the more Julia way, through Pkg.add.

Any pointers or anyone who can spot what I am missing?

EDIT: And err outputs the following, which I just realized.

julia> err
PkgPrecompileError: The following 1 direct dependency failed to precompile:

SPHExample [49649ea8-6f54-4931-9342-0ba915f114f7]

Failed to precompile SPHExample [49649ea8-6f54-4931-9342-0ba915f114f7] to "C:\\Users\\-\\.julia\\compiled\\v1.10\\SPHExample\\jl_E56F.tmp".
ERROR: LoadError: Creating a new global in closed module `Main` (`AuxillaryFunctions`) breaks incremental compilation because the side effects will not be permanent.
Stacktrace:
 [1] includet(mod::Module, file::String)
   @ Revise C:\Users\-\.julia\packages\Revise\FaTes\src\packagedef.jl:1026
 [2] includet(file::String)
   @ Revise C:\Users\-\.julia\packages\Revise\FaTes\src\packagedef.jl:1031
 [3] top-level scope
   @ C:\Users\-\.julia\packages\SPHExample\fR52f\src\SPHExample.jl:1
 [4] include
   @ Base .\Base.jl:495 [inlined]
 [5] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
   @ Base .\loading.jl:2216
 [6] top-level scope
   @ stdin:3
in expression starting at C:\Users\-\.julia\packages\SPHExample\fR52f\src\SPHExample.jl:1
in expression starting at stdin:3

Kind regards

Try getting rid of Revise.jl altogether as a dependency (of your package, I’m not talking about the REPL), pretty sure your package doesn’t need it. Use include instead of includet, of course.

If the problem persists afterwards, give the error messages again.

1 Like

Thanks for the hint!

Revise should only be used for when developing the package not the final release, got it.

Now I get:

julia> err
PkgPrecompileError: The following 1 direct dependency failed to precompile:

SPHExample [49649ea8-6f54-4931-9342-0ba915f114f7]

Failed to precompile SPHExample [49649ea8-6f54-4931-9342-0ba915f114f7] to "C:\\Users\\-\\.julia\\compiled\\v1.10\\SPHExample\\jl_247.tmp".
ERROR: LoadError: UndefVarError: `include` not defined

I suppose a simple using Pkg at top will fix it, but I don’t think I’ve seen other packages do that?

Made a branch here with the changes of removing Revise, and it outputs the error above:

Kind regards

You have to enclose your package code into a module: module SPHExample ... end.

Also, you shouldn’t have Manifest.toml in your Git repo, usually it’s in .gitignore (as automatically set up by PkgTemplates.jl), so you don’t have to worry about that.

And don’t forget to delete Revise.jl from your package’s deps, in Project.toml.

3 Likes

Thanks a ton!

I got it to work now. Just wanted to inquire, is this the intended way in the module to export the name space further:

module SPHExample

    include("AuxillaryFunctions.jl"); 
    include("PreProcess.jl");         
    include("PostProcess.jl");        
    include("TimeStepping.jl");       
    include("SimulationEquations.jl");
    
    # Re-export desired functions from each submodule
    using .PreProcess: LoadParticlesFromCSV
    export LoadParticlesFromCSV

    using .PostProcess: create_vtp_file
    export create_vtp_file

    using .TimeStepping: Δt
    export Δt

    using .SimulationEquations: Wᵢⱼ, ∑ⱼWᵢⱼ, Optim∇ᵢWᵢⱼ, ∑ⱼ∇ᵢWᵢⱼ, Pressure, ∂Πᵢⱼ∂t, ∂ρᵢ∂tDDT, ∂vᵢ∂t
    export Wᵢⱼ, ∑ⱼWᵢⱼ, Optim∇ᵢWᵢⱼ, ∑ⱼ∇ᵢWᵢⱼ, Pressure, ∂Πᵢⱼ∂t, ∂ρᵢ∂tDDT, ∂vᵢ∂t

end

In the files, I already do export .., but I found I had to reiterate it in the SPHExample.jl

Other than that, I learned a lot and now it works!

Kind regards

1 Like

Yes, export acts on the module level, not on the package level.

1 Like

If you want to ‘forward’ all exported symbols from a subpackage, you can use Reexport.jl for convenience :slight_smile:

1 Like