Skip to content

Hint or helper at REPL for using/importing non-package modules #40959

Closed
@BioTurboNick

Description

@BioTurboNick
module Foo
    a = 5
    export a
end
using Foo
#=
ERROR: ArgumentError: Package Foo not found in current path:
- Run `import Pkg; Pkg.add("Foo")` to install the Foo package.
=#

I think the reasonable approach, as discussed with @StefanKarpinski and @DilumAluthge, would be:

  • If package not present and not in registry but a module is defined in Main, hint that the user needs to have the dot in front: using .Foo
  • If package is in registry and a module is defined in Main, offer to install package. Possibly also note that a module with the same name is defined in Main, and provide hint. Or install package and then provide hint after.
  • If package is already added and a module is defined in Main, import the package and provide hint.

This could potentially be done extending the hooks created for #39026

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions