racket-stories
racket-stories copied to clipboard
No instructions for how to set up / run locally
I am trying to set up racket-stories to run on my local machine, but it is not clear how to do that. What is the process exactly? This seems like a could potential addition to the README.
You are right, it ought to be in the readme.
In the terminal:
racket server.rkt
Or open "server.rkt" in DrRacket/emacs and run it.
I had indeed tried that, but I get an error:
The application raised an exception with the message:
file-or-directory-permissions: access failed
path: /home/alex/Code/Racket Web App Sec/racket-stories/app-racket-stories/../dbs/racket-stories-sqlite.db
system error: No such file or directory; errno=2
Stack trace:
handle-status* at:
line 466, column 0, in file /usr/share/racket/collects/db/private/sqlite3/connection.rkt
sqlite3-connect11 at:
line 10, column 0, in file /usr/share/racket/collects/db/private/sqlite3/main.rkt
<unknown procedure> at:
line 555, column 3, in file /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt
<unknown procedure> at:
line 375, column 33, in file /usr/share/racket/collects/racket/contract/private/arrow-higher-order.rkt
send-arg636 at:
line 331, column 25, in file /usr/share/racket/pkgs/db-lib/db/private/generic/connect-util.rkt
.../more-scheme.rkt:261:28 at:
<unknown location>
proc at:
line 38, column 19, in file /usr/share/racket/pkgs/db-lib/db/private/generic/connect-util.rkt
<unknown procedure> at:
line 23, column 7, in file /usr/share/racket/pkgs/db-lib/db/private/generic/connect-util.rkt
Is there something special I have to do for the sqlite stuff to work?
Screenshot of error:

I'm quite a newbie in Racket, so I apologize in advance if I'm missing something obvious.
Hi Alex,
This is a bug. The intention was if missing the database should be created automatically. Perhaps it is due to the folder not being there?
Does it work if you make this folder first?
mkdir /home/alex/Code/Racket Web App Sec/racket-stories/dbs
/Jens Axel
Den lør. 11. jan. 2020 kl. 20.12 skrev Alex Vazquez < [email protected]>:
I had indeed tried that, but I get an error:
The application raised an exception with the message:
file-or-directory-permissions: access failed path: /home/alex/Code/Racket Web App Sec/racket-stories/app-racket-stories/../dbs/racket-stories-sqlite.db system error: No such file or directory; errno=2
Stack trace:
handle-status* at: line 466, column 0, in file /usr/share/racket/collects/db/private/sqlite3/connection.rkt sqlite3-connect11 at: line 10, column 0, in file /usr/share/racket/collects/db/private/sqlite3/main.rkt
at: line 555, column 3, in file /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt at: line 375, column 33, in file /usr/share/racket/collects/racket/contract/private/arrow-higher-order.rkt send-arg636 at: line 331, column 25, in file /usr/share/racket/pkgs/db-lib/db/private/generic/connect-util.rkt .../more-scheme.rkt:261:28 at: proc at: line 38, column 19, in file /usr/share/racket/pkgs/db-lib/db/private/generic/connect-util.rkt at: line 23, column 7, in file /usr/share/racket/pkgs/db-lib/db/private/generic/connect-util.rkt Is there something special I have to do for the sqlite stuff to work?
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/soegaard/racket-stories/issues/9?email_source=notifications&email_token=AADQXROKHCDRUO3OSH4B6ZTQ5IKX3A5CNFSM4KFQMRK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIWI66Q#issuecomment-573345658, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQXRJ6DQRZ3MR7UHFL7GLQ5IKX3ANCNFSM4KFQMRKQ .
--
Jens Axel Søgaard
Hi Jens,
I created the directory and tried again. Now I get a new error (progress!):
The application raised an exception with the message:
prepare: no such table: entrys
error code: 1
Stack trace:
handle-status* at:
line 466, column 0, in file /usr/share/racket/collects/db/private/sqlite3/connection.rkt
<unknown procedure> at:
line 422, column 8, in file /usr/share/racket/collects/db/private/sqlite3/connection.rkt
prepare1* method in connection% at:
line 225, column 4, in file /usr/share/racket/collects/db/private/sqlite3/connection.rkt
<unknown procedure> at:
line 261, column 28, in file /usr/share/racket/collects/db/private/generic/../../../racket/private/more-scheme.rkt
<unknown procedure> at:
line 261, column 28, in file /usr/share/racket/collects/db/private/generic/../../../racket/private/more-scheme.rkt
<unknown procedure> at:
line 23, column 2, in file /home/alex/.racket/7.5/pkgs/deta-lib/private/query.rkt
<unknown procedure> at:
line 375, column 33, in file /usr/share/racket/collects/racket/contract/private/arrow-higher-order.rkt
compose-statement at:
line 90, column 0, in file /usr/share/racket/collects/db/private/generic/functions.rkt
<unknown procedure> at:
line 64, column 0, in file /usr/share/racket/pkgs/db-lib/db/private/generic/functions2.rkt
<unknown procedure> at:
line 555, column 3, in file /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt
unpack204 at:
line 255, column 0, in file /home/alex/.racket/7.5/pkgs/deta-lib/query.rkt
lookups at:
line 118, column 0, in file /home/alex/Code/Racket Web App Sec/racket-stories/app-racket-stories/model.rkt
do-home at:
line 253, column 0, in file /home/alex/Code/Racket Web App Sec/racket-stories/app-racket-stories/control.rkt
dispatch at:
line 145, column 0, in file /home/alex/Code/Racket Web App Sec/racket-stories/app-racket-stories/control.rkt
<unknown procedure> at:
line 375, column 33, in file /usr/share/racket/collects/racket/contract/private/arrow-higher-order.rkt
<unknown procedure> at:
line 375, column 33, in file /usr/share/racket/collects/racket/contract/private/arrow-higher-order.rkt
<unknown procedure> at:
line 63, column 2, in file /usr/share/racket/pkgs/web-server-lib/web-server/dispatchers/dispatch-servlets.rkt
select-handler/no-breaks at:
line 163, column 2, in file /usr/share/racket/collects/racket/private/more-scheme.rkt
<unknown procedure> at:
line 144, column 8, in file /usr/share/racket/pkgs/web-server-lib/web-server/private/dispatch-server-with-connect-unit.rkt

