Problem in addidng a package to new created package dependencies

Hi all,

I recently created a package (for the first time!) and I have a problem with precompiling my package. When I try using PkgMPC in julia repl I get this warning about lack of being required packages in PkgMPC dependencies.

julia> using PkgMPC
[ Info: Precompiling PkgMPC [aa087d6f-2020-4239-96b7-77f8d7e93fb8]
┌ Warning: Package PkgMPC does not have Plots in its dependencies:
│ - If you have PkgMPC checked out for development and have
│   added Plots as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with PkgMPC
└ Loading Plots into PkgMPC from project dependency, future warnings for PkgMPC are suppressed.

It will be recompiled using the packages I have in my main Project.toml at .../.julia/environments/Project.toml but I want to add these packages into PkgMPC dependencies.

I would appreciate if someone could help me on resolving this issue.

also in my source module I tried import *** where *** are the packages which are required for running PkgMPC.I even tried to use Reexport which failed again. This is what I wrote in PkgMPC.jl:

module PkgMPC

# Write your package code here.
import Plots
import CSV
import JuMP
import Ipopt
import DataFrames
import DifferentialEquations
import PlotlyJS

#=
using Reexport

@reexport using Plots
@reexport using CSV
@reexport using JuMP
@reexport using Ipopt
@reexport using DataFrames
@reexport using DifferentialEquations
@reexport using PlotlyJS
=#

#using Plots, CSV, JuMP, Ipopt, DataFrames, DifferentialEquations

include("Extra.jl")
include("main.jl")
include("NMPC.jl")
include("Plant.jl")


export **************

end

and this is where I have my package on GitHub:
https://github.com/Amirrezz94/PkgMPC.jl

Thank you guys!

The issue, as Julia tells you, is that you don’t have any dependence on Plots.jl etc. listed in your Project.toml.

Go to the root of your repo and start julia --project=.. Now use ] add Plots etc. to add the dependencies to the package’s Project.toml. You basically need to add all packages that you want to using in your package.

2 Likes

That’s exactly what I was looking for!
Thank you.

1 Like