tools.deps

Ensure -Sdescribe doesn't trigger resolution

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Debian stable
    Clojure 1.9.0

Description

Reproduction steps

  1. Delete your local .m2 cache
    rm -rf ~/.m2/
  2. Create a folder
  3. cd into the folder and make sure there is no .cpcache folder
    rm -rf .cpcache
  4. Create a deps.edn file with the following contents
    {:deps {clj-time {:mvn/version "0.14.2"}}}
  5. Run the command
    clojure -Sdescribe

Expected Result
Just the environment and command parsing info as data e.g.

{:version "1.9.0.381"
:config-files ["/usr/local/lib/clojure/deps.edn" "/home/test/.clojure/deps.edn" ]
:install-dir "/usr/local/lib/clojure"
:config-dir "/home/test/.clojure"
:cache-dir ".cpcache"
:force false
:repro false
:resolve-aliases ""
:classpath-aliases ""
:jvm-aliases ""
:main-aliases ""
:all-aliases ""}

Actual Result

Downloading: org/clojure/clojure/1.9.0/clojure-1.9.0.pom from https://repo1.maven.org/maven2/
Downloading: org/clojure/spec.alpha/0.1.143/spec.alpha-0.1.143.pom from https://repo1.maven.org/maven2/
Downloading: org/clojure/pom.contrib/0.2.2/pom.contrib-0.2.2.pom from https://repo1.maven.org/maven2/
Downloading: org/clojure/core.specs.alpha/0.1.24/core.specs.alpha-0.1.24.pom from https://repo1.maven.org/maven2/
Downloading: org/clojure/clojure/1.9.0/clojure-1.9.0.jar from https://repo1.maven.org/maven2/
Downloading: org/clojure/spec.alpha/0.1.143/spec.alpha-0.1.143.jar from https://repo1.maven.org/maven2/
Downloading: org/clojure/core.specs.alpha/0.1.24/core.specs.alpha-0.1.24.jar from https://repo1.maven.org/maven2/
{:version "1.9.0.381"
:config-files ["/usr/local/lib/clojure/deps.edn" "/home/test/.clojure/deps.edn" "deps.edn" ]
:install-dir "/usr/local/lib/clojure"
:config-dir "/home/test/.clojure"
:cache-dir ".cpcache"
:force false
:repro false
:resolve-aliases ""
:classpath-aliases ""
:jvm-aliases ""
:main-aliases ""
:all-aliases ""}

Notice that the dependencies have been resolved, as indicated by several jars being downloaded.

Possible reason for bug

I think the issue is in this part of the clojure script:

# If stale, run make-classpath to refresh cached classpath
if "$stale"; then
if "$verbose"; then
echo "Refreshing classpath"
fi

"$JAVA_CMD" -Xmx256m -classpath "$tools_cp" clojure.main -m clojure.tools.deps.alpha.script.make-classpath --config-files "$config_str" --libs-file "$libs_file" --cp-file "$cp_file" --jvm-file "$jvm_file" --main-file "$main_file" "${tools_args[@]}"
fi

which is followed by

if "$pom"; then
exec "$JAVA_CMD" -Xmx256m -classpath "$tools_cp" clojure.main -m clojure.tools.deps.alpha.script.generate-manifest --config-files "$config_str" --gen=pom "${tools_args[@]}"
elif "$print_classpath"; then
echo "$cp"
elif "$describe"; then
for config_path in "${config_paths[@]}"; do
if [[ -f "$config_path" ]]; then
path_vector="$path_vector\"$config_path\" "
fi
done
cat <<-END
{:version "1.9.0.381"
:config-files [$path_vector]
:install-dir "$install_dir"
:config-dir "$config_dir"
:cache-dir "$cache_dir"
:force $force
:repro $repro
:resolve-aliases "$(join '' ${resolve_aliases[@]})"
:classpath-aliases "$(join '' ${classpath_aliases[@]})"
:jvm-aliases "$(join '' ${jvm_aliases[@]})"
:main-aliases "$(join '' ${main_aliases[@]})"
:all-aliases "$(join '' ${all_aliases[@]})"}
END

As far as I can tell this means, if the .cpcache is stale (as in this case), make-classpath will always be run before handling the -Sdescribe parameter.

Activity

Hide
Sean Corfield added a comment - - edited

Patch attached against 1.9.0 that allows describe option to circumvent stale/cp computation.

Show
Sean Corfield added a comment - - edited Patch attached against 1.9.0 that allows describe option to circumvent stale/cp computation.
Hide
Alex Miller added a comment -

Fix in de4f692

Show
Alex Miller added a comment - Fix in de4f692
Hide
Alex Miller added a comment -

Released in clj 1.10.0.408

Show
Alex Miller added a comment - Released in clj 1.10.0.408

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: