
bmads_51
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 Prag Prog topics










Other popular topics









Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /java
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /slackware
- /c
- /julia
- /neovim
- /markdown