pwalker

pwalker

Programming Clojure, Third Edition: Invalid token: ::music/id spec error (122)

Hi @alexmiller

I’ve been following along through PC 3rd, and hit a bump on page 122 - the ‘name’ format for the spec seems incorrect. I went back and it looked like adding a namespace might fix it, but that didn’t help either, I still get the ‘invalid token’ error.

Code:
(ns net.solarwinter
(:require [clojure.spec.alpha :as s]))

(s/def ::music/id uuid?)

Evaluating this produces:

  1. Unhandled clojure.lang.Compiler$CompilerException
    Error compiling spec.clj at (4:18)
    #:clojure.error{:phase :read-source,
    :line 4,
    :column 18,
    :source
    “/Users/paul/Documents/Programming/clojure/spec.clj”}
    Compiler.java: 7647 clojure.lang.Compiler/load
    REPL: 1 user/eval7690
    REPL: 1 user/eval7690
    Compiler.java: 7181 clojure.lang.Compiler/eval
    Compiler.java: 7136 clojure.lang.Compiler/eval
    core.clj: 3202 clojure.core/eval
    core.clj: 3198 clojure.core/eval
    interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn/fn
    AFn.java: 152 clojure.lang.AFn/applyToHelper
    AFn.java: 144 clojure.lang.AFn/applyTo
    core.clj: 667 clojure.core/apply
    core.clj: 1977 clojure.core/with-bindings*
    core.clj: 1977 clojure.core/with-bindings*
    RestFn.java: 425 clojure.lang.RestFn/invoke
    interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn
    main.clj: 437 clojure.main/repl/read-eval-print/fn
    main.clj: 437 clojure.main/repl/read-eval-print
    main.clj: 458 clojure.main/repl/fn
    main.clj: 458 clojure.main/repl
    main.clj: 368 clojure.main/repl
    RestFn.java: 1523 clojure.lang.RestFn/invoke
    interruptible_eval.clj: 84 nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj: 152 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
    AFn.java: 22 clojure.lang.AFn/run
    session.clj: 218 nrepl.middleware.session/session-exec/main-loop/fn
    session.clj: 217 nrepl.middleware.session/session-exec/main-loop
    AFn.java: 22 clojure.lang.AFn/run
    Thread.java: 833 java.lang.Thread/run

  2. Caused by java.lang.RuntimeException
    Invalid token: ::music/id

I’m on Clojure 1.10.3 (java version “13.0.1” 2019-10-15, macOS Monterey, but I don’t think those should matter).

Marked As Solved

alexmiller

alexmiller

Author of Programming Clojure, Third Edition

I think this is a bug in the book in that the music alias is not defined before it’s used as a qualifier. To do so, you either need to define a namespace music that is loadable or, more commonly alias music to some longer namespace (which is also loadable):

(create-ns 'domain.music)
(alias 'music 'domain.music)

In Clojure 1.11, the new :as-alias clause in require allows you to do this without loading any namespace:

(require '[music :as-alias music])

Where Next?

Popular Pragmatic Bookshelf topics Top

johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
New
gilesdotcodes
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions: In Gemfile, change gem 'rails' t...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
brunogirin
When running tox for the first time, I got the following error: ERROR: InterpreterNotFound: python3.10 I realised that I was running ...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New

Other popular topics Top

AstonJ
Or looking forward to? :nerd_face:
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
hilfordjames
There appears to have been an update that has changed the terminology for what has previously been known as the Taskbar Overflow - this h...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New

Sub Categories: