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

PureScript build usually fails when spago is used #171

Open
shamansir opened this issue Feb 4, 2021 · 11 comments
Open

PureScript build usually fails when spago is used #171

shamansir opened this issue Feb 4, 2021 · 11 comments

Comments

@shamansir
Copy link

Version: 0.23.3
spago version: 0.19.0
purs version: 0.13.8

Could be spago issue, but may be you have a suggestion on what to change in my build command.

I used this command as build command:

/opt/local/bin/spago build --purs-args --json-errors > /dev/null

And every next build I get the error: Problem running build: didn't find JSON output. Sometimes (rarely) it works, and the errors are fine, but usually not.

Before, there was a --quiet flag, but now it's gone from spago in favour of > dev/null.

Could be that spago (purs?) still adds the [error] Failed to build. to the JSON output with errors.

@shamansir
Copy link
Author

shamansir commented Feb 4, 2021

Oh, I see, could be related to #159

But the output from PureScript IDE is different:

Running build command: /opt/local/bin/spago build --purs-args --json-errors [object Object] /dev/null
[Info  - 1:38:57 PM] Invalid argument `[object Object]'

So, seems, > symbol is replaced with the [object Object] somehow.

The problem is that spago's output is full of Compiling package ... lines even with --json-errors flag on, when used without > /dev/null or, previously, --quiet, so the build also fails.

@nwolverson
Copy link
Owner

The build command is not run under a shell, you should remove the > /dev/null.

The spago output should just be fine as it is, so long as JSON errors are printed to stderr - junk lines should be ignored. There is some change incoming with purescript 0.14 around printing JSON errors to stdout, but unless this is involved in current spago behaviour I guess that's not relevant

@nwolverson
Copy link
Owner

Did that (removing the redirect) help? It should be that simply including the "junk" in the output and relying on the extension to sort it out is fine - certainly I'm happily building with spago in that case.

@shamansir
Copy link
Author

shamansir commented Mar 2, 2021

Without > /dev/null It fails with a dialog box (or passes, when should not (there are errors in the code), but still shows the dialog box):

[Info  - 23:07:47] Running build command: /opt/local/bin/spago build --purs-args --json-errors
[Info  - 23:07:51] Compiling Noodle.Render.Html.DebugBox
Compiling Noodle.Render.Component.Patch.Layout
Compiling Noodle.API.Action.Apply

[Error - 23:07:51] Couldn't parse build output: Unexpected token � in JSON at position 8192
Built with 0/0 issues for file: "/Users/shamansir/Workspace/noodle/src/Noodle/Render/Component/Patch/Layout.purs", all diagnostic files: []

Captura de Pantalla 2021-03-02 a la(s) 23 08 34

@nwolverson
Copy link
Owner

That 8192 is suspicious, I assume something is going wrong parsing large JSON output.

@shamansir
Copy link
Author

shamansir commented Mar 3, 2021

I've fixed some issues in the code, but the position doesn't change:

[Info  - 08:27:33] Resolved build command (1st is used): 
[Info  - 08:27:33] /opt/local/bin/spago: 0.19.0

[Info  - 08:27:33] Running build command: /opt/local/bin/spago build --purs-args --json-errors
[Info  - 08:27:40] Compiling Noodle.API.Action.Sequence
Compiling Noodle.Render.Component.Patch.Layout
Compiling Noodle.Render.Html.DebugBox
Compiling Noodle.Render.Renderer
Compiling Noodle.Test.Spec.Flow.Base
Compiling Noodle.Test.Spec.Actions
Compiling Noodle.Test.Spec.Structure
Compiling Noodle.Render.String
Compiling Noodle.Test.Util.Trace
Compiling Noodle.Render.Terminal
Compiling Noodle.Render.Html.VDom
Compiling Noodle.Test.Spec.Flow.Subscriptions
Compiling Noodle.Test.Spec.Flow.Subpatches
Compiling Noodle.Test.Spec.Flow.Network
Compiling Noodle.Test.Spec.Flow.Inlets
Compiling Noodle.Test.Spec.Flow.Nodes
Compiling Noodle.Test.Spec.Flow.Links
Compiling Noodle.Test.Spec.Flow

[Error - 08:27:40] Couldn't parse build output: Unexpected token � in JSON at position 8192

The output of /opt/local/bin/spago build --purs-args --json-errors > ./tmp.errors 2>&1 is here (notice I intentionally didn't format it and it's just a very long line of JSON, so that formatting wouldn't change positions): https://gist.github.com/shamansir/c77bcbb2d202afd4733f4290c628a0f3

Raw version

However I noticed that spago has been updated to 0.19.1, the version I use is 0.19.0.

@shamansir
Copy link
Author

In the JSON string, it seems to be nothing suspicious at the position 8192 (see the cursor), but a bit earlier in the code there are operators imports, could that be that some operator has unsupported symbol idk?

Captura de Pantalla 2021-03-03 a la(s) 9 26 53

@nwolverson
Copy link
Owner

Thanks for the JSON upload, I'll try to repro later. As I say 8192 is a suspicious number (being a power of 2) so likely not actually a character in the JSON. This extension (rather the LS) did at one time have an issue with larger error reports, but I'm surprised this is cropping up as I did think that was fixed

@natefaubion
Copy link

This is a node thing where it doesn't always flush or receive stdout before the process closes. I've experienced this when combining spago and psa with the ide server. I'm not totally sure where the culprit lies as I never have this problem when using only psa and vscode, or only spago and vscode.

@shamansir
Copy link
Author

shamansir commented Mar 6, 2021

Seems outputting errors have changed in PureScript 14.0, could be related and I'll try it later:

Compiler errors and warnings arising from your code are now printed to stdout rather than stderr, and progress messages such as "Compiling Data.Array" are now printed to stderr rather than stdout. Warnings and errors arising from incorrect use of the CLI, such as specifying input files which don't exist or specifying globs which don't match any files, are still printed to stderr (as they were before). This change is useful when using the --json-errors flag, since you can now pipe JSON errors into other programs without having to perform awkward gymnastics such as 2>&1.

@nwolverson
Copy link
Owner

I saw this once and still can't reproduce it.

After a side-track where I was typing up a comment noting the json was truncated after my editor truncated it...

I can build just fine with those json errors as saved here, so I can only agree with nate that it seems likely there is some truncation with the way these things are composed.

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

No branches or pull requests

3 participants