Unexpected path structure for module

I have a long term problem using apropos():

julia> apropos("interpolate")
Base.@async
Base.Regex
Base.@eval
Base.Threads.@spawn
DocStringExtensions.Abbreviation
DocStringExtensions.interpolation
MacroTools.@qq
MacroTools.@q
ERROR: Unexpected path structure for module source: /Users/Thomas/Documents/Julia/Extensions/Extensions.jl

I don’t see anything special inside my Extensions module. What should I do?

Thanks

Assuming this is intended to be a package, it may work better if you insert a src into the path.

/Users/Thomas/Documents/Julia/Extensions/src/Extensions.jl

If that doesn’t help it would be useful to know more exactly what files are in Julia/Extensions.

the file is located exactly at

so, there’s no “src” sub-folder inside.

There’re other .jl inside Extensions/, but how does it matter?

Does it or does it not help to add a src directory in the layout?

Other .jl files might not be interesting but the presence or non-presence of Project.toml might be.

adding ‘src’ NOT help (actually NOT work because the path is invalid).

This problem persists for years. Everything is fine except that calling apropos() would trigger the error.

You need to actually restructure your package, i.e. move Extensions/Extensions.jl into Extensions/src/Extensions.jl … Julia expects packages to have a standardized directory structure.

!!! I never know that Julia requires a specific path structure !!! anywhere in docs I could find related documents?

so, if I create a src folder and move everything in it, how should I add it to the LOAD_PATH?

now:

push!(LOAD_PATH, joinpath(ROOT_PATH, "Extensions/") )

should I change it to:

push!(LOAD_PATH, joinpath(ROOT_PATH, "Extensions/src") )

?

(ROOT_PATH is /Users/Thomas/Documents/Julia)

thanks

You should not move “everything” into the src/ folder, only the source files. The beginning here 5. Creating Packages · Pkg.jl provides an overview on the Folder structure.

For the remainder of a package, like tests, docs, the GitHub CI workflows, code formatting etc, there exist helpers like BestieTemplate - Your best practices friend · BestieTemplate.jl.

wow apropos() works after moving to src! Thanks.

anyway, LOAD_PATH now should include src also:

push!(LOAD_PATH, joinpath(ROOT_PATH, "Extensions/src") )

If you are using the package structure, it is better not to manually edit LOAD_PATH, but instead to use the package system, e.g. dev or activate commands, as described in the Pkg manual.