# My Package cannot be installed using Pkg.add

**URL:** <https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294>\
**Category:** General Usage\
**Tags:** package, pkg\
**Created:** [January 26, 2024, 10:15am UTC](https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294 "2024-01-26T10:15:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [January 26, 2024, 10:15am UTC](https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294/1 "2024-01-26T10:15:24Z")

</div>

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](https://github.com/AhmedSalih3d/SPHExample)

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:

```julia
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
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

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [January 26, 2024, 10:34am UTC](https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294/2 "2024-01-26T10:34:12Z")

</div>

> <https://github.com/AhmedSalih3d/SPHExample/blob/764774a1d0f2bd476885c7a6f2c97472988dad8b/src/SPHExample.jl#L1-L7>

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.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [January 26, 2024, 10:42am UTC](https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294/3 "2024-01-26T10:42:31Z")

</div>

Thanks for the hint!

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

Now I get:

```julia
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:

> **[GitHub - AhmedSalih3d/SPHExample at 3-error-wher-try-pkgadd](https://github.com/AhmedSalih3d/SPHExample/tree/3-error-wher-try-pkgadd)**
>
> 3-error-wher-try-pkgadd

Kind regards

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [January 26, 2024, 11:06am UTC](https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294/4 "2024-01-26T11:06:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [January 26, 2024, 5:59pm UTC](https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294/6 "2024-01-26T17:59:38Z")

</div>

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:

```julia
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

> <https://github.com/AhmedSalih3d/SPHExample/blob/3-error-wher-try-pkgadd/src/SPHExample.jl>

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

Kind regards

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [January 26, 2024, 6:28pm UTC](https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294/7 "2024-01-26T18:28:13Z")

</div>

> [@Ahmed\_Salih](#):
>
> In the files, I already do `export ..`, but I found I had to reiterate it in the [SPHExample.jl](https://juliahub.com/ui/Packages/SPHExample)

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

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [January 26, 2024, 9:53pm UTC](https://discourse.julialang.org/t/my-package-cannot-be-installed-using-pkg-add/109294/8 "2024-01-26T21:53:12Z")

</div>

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