Pluto.jl: Pluto doesn't use Pkg environments?

Created on 9 Sep 2020  路  14Comments  路  Source: fonsp/Pluto.jl

I have an environment setup and activated with my dependencies and have the Pluto notebook in the same folder. However, Pluto does not seem to detect the installed dependencies in the environment?

Then when I run import Pkg; Pkg.add("PlutoUI") in a cell, the global Project.toml and Manifest.toml at .julia/environments/v1.5 get updated instead of those in the environment. Is this expected behaviour?

backend documentation

Most helpful comment

I usually activate the environment via ] activate . . So in this case I should run import Pkg; Pkg.activate(".") in a cell in Pluto?

All 14 comments

Need to explicitly create a new env using Pkg.activate command

repl screenshot

I usually activate the environment via ] activate . . So in this case I should run import Pkg; Pkg.activate(".") in a cell in Pluto?

That's what I usually do, and it's working great for me : )

@Roger-luo is working on making this experience better, see https://github.com/fonsp/Pluto.jl/pull/341 and linked discussions

@fonsp Read the discussions and saw that Pluto has been updated with the functionality. But still not too sure on how to use it. Any advice?

I think to make things more smooth we need #367 and #366 so there will be some breaking changes on this. But for now, just FYI, @limzy12 you can check: https://github.com/fonsp/Pluto.jl/pull/396#issuecomment-689761594

Eventually, I'm thinking about providing a simpler access to open pluto in terminal directly as

pluto --project=<your project path>

and it starts with --project=@. by default.

You can also do:

pkg"activate ."

in a cell

But note that Pluto will always run cells that use using or import before cells that don't. This means that you can't use pkg"..." to set up a notebook environment, because it runs _after_ your imports.

See https://github.com/fonsp/Pluto.jl/issues/142#issuecomment-685135043 for the recommended method.

That seems like very arbitrary behaviour...why not just execute in order?

@dlfivefifty because we can't find out the right order for cells with using ..., as we only use static analysis on the cells - we don't look at the environment, the packages, the exported names from the package. Mostly because we don't want to run code before being able to determine the cell order, and we do need to actually run a modules Julia files to find the exports.

This is something that we can't really easily fix, but yeah running the cells first does feel kinda hacky

Maybe add pkg"..." cells to the priority list?

Yeah that's something we can do, although we are looking a for a more systemic solution - the current way, even with pkg"" prioritized, is too confusing.

You can make a pull request with pkg added to the list and we will see what we can do. If you have thoughts on how to make this work nice, reproducible and predictable by default, that would be an amazing addition #142

I think Mathematica is the gold standard for notebooks.. I'd love it to work like that. but it seems like you are going a very different direction in terms of reactivity so I'm not sure what your plan is.. for example the not being able to have multiple lines in a cell or redefine variables is very strange to me.

Just to be clear:

Current solution

Use Pkg.activate. You need to do everything in one cell to enforce that they run linearly:

begin
    import Pkg
    Pkg.activate(".")
    using A
    using B
    using C
end

Future solution

142

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roflmaostc picture roflmaostc  路  4Comments

MikaelSlevinsky picture MikaelSlevinsky  路  6Comments

jarvist picture jarvist  路  6Comments

FelixBenning picture FelixBenning  路  3Comments

fonsp picture fonsp  路  5Comments