Problem with module dependencies in Pluto

I created a module, myModule, that requires the Dates and DataFrames packages.
Fwiw, my src directory contains only myModule.jl which looks like:

module myModule
  using DataFrames, Dates
  export myDF
  function myDF()
      df = DataFrame(a = [1, 2, 3], b = [4, 5, 6], c = [today(), today() + Day(1), today() + Day(2)])
      return df
end # module myModule

and my Project.toml file looks like

name = "myModule"
uuid = "c3019312-639c-46e1-a276-88058c088531"
authors = ["ADANNENBERG <>"]
version = "0.1.0"

DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

The command

using myModule

is sufficient for the module to work in the REPL or in VS Code, i.e. sufficient to make the exported function myDF() work fine in the REPL or VS Code.

In Pluto, however, it appears that the “using DataFrames, Dates” line in myModule is not used or recognized. Instead, when I’m in Pluto I have to use the command

using myModule, DataFrames, Dates

in order not to throw an error.

This was a toy example, but it’s true for every module I’ve created: In the REPL or VS Code I just have to have a line “using moduleName” and all the exported functions in the module work fine. But in Pluto “using moduleName” will bug and tell me that the packages that moduleName depends upon are not found. In Pluto I can only make moduleName work if I have the line “using moduleName, Dates, DataFrames”…

Is this a feature of Pluto, or a sign that I’ve got a problem in myModule that doesn’t cause the REPL or VS Code to bug?

you might be better off finding the Plutonians on Discord

It might also be worth reading about Pluto’s own package management: (📦 Packages — Pluto.jl)

Thanks, I will give it a shot…

First thing i usually do in a notebook is

    import Pkg
    using …

because I’m no good at sharing :joy:

Thanks, that works. Can you explain why in simple terms?

Not really :grinning: Sometimes I just learn the magic spells that work.

Pluto is awesome, but the design is very “principled”, so you either do things the Pluto way or find out how to do things differently.

I set myself up for that one :smiley:

1 Like