Value of @__DIR__ in Pluto notebook on Binder

I have a Pluto notebook checked into GitHub that I’d like to be able to access through Binder.

My notebook uses @DIR to activate a workspace (also in GitHub) that identifies the packages needed by the notebook.

This works fine on my local clone, but from Binder, @DIR refers to some binder directory, rather than to the workspace directory on GitHub where the notebook lives.

What should I be doing to make this work? I’m trying to avoid waiting for the package manager to compute the transitive closure of the package dependencies when my notebook is opened.

My workspace and notebook are here:

Thanks.

Isn’t this solved by Pluto’s built in package manager? As the manifest is part of the notebook file itself you shouldn’t have to rely on other files in some directory?

1 Like

I don’t know. I’ve done a Pkg.update(“Pluto”) maybe half a dozen times in the past few days and Pluto still complains that it is running an older version. I’ll try again, paying close attention to Pluto’s startup output which zips by.

In any case, I have a much larger notebook that I’m gradually migrating code out of and into a package. I’ll want that notebook and package to both use the same workspace so I’d like for @DIR or something like it to work for GitHub URIs.

Isn’t this solved by Pluto’s built in package manager? As the manifest is part of the notebook file itself you shouldn’t have to rely on other files in some directory?

Have you done the update from the REPL before starting Pluto or withing Pluto? Have a look at my answer here on a similar issue.

If you’re in the REPL, just do add Pluto@0.16 to force an upgrade and/or get more information about what in your environment is preventing an update.

Thanks for that suggestion.

Pkg.add(PackageSpec(name="Pluto", version="0.16"))

(because ]commands don’t play nice with emacs shell mode) showed me that PlutoTool (a package of mine) was constraining the Pluto version. I fixed that and updated Pluto. Now it starts without a version warning.

1 Like

I’ve done a bit of stubling around with my binder link.

If I open

and evaluate @FILE and @DIR in the resulting notebook, I get references to /srv/julia/pkg/pluto_notebooks rather than to my github repository.

I’m trying Pluto’s package manager instead of using my own workspace. I use a couple of unregistered packages so I Pkg.add those.

My notebook is at

The binder link I’m using is

In binder, my notebook gets the error

ArgumentError: Package Unitful not found in current path:

- Run `import Pkg; Pkg.add("Unitful")` to install the Unitful package.

but Unitful is in the general package registry here

https://github.com/JuliaRegistries/General/tree/master/U/Unitful

Shouldn’t the Pluto package manager be finding it there?

Summary:

Pluto’s internal package manager can only find registered packages.

I’ve not found a way to get a Pluto notebook running on binder.plutojl.org to use a workspace that’s checked in to GitHub.

Explicit Pkg.add and using seem to be the only way to run my notebook on binder.

1 Like