# Pluto on Binder: use a repo environment rather than Pluto managed environment?

**URL:** <https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311>\
**Category:** Pluto\
**Tags:** binder\
**Created:** [January 27, 2022, 6:03pm UTC](https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311 "2022-01-27T18:03:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [January 27, 2022, 6:03pm UTC](https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311/1 "2022-01-27T18:03:47Z")

</div>

I would like to load a Pluto notebook in Binder that uses an environment managed outside the notebook itself (but in the same repository).

Is this possible somehow to swing using the raw URL for a Pluto notebook in a remote repo?

E.g., my first cell says:

```julia
begin
	using Pkg
	Pkg.activate(".")
	Pkg.instantiate()
	using PlutoUI
end

```

Using [https://pluto-on-binder.glitch.me/](https://pluto-on-binder.glitch.me/), it doesn’t know how to find the Project/Manifest files and thus the version of PlutoUI I want to manage from there.

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [January 27, 2022, 6:44pm UTC](https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311/2 "2022-01-27T18:44:46Z")

</div>

Don’t know how binder runs the notebook, but could you just clone the repo in the first cell to some local path and then activate that path?

---

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [January 27, 2022, 8:28pm UTC](https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311/3 "2022-01-27T20:28:15Z")

</div>

It makes sense to me to be able to download the `Manifest.toml` and `Project.toml` files to a local temp directory and activate from there, but I can’t figure out how to do that … see this [related question](https://discourse.julialang.org/t/how-do-i-use-downloads-download-to-download-to-a-custom-location/75322) I just posted.

---

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [January 28, 2022, 8:28pm UTC](https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311/4 "2022-01-28T20:28:07Z")

</div>

I’m trying with this code in the first cell to download config files to a temp directory:

```julia
begin
	using Downloads
	using Pkg

	owd = pwd()

	if isfile(joinpath("..","Manifest.toml")) && isfile(joinpath("..","Project.toml"))

		cd("..")
		Pkg.activate(".")
		Pkg.resolve()
		Pkg.instantiate()
		cd(owd)
		
	elseif isfile(joinpath(".","Manifest.toml")) && isfile(joinpath(".","Project.toml"))

		Pkg.activate(".")
		Pkg.resolve()
		Pkg.instantiate()
		
	else

		manifest_url = "https://URL/to/Manifest.toml"
		project_url = "https://URL/to/Project.toml"
		
		temp_dir = mktempdir(".",cleanup=true)
		
		Downloads.download(manifest_url,joinpath(owd,temp_dir,"Manifest.toml"))
		Downloads.download(project_url,joinpath(owd,temp_dir,"Project.toml"))
		
		cd(temp_dir)
		
		Pkg.activate(".")
		Pkg.instantiate()
		
		cd(owd)
	end

end

```

In some projects, I have these files in a folder just above the notebook. In others, I have them in the same folder. If it’s running on Binder, they won’t be in either location, so we can make a temp directory and download them from the repository, then activate and instantiate on that directory.

It works well locally and on Binder on simple test cases, but on my real notebook, I’m getting this error running the notebook on Binder:

```julia
expected package `QOI [4b34888f]` to be registered

    pkgerror(::String)@Types.jl:55
    check_registered(::Pkg.Types.Context, ::Vector{Pkg.Types.PackageSpec})@Operations.jl:1157
    var"#instantiate#253"(::Nothing, ::Bool, ::Bool, ::Base.BinaryPlatforms.Platform, ::Bool, ::Bool, ::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Pkg.API.instantiate), ::Pkg.Types.Context)@API.jl:1372
    instantiate@API.jl:1325[inlined]
    #instantiate#252@API.jl:1321[inlined]
    instantiate()@API.jl:1321
    top-level scope@

```

[Some](https://stackoverflow.com/questions/65461774/error-expected-package-juno-e5e0dc1b-to-be-registered) solutions suggest deleting the registry to fix it, but I can’t do that on Binder.

Or to update the registry with [`Pkg.Registry.update()`](https://discourse.julialang.org/t/error-expected-package-to-be-registered-in-juliapro/52430). This also did not solve it.

I tried deleting the Manifest.toml and runing `pkg> instantiate` again to make it fresh, but that yields the same error.

Linking to newly created issues on [QOI](https://github.com/KristofferC/QOI.jl/issues/10) and [Pluto on Binder](https://github.com/fonsp/pluto-on-binder/issues/18) (don’t know if these are the issue or not).

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 29, 2022, 3:14pm UTC](https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311/5 "2022-01-29T15:14:27Z")

</div>

What Julia version are you using? Can you see if QOI.jl is present in the downloaded registry? This folder should exist [https://github.com/JuliaRegistries/General/tree/master/Q/QOI](https://github.com/JuliaRegistries/General/tree/master/Q/QOI).

---

<div class="post-metadata">

**Author:** ![thompsonmj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thompsonmj/32/25172_2.png) [@thompsonmj](https://discourse.julialang.org/u/thompsonmj)\
**Post date:** [January 30, 2022, 2:36am UTC](https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311/6 "2022-01-30T02:36:47Z")

</div>

With Pluto on Binder, it’s running Julia 1.6.3. I created the manifest locally for a project with the header, which I download from a remote repo:

```julia
# This file is machine-generated - editing it directly is not advised

julia_version = "1.7.1"
manifest_format = "2.0"

```

When I do `Pkg.add(“QOI”), it seems to get past it (to proceed to other errors with other packages…) but I’d like to figure out how to get it to load correclty straight from the manifest if possible.

---

<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:** [May 10, 2022, 1:33pm UTC](https://discourse.julialang.org/t/pluto-on-binder-use-a-repo-environment-rather-than-pluto-managed-environment/75311/7 "2022-05-10T13:33:23Z")

</div>

The site [https://pluto-on-binder.glitch.me/](https://pluto-on-binder.glitch.me/) was still using an old version of Julia and Pluto. I just updated, try again!

The example notebook uses `Pkg` to set up a package environment, because it was written before [🎁 Package management · fonsp/Pluto.jl Wiki · GitHub](https://github.com/fonsp/Pluto.jl/wiki/%F0%9F%8E%81-Package-management) existed! You should definitely use the built-in package manager for binder, which will also fix this issue.
