bmads_51

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:

  1. require it directly: (require '[mylib.ns1])
  2. load a namespace which itself requires mylib.ns1 (directly or indirectly).
  3. 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.

First Post!

Dmitri

Dmitri

Author of Web Development with Clojure

Yeah, using require would force the namespace to load. Simply doing in-ns will switch to the namespace, but won’t trigger for the functions there to be evaluated. I think you’re right that loading the namespace would be the way to go here to avoid the behavior.

Popular Pragmatic topics Top

mikecargal
Title: Hands-on Rust: question about get_component (page 295) (feel free to respond. “You dug you’re own hole… good luck”) I have somet...
New
Mmm
Hi, build fails on: bracket-lib = “~0.8.1” when running on Mac Mini M1 Rust version 1.5.0: Compiling winit v0.22.2 error[E0308]: mi...
New
JohnS
I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps. With: ruby-3.0.0 s...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
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
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
bjnord
Hello @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
New

Other popular topics Top

dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
New

Latest in PragProg

View all threads ❯