boot-clj / boot

Build tooling for Clojure.
https://boot-clj.github.io/
Eclipse Public License 1.0
1.75k stars 180 forks source link

*print-length* and *print-level* have unexpected consequences with set-env! in the REPL #586

Closed arsenerei closed 7 years ago

arsenerei commented 7 years ago

Thanks for all the effort you've put into boot!

I was trying to follow this post and got a "Unmatched delimiter: ]" exception when calling (set-env! :dependencies '[[cheshire "5.5.0"]]).

After some debugging, I discovered it was the *print-length* and *print-level* settings in my profile.boot causing the issue.

I'm not sure if this is intended behavior, but it certainly caught me by surprise.

$ boot repl
nREPL server started on port 36881 on host 127.0.0.1 - nrepl://127.0.0.1:36881
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
OpenJDK 64-Bit Server VM 1.8.0_121-b13
        Exit: Control+D or (exit) or (quit)
    Commands: (user/help)
        Docs: (doc function-name-here)
              (find-doc "part-of-name-here")
Find by Name: (find-name "part-of-name-here")
      Source: (source function-name-here)
     Javadoc: (javadoc java-object-or-class-here)
    Examples from clojuredocs.org: [clojuredocs or cdoc]
              (user/clojuredocs name-here)
              (user/clojuredocs "ns-here" "name-here")
boot.user=> (set! *print-level* 0)
0
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])

java.lang.AssertionError: Assert failed: value not readable by Clojure reader
                          :dependencies => #
                          #
boot.user=> (set! *print-level* 1)
1
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])

java.lang.AssertionError: Assert failed: value not readable by Clojure reader
                          :dependencies => [#]
                          (printable-readable? v'')
boot.user=> (set! *print-level* 2)
2
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])

java.lang.RuntimeException: Unmatched delimiter: )
boot.user=> (set! *print-level* 3)
3
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])

java.lang.RuntimeException: Reader tag must be a symbol
boot.user=> (set! *print-level* 4)
4
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])

java.lang.RuntimeException: Unmatched delimiter: ]
boot.user=> (set! *print-level* 5)
5
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])

java.lang.RuntimeException: Unmatched delimiter: ]
boot.user=> (set! *print-level* 6)
6
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])
Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.5.1
nil

There are similar exceptions with *print-length*

boot.user=> (set! *print-length* 0)
0
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])

java.lang.RuntimeException: Map literal must contain an even number of forms
boot.user=> (set! *print-length* 12)
12
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])

java.lang.RuntimeException: Map literal must contain an even number of forms
boot.user=> (set! *print-length* 13)
13
boot.user=> (set-env! :dependencies '[[cheshire "5.5.0"]])
Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.5.1
nil
RadicalZephyr commented 7 years ago

From the doc for set-env! I'm not at all surprised that this fails like this. I guess the right thing to do for boot would be to bind *print-level* and *print-length* to nil in the critical areas where the env is being printed.

alandipert commented 7 years ago

Thanks for the report, this is fixed in master :+1: