# Pluto and package loading

**URL:** <https://discourse.julialang.org/t/pluto-and-package-loading/125684>\
**Category:** General Usage\
**Tags:** pluto\
**Created:** [February 8, 2025, 9:27am UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684 "2025-02-08T09:27:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Ghislain\_Quenum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jose_ghislain_quenum/32/204363_2.png) [@Jose\_Ghislain\_Quenum](https://discourse.julialang.org/u/Jose_Ghislain_Quenum)\
**Post date:** [February 8, 2025, 9:27am UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684/1 "2025-02-08T09:27:54Z")

</div>

Hey all, I am observing a weird behavior from Pluto. While trying to load the Bandits package (available at [Bandits](https://github.com/rawls238/Bandits.jl.git) ), I realised the package was not declared in the registry. This forced me to add the command Pkg.add(url=“[GitHub - rawls238/Bandits.jl: Implementation of multi-armed bandits in Julia](https://github.com/rawls238/Bandits.jl.git)”) to my notebook. Although it loads the Bandits package, it cannot load any other package with the “using” keyword. I must use Pkg.add() Is that expected behavior? Did I miss a configuration?

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [February 8, 2025, 12:06pm UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684/2 "2025-02-08T12:06:44Z")

</div>

That’s how Pluto works. Either it automatically adds all packages before `using` and removes them once the cell with `using` is deleted, but you can only use registered packages, or you go with the general `Pkg` mechanism.  
A workaround is to create a local registry (see LocalRegistry.jl), register anything you need there, add it in REPL through `pkg"registry add myregistry"`, and then Pluto can use packages registered there the same way as the packages from the General registry.

---

<div class="post-metadata">

**Author:** ![dmetivie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmetivie/32/6926_2.png) [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Post date:** [October 1, 2025, 5:55am UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684/3 "2025-10-01T05:55:59Z")

</div>

And if you want to share the notebook, you need to add

```julia-auto
pkg"registry add myregistry"

```

inside the notebook?

---

<div class="post-metadata">

**Author:** ![dmetivie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmetivie/32/6926_2.png) [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Post date:** [October 1, 2025, 11:06am UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684/4 "2025-10-01T11:06:30Z")

</div>

I tried using

```julia
begin
	Pkg.pkg"registry add https://github.com/myLocalRegistry"
	using mylocalPkg
end

```

it works on my local machine but does not with CI from [GitHub - JuliaPluto/static-export-template: A template to automatically convert Pluto notebooks to an HTML website with GitHub Pages. Demo page:](https://github.com/JuliaPluto/static-export-template).  
It just fails to install.  
I also get

```julia
┌ Warning: Pkg operation failed. Updating registries and trying again...
└ @ GracefulPkg /srv/julia/pkg/packages/GracefulPkg/LmTcK/src/apply strategies.jl:92

```

---

<div class="post-metadata">

**Author:** ![dmetivie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmetivie/32/6926_2.png) [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Post date:** [October 1, 2025, 11:25am UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684/5 "2025-10-01T11:25:05Z")

</div>

It seems it cannot be done from Pluto with the native pkg management, see:

> **[📦 Packages – Built-in package management — Pluto.jl](https://plutojl.org/en/docs/packages/#custom-registries)**
>
> Pluto.jl automatically manages a package environment for your notebook.

and

> **[📦 Packages: advanced – Pkg.activate in a cell — Pluto.jl](https://plutojl.org/en/docs/packages-advanced/)**
>
> How to use Pkg.activate in Pluto.jl notebooks to set up a custom Pkg environment.

---

<div class="post-metadata">

**Author:** ![Vasily\_Pisarev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vasily_pisarev/32/7929_2.png) [@Vasily\_Pisarev](https://discourse.julialang.org/u/Vasily_Pisarev)\
**Post date:** [October 2, 2025, 7:33am UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684/6 "2025-10-02T07:33:59Z")

</div>

I’ve just discovered this pattern

```julia-auto
try
	using Bandits
catch notfound
	using Pkg
	RegistrySpec(url = "https://github.com/myLocalRegistry.git") |> Pkg.Registry.add
	error("The registry https://github.com/myLocalRegistry has been added; you need to restart your Pluto session")
end

```

That way, if the registry has been added, Pluto simply loads the package. Otherwise, it adds the registry before showing a message asking to restart the notebook.  
Note that “Restart notebook” button which shows would not suffice. One needs to go to Pluto main menu, kill the notebook from there and start it again.

---

<div class="post-metadata">

**Author:** ![dmetivie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmetivie/32/6926_2.png) [@dmetivie](https://discourse.julialang.org/u/dmetivie)\
**Post date:** [October 3, 2025, 10:26am UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684/7 "2025-10-03T10:26:06Z")

</div>

That should work thanks. However, in terms of user experience, it is not fun!

---

<div class="post-metadata">

**Author:** ![fonsp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fonsp/32/222349_2.png) [@fonsp](https://discourse.julialang.org/u/fonsp)\
**Post date:** [October 14, 2025, 11:02am UTC](https://discourse.julialang.org/t/pluto-and-package-loading/125684/8 "2025-10-14T11:02:12Z")

</div>

Hi!

In the Julia REPL, you can use `Pluto.activate_notebook_environment("../path/to/notebook.jl")`. After this command, you can use the Pkg REPL `]` to inspect and modify the notebook package environment. From here, you can add a local package (from path or from git URL), without needing a local registry.

Learn more about `activate_notebook_environment`: [📦 Packages: advanced – Pkg.activate in a cell — Pluto.jl](https://plutojl.org/en/docs/packages-advanced/#activate_notebook_environment)

* * *

# Future

I am also working on adding functionality for this directly into Pluto’s UI: [📋 Guided Project.toml editor by fonsp · Pull Request #3218 · fonsp/Pluto.jl · GitHub](https://github.com/fonsp/Pluto.jl/pull/3218)
