@@ -250,7 +250,9 @@ to get the file name part of the path.
250
250
function pathof (m:: Module )
251
251
pkgid = get (Base. module_keys, m, nothing )
252
252
pkgid === nothing && return nothing
253
- return Base. locate_package (pkgid)
253
+ origin = get (Base. pkgorigins, pkgid, nothing )
254
+ origin === nothing && return nothing
255
+ return origin. path
254
256
end
255
257
256
258
"""
@@ -824,18 +826,19 @@ function require(into::Module, mod::Symbol)
824
826
return require (uuidkey, cache)
825
827
end
826
828
827
- struct PkgOrigin
829
+ mutable struct PkgOrigin
828
830
# version::VersionNumber
829
- # path::String
831
+ path:: Union{ String,Nothing}
830
832
cachepath:: Union{String,Nothing}
831
833
end
834
+ PkgOrigin () = PkgOrigin (nothing , nothing )
832
835
const pkgorigins = Dict {PkgId,PkgOrigin} ()
833
836
834
837
function require (uuidkey:: PkgId , cache:: TOMLCache = TOMLCache ())
835
838
if ! root_module_exists (uuidkey)
836
839
cachefile = _require (uuidkey, cache)
837
840
if cachefile != = nothing
838
- pkgorigins[ uuidkey] = PkgOrigin ( cachefile)
841
+ get! (PkgOrigin, pkgorigins, uuidkey) . cachepath = cachefile
839
842
end
840
843
# After successfully loading, notify downstream consumers
841
844
for callback in package_callbacks
@@ -907,6 +910,7 @@ function _require(pkg::PkgId, cache::TOMLCache)
907
910
toplevel_load[] = false
908
911
# perform the search operation to select the module file require intends to load
909
912
path = locate_package (pkg, cache)
913
+ get! (PkgOrigin, pkgorigins, pkg). path = path
910
914
if path === nothing
911
915
throw (ArgumentError ("""
912
916
Package $pkg is required but does not seem to be installed:
@@ -1496,7 +1500,7 @@ function stale_cachefile(modpath::String, cachefile::String, cache::TOMLCache)
1496
1500
end
1497
1501
1498
1502
if isa (id, PkgId)
1499
- pkgorigins[id] = PkgOrigin ( cachefile)
1503
+ get! (PkgOrigin, pkgorigins, id) . cachepath = cachefile
1500
1504
end
1501
1505
1502
1506
return depmods # fresh cachefile
0 commit comments