Skip to content

Commit c57dcee

Browse files
committed
Remove ArgumentError() in parse_cache_header() when @depot cannot be resolved
In the original implementation of relocatable package cache files, `parse_cache_header()` was made responsible for resolving `@depot/`-relative paths, and it threw an `ArgumentError()` if it could not find one. However, this could happen for a few reasons: 1. The `JULIA_DEPOT_PATH` could be set incorrectly, so the appropriate source text files could not be found in an appropriate `packages/` directory. 2. The package could have been upgraded, leaving a cache file for an older version on-disk, but no matching source files. For a concrete example of (2), see the following `bash` script: #!/bin/bash set -euo pipefail TEMP_PATH=$(mktemp -d) JULIA=${JULIA:-julia} echo JULIA: ${JULIA} export JULIA_DEPOT_PATH="${TEMP_PATH}" trap 'rm -rf ${TEMP_PATH}' EXIT # Create a `Foo.jl` that has an `internal.jl` within it FOO_DIR=${JULIA_DEPOT_PATH}/dev/Foo mkdir -p ${FOO_DIR}/src cat >${FOO_DIR}/Project.toml <<EOF name = "Foo" uuid = "00000000-0000-0000-0000-000000000001" version = "1.0.0" EOF cat >${FOO_DIR}/src/Foo.jl <<EOF module Foo include("internal.jl") end EOF cat >${FOO_DIR}/src/internal.jl <<EOF # Nothing to see here, folks EOF ${JULIA} -e "import Pkg; Pkg.develop(\"Foo\"); Pkg.precompile()" # Change `Foo` to no longer depend on `internal.jl`; this should invalidate its cache files cat >${FOO_DIR}/src/Foo.jl <<EOF module Foo end EOF rm -f ${FOO_DIR}/src/internal.jl # This should print `SUCCESS!`, not `FAILURE!` ${JULIA} -e 'using Foo; println("SUCCESS!")' || echo "FAILURE!" This pull request removes the `ArgumentError()`, as it seems reasonable to require `parse_cache_header()` to not throw errors in cases like these. We instead rely upon a higher level validation to reject a cachefile whose depot cannot be found, which should happen when `stale_cachefile()` later checks to ensure that all includes are found on-disk, (which will be false, as these paths start with `@depot/`, an unlikely path prefix to exist).
1 parent b5a531a commit c57dcee

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

base/loading.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,11 +2718,9 @@ function parse_cache_header(f::IO, cachefile::AbstractString)
27182718
chi.filename srcfiles && push!(keepidx, i)
27192719
end
27202720
if depot === :no_depot_found
2721-
throw(ArgumentError("""
2722-
Failed to determine depot from srctext files in cache file $cachefile.
2723-
- Make sure you have adjusted DEPOT_PATH in case you relocated depots."""))
2721+
@debug("Unable to resolve @depot tag in cache file $cachefile", srcfiles)
27242722
elseif depot === :missing_depot_tag
2725-
@debug "Missing @depot tag for include dependencies in cache file $cachefile."
2723+
@debug("Missing @depot tag for include dependencies in cache file $cachefile.", srcfiles)
27262724
else
27272725
for inc in includes
27282726
inc.filename = replace(inc.filename, r"^@depot" => depot)

0 commit comments

Comments
 (0)