joy-framework / joy

A full stack web framework written in janet
https://joy.swlkr.com
MIT License
535 stars 30 forks source link

Getting Started: joy create route account error: bad slot #0, expected core/file, got nil #66

Closed jcreager closed 4 years ago

jcreager commented 4 years ago

When following the get started tutorial I run into the following issue.

Steps to reproduce:

joy new my-joy-project
cd my-joy-project

This is what is inside the new project folder after generating the project.

ls -l
total 72
-rw-r--r--  1 user  group     39 Jul 18 18:13 Procfile
-rw-r--r--  1 user  group    830 Jul 18 18:13 app.janet
drwxr-xr-x  4 user  group    128 Jul 18 18:14 db
-rw-r--r--  1 user  group  20480 Jul 18 18:14 development.sqlite3
-rw-r--r--  1 user  group    329 Jul 18 18:13 project.janet
drwxr-xr-x  4 user  group    128 Jul 18 18:13 public
-rwxr-xr-x  1 user  group     74 Jul 18 18:13 watch
joy create db
joy create table account 'email text not null unique' 'password text not null'
joy migrate
Migrating [20200719011400-create-table-account.sql]...
create table account (
  id integer primary key,
  email text not null unique,
  password text not null,
  created_at integer not null default(strftime('%s', 'now')),
  updated_at integer
)

Successfully migrated [20200719011400-create-table-account.sql]
joy create route account
error: bad slot #0, expected core/file, got nil
  in file/close
  in new-routes-text [/usr/local/lib/janet/joy/cli/routes.janet] on line 90, column 3
  in create [/usr/local/lib/janet/joy/cli/routes.janet] (tailcall) on line 105, column 25

Version:

joy version
0.8.0

janet
Janet 1.10.0-meson

I have tested these commands with Linux Alpine and Mac Os and get the same results. It looks like part of the issue is that the src file and src/rotues.janet file have not been auto generated.

Creating this directory and file leads to new issues.

joy create route account
error: bad slot #0, expected string|symbol|keyword|buffer, got nil
  in string/trimr
  in <anonymous> [/usr/local/lib/janet/joy/cli/routes.janet] on line 97, column 40
  in new-routes-text [/usr/local/lib/janet/joy/cli/routes.janet] on line 90, column 3
  in create [/usr/local/lib/janet/joy/cli/routes.janet] (tailcall) on line 105, column 25

Any thoughts on what the issue might be?

jcreager commented 4 years ago

Just to follow up, I was able to get things working eventually. It looks like the issue is that the command joy new my-joy-project does not set up a project the way the command joy create route account expects. Mainly, the src/routes.janet file is not created and the directory src/routes does not exist. Creating these and adding a defroutes to src/routes.janet fixed the error I reported above and I was successfully able to run joy create route account. I'm guess something changed in the joy new command at some point.

Awesome project by the way.