Web Development with Clojure, Third Edition: guestbook.auth functions not invocable (P. 168)

Dmitri Sotnikov @dmitri and Scot Brown @svmbrown
I was trying to execute the following code on p. 168:
user> (in-ns 'guestbook.auth)
#namespace[guestbook.auth]
guestbook.auth> (create-user! “testuser” “testpass”)
1
guestbook.auth> (authenticate-user “testuser” “testpass”)
{:login “testuser”, :created_at #inst “2019-09-20T02:22:53.217-00:00”}
guestbook.auth> (authenticate-user “testuser” “wrongpass”)
but the functions in the guestbook.auth namespace were simply unavailable after I switched to that namespace. I was getting No such var error messages.
After a lot of searching, I stumbled upon this from https://clojure.org/guides/repl/navigating_namespaces
How to make sure a lib is loaded
To make sure that a lib with namespace mylib.ns1
has been loaded in the REPL, you can do any one of the following:
-
require
it directly:(require '[mylib.ns1])
- load a namespace which itself requires
mylib.ns1
(directly or indirectly). - evaluate manually all the code in the source file
mylib.ns1
So I believe this section in the book was too premature. I actually went on to type in the login route code further down on pp. 168-9. Since that login route code loads (a la #2 above) the guestbook.auth namespace, once you jack-in or lein repl you will be able to execute the functions in the guestbook.auth namespace. So I think if the code blocks are reversed, that would help solve this issue.
Popular Pragprog topics










Other popular topics










Latest in Pragprog
Latest (all)
Categories:
My Saved Portals
-
None saved yet
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /preact
- /flutter
- /c-plus-plus
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /vuejs
- /nim
- /emacs
- /nerves
- /elm