Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No instructions for how to set up / run locally #9

Open
seisvelas opened this issue Jan 11, 2020 · 16 comments
Open

No instructions for how to set up / run locally #9

seisvelas opened this issue Jan 11, 2020 · 16 comments

Comments

@seisvelas
Copy link
Contributor

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.

@soegaard
Copy link
Owner

soegaard commented Jan 11, 2020

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.

@soegaard soegaard reopened this Jan 11, 2020
@seisvelas
Copy link
Contributor Author

seisvelas commented Jan 11, 2020

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:

RacketError

I'm quite a newbie in Racket, so I apologize in advance if I'm missing something obvious.

@soegaard
Copy link
Owner

soegaard commented Jan 11, 2020 via email

@seisvelas
Copy link
Contributor Author

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

New Error

@soegaard
Copy link
Owner

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.

@seisvelas
Copy link
Contributor Author

Thanks!

So I can run the site now, but when I try to create a user, this happens:

UserCreateError

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!

@soegaard
Copy link
Owner

soegaard commented Jan 11, 2020 via email

@soegaard
Copy link
Owner

soegaard commented Jan 11, 2020 via email

@seisvelas
Copy link
Contributor Author

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.

@soegaard
Copy link
Owner

soegaard commented Jan 12, 2020 via email

@soegaard
Copy link
Owner

@seisvelas

Hi Alex,
Did you succeed in getting it up and running?
/Jens Axel

@soapdog
Copy link

soapdog commented Mar 4, 2020

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.

@soegaard
Copy link
Owner

soegaard commented Mar 4, 2020

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).

@winny-
Copy link

winny- commented Jun 8, 2022

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

winny- added a commit to winny-/racket-stories that referenced this issue Jun 8, 2022
Did not test, was unable to run locally (left a comment in soegaard#9).
@soegaard
Copy link
Owner

soegaard commented Jun 8, 2022

Yes, you'll need to install crypto:

raco pkg install crypto

@winny-
Copy link

winny- commented Jun 8, 2022

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants