You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove ArgumentError() in parse_cache_header() when @depot cannot be resolved (#51989)
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).
0 commit comments