Hi Alex,
I cloned a new version of racket-stories to see what was wrong.
The database setup now creates the folder dbs if is is missing
and at the same time made a small change to create-tables.
To setup the database, open "model.rkt".
Run it.
Then enter (create-tables) in the repl.
Now the database is setup, and you can start the web server in the terminal.
Thanks!
So I can run the site now, but when I try to create a user, this happens:

It appears that the error is referencing the following function in model.rkt:
(define (create-user username password email)
(unless (good-username? username)
(raise (exn:fail:user:bad (bad-username-reason username)
(current-continuation-marks))))
Thanks for helping me with this by the way. I'm so close to having it working!
You are indeed very close.
I think the culprit is line 75 in "authentication.rkt". Try changing 64 to 32.
https://github.com/soegaard/racket-stories/blob/master/app-racket-stories/authentication.rkt#L74
The reason I didn't ran into this error is that pbkedf is the fallback algorithm. It's only used when argon2 isn't available.
/Jens Axel
Den lør. 11. jan. 2020 kl. 23.40 skrev Alex Vazquez < [email protected]>:
Thanks!
So I can run the site now, but when I try to create a user, this happens:
[image: UserCreateError] https://user-images.githubusercontent.com/44826516/72211436-d8798900-3490-11ea-8bd4-12e24f71132f.png
It appears that the error is referencing the following function in model.rkt:
(define (create-user username password email) (unless (good-username? username) (raise (exn:fail:user:bad (bad-username-reason username) (current-continuation-marks))))
Thanks for helping me with this by the way. I'm so close to having it working!
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/soegaard/racket-stories/issues/9?email_source=notifications&email_token=AADQXRIDBG5HJPEMTC5H4DDQ5JDEBA5CNFSM4KFQMRK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIWMVQY#issuecomment-573360835, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQXRMI4WUXMZ7FSROXXE3Q5JDEBANCNFSM4KFQMRKQ .
--
Jens Axel Søgaard
Maybe the keysize 64 is supported on some systems? I can't recall having problems on macOS with respect to this.
Den søn. 12. jan. 2020 kl. 00.11 skrev Jens Axel Søgaard < [email protected]>:
You are indeed very close.
I think the culprit is line 75 in "authentication.rkt". Try changing 64 to 32.
https://github.com/soegaard/racket-stories/blob/master/app-racket-stories/authentication.rkt#L74
The reason I didn't ran into this error is that pbkedf is the fallback algorithm. It's only used when argon2 isn't available.
/Jens Axel
Den lør. 11. jan. 2020 kl. 23.40 skrev Alex Vazquez < [email protected]>:
Thanks!
So I can run the site now, but when I try to create a user, this happens:
[image: UserCreateError] https://user-images.githubusercontent.com/44826516/72211436-d8798900-3490-11ea-8bd4-12e24f71132f.png
It appears that the error is referencing the following function in model.rkt:
(define (create-user username password email) (unless (good-username? username) (raise (exn:fail:user:bad (bad-username-reason username) (current-continuation-marks))))
Thanks for helping me with this by the way. I'm so close to having it working!
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/soegaard/racket-stories/issues/9?email_source=notifications&email_token=AADQXRIDBG5HJPEMTC5H4DDQ5JDEBA5CNFSM4KFQMRK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIWMVQY#issuecomment-573360835, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQXRMI4WUXMZ7FSROXXE3Q5JDEBANCNFSM4KFQMRKQ .
--
Jens Axel Søgaard
--
Jens Axel Søgaard
I'm on Ubuntu. I have no clue - perhaps there's a way for me to change the keysize to something my system supports. I'll look into it and get back.
Hi Alex,
Rereading your error message, I think, the problem is that 'key-size is not a legal as a parameter for pbkdf2. I have pushed a new version to github. When I tested this version using pbkdf2 it worked on macOS (haven't tested on Ubuntu, but it ought to work there too).
/Jens Axel
Den søn. 12. jan. 2020 kl. 01.11 skrev Alex Vazquez < [email protected]>:
I'm on Ubuntu. I have no clue - perhaps there's a way for me to change the keysize to something my system supports. I'll look into it and get back.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/soegaard/racket-stories/issues/9?email_source=notifications&email_token=AADQXRJW4W23PWHVE4KAL7DQ5JN3JA5CNFSM4KFQMRK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIWOCOQ#issuecomment-573366586, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQXRLFVOO3L4W6TESNXLDQ5JN3JANCNFSM4KFQMRKQ .
--
Jens Axel Søgaard
@seisvelas
Hi Alex, Did you succeed in getting it up and running? /Jens Axel
With a fresh checkout, I can't get it to run, the error is related to secret.rkt trying to decrypt a badly formed UTF-8 string:
No key in either environment or home. Using default.
. . secret.rkt:49:2: bytes->string/utf-8: string is not a well-formed UTF-8 encoding
string: #"\255\3\311\371\244M\376\213T\261\263\a/\2128B\30\32\305f\v]\346\201\233_.\347\323l[\377%\3!\341"
Also, the instructions are missing the fact that you need to install postmark-client.
The snippet around "secret.rkt:42:2" is:
; aes-decrypt : string -> string
(define (aes-decrypt crypto-text)
(bytes->string/utf-8
(aes-decrypt-bytes crypto-text)))
Here (aes-decrypt-bytes crypto-text) attempts to decrypt one of the encrypted keys in the code.
Since your machine doesn't know the correct key, the output of aes-decrypt-bytes is not the
original key. Given the original key the result will be byte string containing an utf-8 encoded string - and
the call to bytes->string/utf-8 will succeed.
I suggest replacing the original encrypted keys in "secret.rkt" with your keys.
Use aes-encrypt in the repl to produce som encrypted keys and copy-paste them
to replace keys in the code.
I'll need to add a note on postmark-client. It's used to send emails to people (for password reset).
Are there dependencies outside of the standard racket distribution?
winston@stargate ~/pro/racket-stories $ racket server.rkt
app-racket-stories/secret.rkt:27:9: collection not found
for module path: crypto
collection: "crypto"
in collection directories:
/home/winston/.local/share/racket/8.5/collects
/nix/store/ahq7vhfd3mlinkhdj5x8c88akplmyh8f-racket-8.5/share/racket/collects/
... [165 additional linked and package directories]
location...:
app-racket-stories/secret.rkt:27:9
Yes, you'll need to install crypto:
raco pkg install crypto
Was able to get it running after running raco pkg install --auto gregor crypto deta postmark-client urlang, now I just need to figure out keys :)