Using a package imports some other unwanted packages, how to find out where is the unwanted package from?

I found out some unwanted package A is imported and cause name space conflict with my own module Main. I didn’t import/using package A, so it must be loaded by other other package that I import/using. How could I find out which package loaded package A?

I may be wrong here, but I think importing or using a package/module into your code should not bring any other module/package into your namespace besides the explicited one. Are you sue this is what is happening? Can you post the error message?

You can always go through your packages manually like this

julia> using B

julia> A
ERROR: UndefVarError: A not defined

julia> using C

julia> A
A

where we see that (in this example) B was not exporting A but C was.

This is a bit tedious when you import many packages. Is there a shortcut?

I found the culprit.

Somehow using Plots also loadsalpha from package ColorTypes

using Plots
julia> ColorTypes.alpha
alpha (generic function with 5 methods)

This conflict with my const alpha =1
What I don’t understand is that in Plots I don’t see its dependence on ColorTypes

So is it true that import/using one package won’t load other packages?

I believe not, one package can export whatever they want and they may export things from other packages.

No direct dependance, but

(@v1.6) pkg> activate --temp
  Activating new environment at `/tmp/jl_bxylqu/Project.toml`

(jl_bxylqu) pkg> st
      Status `/tmp/jl_bxylqu/Project.toml` (empty project)

(jl_bxylqu) pkg> add Plots
    Updating registry at `~/.julia/registries/General`
   Resolving package versions...
   Installed Latexify ─────── v0.15.7
   Installed StatsBase ────── v0.33.12
   Installed ChainRulesCore ─ v1.10.0
    Updating `/tmp/jl_bxylqu/Project.toml`
  [91a5bcdd] + Plots v1.22.6
    Updating `/tmp/jl_bxylqu/Manifest.toml`
  [79e6a3ab] + Adapt v3.3.1
  [d360d2e6] + ChainRulesCore v1.10.0
  [35d6a980] + ColorSchemes v3.15.0
  [3da002f7] + ColorTypes v0.11.0
...

so it is somewhere in the dependancy tree.