decrypto-org / blockchain-course

An interactive course on blockchain science and engineering
MIT License
14 stars 11 forks source link

api yarn start uncooperative #38

Closed OrfeasLitos closed 5 years ago

OrfeasLitos commented 5 years ago
api $ yarn start 
yarn run v1.13.0
$ nodemon --watch . --watch $(realpath node_modules/blockchain-course-db) --watch index.js
[nodemon] 1.17.5
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.* /home/orfeas/repositories/blockchain-course/db/**/* index.js
[nodemon] starting `node index.js`
sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators ../db/node_modules/sequelize/lib/sequelize.js:242:13
fs.js:119
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir '../../assignments'
    at Object.readdirSync (fs.js:806:3)
    at loadAssignments (/home/orfeas/repositories/blockchain-course/db/helpers.js:14:17)
    at Object.<anonymous> (/home/orfeas/repositories/blockchain-course/db/models/custom/assignment.js:11:1)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
    at Module.require (internal/modules/cjs/loader.js:705:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at mapJSFiles (/home/orfeas/repositories/blockchain-course/db/models/index.js:32:17)
    at Array.forEach (<anonymous>)
    at mapJSFiles (/home/orfeas/repositories/blockchain-course/db/helpers.js:10:6)
    at Object.<anonymous> (/home/orfeas/repositories/blockchain-course/db/models/index.js:31:1)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
    at Module.require (internal/modules/cjs/loader.js:705:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/home/orfeas/repositories/blockchain-course/db/db.js:4:16)
[nodemon] app crashed - waiting for file changes before starting...
OrfeasLitos commented 5 years ago

Tried playing around with ASSIGNMENT_FOLDER env var, to no avail.

dionyziz commented 5 years ago

You need to clone the assignments repo into that directory

On Sat, Mar 9, 2019, 22:11 Orfeas Stefanos Thyfronitis Litos < notifications@github.com> wrote:

Tried playing around with ASSIGNMENT_FOLDER env var, to no avail.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/decrypto-org/blockchain-course/issues/38#issuecomment-471217842, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhPPOmRH7kP1gjnj9v8Ytmz2GSXkV5-ks5vVBVwgaJpZM4bm4Q0 .

OrfeasLitos commented 5 years ago

It used to work before I pulled. There's already a bunch of assignments there.

I tried removing everything and copying over the entire assignments repo, I npm installed and updated in the root of the repo, in api and in app and got this when doing yarn start in api:

yarn start
yarn run v1.13.0
$ nodemon --watch . --watch $(realpath node_modules/blockchain-course-db) --watch index.js
[nodemon] 1.18.10
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.* /home/orfeas/repositories/blockchain-course/api/node_modules/blockchain-course-db index.js
[nodemon] starting `node index.js`
internal/modules/cjs/loader.js:651
    throw err;
    ^

Error: Cannot find module 'blockchain-course-db'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15)
    at Function.Module._load (internal/modules/cjs/loader.js:575:25)
    at Module.require (internal/modules/cjs/loader.js:705:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/home/orfeas/repositories/blockchain-course/api/controllers/AssignmentController.js:6:59)
    at Module._compile (internal/modules/cjs/loader.js:799:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
    at Module.load (internal/modules/cjs/loader.js:666:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
    at Function.Module._load (internal/modules/cjs/loader.js:598:3)
[nodemon] app crashed - waiting for file changes before starting...
dionyziz commented 5 years ago

Did you run yarn install within the updated assignments repo? A lot has changed...

On Sat, Mar 9, 2019, 22:45 Orfeas Stefanos Thyfronitis Litos < notifications@github.com> wrote:

It used to work before I pulled. There's already a bunch of assignments there.

I tried removing everything and copying over the entire assignments repo, I npm installed and updated in the root of the repo, in api and in app and got this when doing yarn start in api:

yarn start yarn run v1.13.0 $ nodemon --watch . --watch $(realpath node_modules/blockchain-course-db) --watch index.js [nodemon] 1.18.10 [nodemon] to restart at any time, enter rs [nodemon] watching: . /home/orfeas/repositories/blockchain-course/api/node_modules/blockchain-course-db index.js [nodemon] starting node index.js internal/modules/cjs/loader.js:651 throw err; ^

Error: Cannot find module 'blockchain-course-db' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:649:15) at Function.Module._load (internal/modules/cjs/loader.js:575:25) at Module.require (internal/modules/cjs/loader.js:705:19) at require (internal/modules/cjs/helpers.js:14:16) at Object. (/home/orfeas/repositories/blockchain-course/api/controllers/AssignmentController.js:6:59) at Module._compile (internal/modules/cjs/loader.js:799:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10) at Module.load (internal/modules/cjs/loader.js:666:32) at tryModuleLoad (internal/modules/cjs/loader.js:606:12) at Function.Module._load (internal/modules/cjs/loader.js:598:3) [nodemon] app crashed - waiting for file changes before starting...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/decrypto-org/blockchain-course/issues/38#issuecomment-471220438, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhPPOEvFqTEbHYUP2GVp_3hZAZGsqVnks5vVB2CgaJpZM4bm4Q0 .

OrfeasLitos commented 5 years ago

Ran yarn install everywhere (api, app, root, assignments repo). The same.

cnasikas commented 5 years ago

Did you pull the latest changes from assignment's repo ?

cnasikas commented 5 years ago

The Error: Cannot find module 'blockchain-course-db' indicates that you have to yarn link inside db folder and yarn link blockchain-course-db inside api and cli folder

OrfeasLitos commented 5 years ago

The issue is with the default db directory. The current directory for the relative path of db/models/custom/assignment.js, line 6 is taken to be the path from which the script was invoked. I.e. to make it work I had to go to db/assignments/dutch-auction and run node ../../../cli/cli.js.

OrfeasLitos commented 5 years ago

And the next problem was: Error: Judge folder has not been declared. Did you assign the JUDGE_FOLDER variable inside .env? A sensible default can help here.

OrfeasLitos commented 5 years ago

After playing around with the judge folder, I get

$ node ../../../cli/cli.js
sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators ../../node_modules/sequelize/lib/sequelize.js:242:13
[ 'LICENSE',
  'README.md',
  'assignment-helpers.js',
  'dutch-auction',
  'faucet',
  'judges.js',
  'merkle-tree',
  'node_modules',
  'package.json',
  'proof-of-work',
  'public-key',
  'reverse-sha',
  'simple-storage',
  'vickrey-auction',
  'winston.js',
  'yarn.lock' ]
cli.js <command>

Commands:
  cli.js generate <command>  Generate <aux>
  cli.js get <command>       Get an entity <assignment>
  cli.js judge <id>          Judge a solution for a specific assignment
  cli.js stats <command>     Get user stats <top|last|score>

Options:
  --version  Show version number                                  [boolean]
  --help     Show help                                            [boolean]

(node:5376) V8: /home/orfeas/repositories/blockchain-course/db/node_modules/solc/soljson.js:3 Invalid asm.js: Invalid member of stdlib
cnasikas commented 5 years ago

And the next problem was: Error: Judge folder has not been declared. Did you assign the JUDGE_FOLDER variable inside .env? A sensible default can help here.

This is an issue regarding assignments which is in another repository and outside the scope of this repository. Nevertheless, as we are the same authors, we can not predict in which folder you will put your JUDGE_FOLDER and so what default is sensible enough.

I think is better to think the structure as follows: There is the blockchain-course repository that contains the api, web app, db and cli. Given the structure that we have, anyone can make a module , compatible with our logic, that implements various assignments. How they will implement this module is their choice. In our case we made the assignments repository with a JUDGE_FOLDER variable as a mandatory variable that must be filled by the user.

OrfeasLitos commented 5 years ago

Do I have to understand the entire architecture? I just want to write exercises.

cnasikas commented 5 years ago

No you don't. That's why you have to declare only two variables (absolute path).

dionyziz commented 5 years ago

I agree with Orfeas that maybe we should have a reasonable default for the location of the exercises folder. If you want, you can change it. Otherwise you just clone in the predetermined location.

On Mon, Mar 11, 2019, 16:58 Christos Nasikas notifications@github.com wrote:

No you don't. That's why you have to declare only two variables.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/decrypto-org/blockchain-course/issues/38#issuecomment-471574124, or mute the thread https://github.com/notifications/unsubscribe-auth/AAhPPPDVDn-G8ryVvAckDEzU4U3nR93qks5vVm8RgaJpZM4bm4Q0 .

cnasikas commented 5 years ago

We have already a reasonable default.

dionyziz commented 5 years ago

Correction: I mean for the judge location. The judge location within the assignments folder should be assumed to live in the location in which it would end up if you just cloned the assignments dir into the prespecified location within the blockchain-course dir.

dionyziz commented 5 years ago

Why do we need an absolute path there by the way?

cnasikas commented 5 years ago

Why do we need an absolute path there by the way?

Will be fixed at #39

Correction: I mean for the judge location. The judge location within the assignments folder should be assumed to live in the location in which it would end up if you just cloned the assignments dir into the prespecified location within the blockchain-course dir.

If you remember we had exactly the structure you are describing. The judge folder were inside the assignments folder. We made this change because we want the assignments folder to be empty so you can git clone inside the folder. If you want a default location for the judge folder please open an issue or a PR in the assignments repository as this issue has nothing to do with this repository.

dionyziz commented 5 years ago

I do not suggest that we go back to the previous structure. The way things are now is how they should be -- the assignments folder should be empty. The difference is that the judge path in the assignments repo should have a reasonable default, assuming the assignments repo will be cloned in the correct location. I'll open an issue on that repo.

OrfeasLitos commented 5 years ago

I'm closing this as the initial question was solved. I'll open a separate issue for the paths.