Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using - give a hint in error message when there is a typo in package name #38604

Open
strickek opened this issue Nov 29, 2020 · 2 comments
Open
Labels
error handling Handling of exceptions by Julia or the user REPL Julia's REPL (Read Eval Print Loop)

Comments

@strickek
Copy link
Contributor

I think it is a very common mistake with using statements. As package names are case-sensitive, a small typo in name, eg DataFrames: Dataframes, DataFrame, Dataframe, ..., results in an error message:

julia> using Dataframes
ERROR: ArgumentError: Package Dataframes not found in current path:

  • Run import Pkg; Pkg.add("Dataframes") to install the Dataframes package.

Stacktrace:
[1] require(into::Module, mod::Symbol)
@ Base ./loading.jl:874

in the next step the user will do the suggested solution, which will not work:

julia> import Pkg; Pkg.add("Dataframes")
Updating registry at ~/.julia/registries/General
ERROR: The following package names could not be resolved:

  • Dataframes (not found in project, manifest or registry)

Stacktrace:
[1] pkgerror(msg::String)
@ Pkg.Types ~/projects/julia/usr/share/julia/stdlib/v1.6/Pkg/src/Types.jl:52
[2] ensure_resolved(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; registry::Bool)
@ Pkg.Types ~/projects/julia/usr/share/julia/stdlib/v1.6/Pkg/src/Types.jl:823
...

I suggest to offer a different error message if there is an installed package with an similar name (in Stdlib or in Project deps), like:

julia> using Dataframes
ERROR: ArgumentError: Did you mean DataFrames? Your entry Dataframes is
not found in current path. Correct your entry and try again, or run
import Pkg; Pkg.add("Dataframes") to install the Dataframes package.

Stacktrace:
[1] require(into::Module, mod::Symbol)
@ Base ./loading.jl:868

If this is ok, I can offer to open a pull request (have already a first draft).

@KristofferC
Copy link
Sponsor Member

Either, we allow Pkg to install a hook into the error message or we implement the registry parsing ourselves in Base.

@vtjnash vtjnash added the REPL Julia's REPL (Read Eval Print Loop) label Feb 1, 2024
@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 1, 2024

Pkg does install a hook (via REPL), which seems like it could do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants