IntersectMBO / plutus-apps

The Plutus application platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PAB-Nami Demo Frontend includes bad spago command

MitchTurner opened this issue · comments

Summary

While following the PAB-Nami simple demo I can get as far as the frontend. However when trying to start the server, the npm start command runs a spago command:

    "build:spago": "spago build --purs-args \"--strict --censor-lib --stash --is-lib=.spago\"",

which gives the error:

> spago build --purs-args "--strict --censor-lib --stash --is-lib=.spago"

Invalid option `--strict'

Usage: purs COMMAND
  The PureScript compiler and tools
[error] Failed to build.

On investigation, the --purs-args is used to include "Arguments to pass to purs compile. Wrap in quotes" (spago build -h).

So, looking at purs compile -h:

purs compile -h
Usage: purs compile [FILE] [-o|--output ARG] [-v|--verbose-errors] 
                    [-c|--comments] [-g|--codegen ARG] [-p|--no-prefix] 
                    [--json-errors]
  Compile PureScript source files

Available options:
  -h,--help                Show this help text
  FILE                     The input .purs file(s).
  -o,--output ARG          The output directory (default: "output")
  -v,--verbose-errors      Display verbose error messages
  -c,--comments            Include comments in the generated code
  -g,--codegen ARG         Specifies comma-separated codegen targets to include.
                           Accepted codegen targets are 'corefn', 'docs', 'js',
                           'sourcemaps'. The default target is 'js', but if this
                           option is used only the targets specified will be
                           used.
  -p,--no-prefix           Do not include comment header
  --json-errors            Print errors to stderr as JSON

it looks like, indeed, --strict --censor-lib --stash --is-lib=.spago are all invalid commands

Steps to reproduce the behavior

npm --version
8.5.4

purs --version
0.14.7

spago --version
0.20.7

Run npm start in plutus-pab-executables/demo/pab-nami/client

Actual Result

npm start

> pab-nami@0.0.1 start
> npm install && npm run install:spago && npm run build:spago && npm run build:webpack:dev

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@dcspark/milkomeda-constants@0.4.0',
npm WARN EBADENGINE   required: { node: '>=14.17.6', npm: '>=6.14.15' },
npm WARN EBADENGINE   current: { node: 'v14.17.4', npm: '8.5.4' }
npm WARN EBADENGINE }

up to date, audited 995 packages in 2s

78 packages are looking for funding
  run `npm fund` for details

14 vulnerabilities (9 moderate, 4 high, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

> pab-nami@0.0.1 install:spago
> spago install


> pab-nami@0.0.1 build:spago
> spago build --purs-args "--strict --censor-lib --stash --is-lib=.spago"

Invalid option `--strict'

Usage: purs COMMAND
  The PureScript compiler and tools
[error] Failed to build.

Expected Result

A running server 🤞

Describe the approach you would take to fix this

I tried removing the --purs-args wholesale, to see if it would run without those arguments being passed to purs.

This seemed to get further into the process, but failed later with ERROR in Error: Child compilation failed

I don't know it this is the correct path to go down, so I haven't tried more.

System info

Ubuntu
20.04.1

Does npm start need to run within a nix-shell? It appears like I don't get any errors if I run from nix-shell (although the UI also doesn't seem to show up in my browser still in the nix-shell case).

commented

Does npm start need to run within a nix-shell?

Yes it does. That way you get a correct (pinned) versions of all tools and dependencies.

Maybe try to erase node_modules and .spago directories and check the console output in browsers developer tools.

commented

I'm pretty sure that this issue is solved. I think there is room for improvement in the README though. It was just the nix-shell wasn't run in my second console instance. I'm still having trouble with the demo, but I don't have any reason to believe my troubles are related to this issue.

The docs do say at the beginning

The instructions were tested inside the plutus-apps's nix-shell.

And also in the PAB section makes reference to nix-shell.

But when it asks you to create another shell for the Frontend it doesn't say anything about doing it in nix-shell:

From another command line interface, run the following command to launch the frontend application:

More explicit instructions could be helpful for us, less familiar with established workflows. I can make a PR when I get some time if that is best (or someone else can). I'll wait until after I get the demo running first though.

Created PR for some minor edits/clarifcations here:
#362