Schmavery / reprocessing

ReasonML graphics library inspired by Processing
https://schmavery.github.io/reprocessing/
MIT License
682 stars 24 forks source link

Issue with `refmt` #96

Closed codekiln closed 6 years ago

codekiln commented 6 years ago

Locally, I'm running:

$ refmt --version
Reason 3.0.0 @ bee43b0

@bsansouci told me that the trailing commas were an issue in bsb-native#2.1.1 with Reason 3.0.0, so I upgraded bsb-native to 2.1.1. Unfortunately, I suspect that reprocessing itself depends on bsb-native, as I still get mysterious errors when compiling. For example, this reprocessing02 example produces:

$ yarn bn #  `"bn": "bsb -make-world -backend native",`
yarn run v1.5.1
warning package.json: No license field
$ bsb -make-world -backend native
ninja: no work to do.
[1/1] Building run_build_script
[1/1] Building run_build_script
Warning package Tsdl: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tsdl/lib/tsdl_new.o' as it's automatically linked by the build-script, you can safely remove it from that list.
[1/1] Building run_build_script
[1/1] Building run_build_script
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/tgls_new.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/glad.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/soil_wrapper.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/SOIL.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/image_DXT.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/stb_image_aug.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/image_helper.o' as it's automatically linked by the build-script, you can safely remove it from that list.
[1/1] Building run_build_script
[1/1] Building run_build_script
Warning package Reasongl: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Reasongl/lib/reasongl.o' as it's automatically linked by the build-script, you can safely remove it from that list.
ninja: no work to do.
ninja: Entering directory `/Users/pnore/dev/react/reasonml-playground/reprocessing02/lib/bs/native'
[2/3] Building src/index.mlast
FAILED: src/index.mlast
/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/bsc.exe -pp "/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/refmt.exe --print binary"   -ppx /Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/belt_bsppx.exe -bs-super-errors -w -30-40+6+7+27+32..39+44+45+101 -bs-D BSB_BACKEND="native" -nostdlib -I '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/ocaml' -no-alias-deps -color always -c -o src/index.mlast -bs-syntax-only -bs-simple-binary-ast -bs-binary-ast -impl /Users/pnore/dev/react/reasonml-playground/reprocessing02/src/index.re
File "/Users/pnore/dev/react/reasonml-playground/reprocessing02/src/index.re", line 85, characters 11-12:
Error: 904: <UNKNOWN SYNTAX ERROR>

  We've found a bug for you!
  /Users/pnore/dev/react/reasonml-playground/reprocessing02/src/index.re

  There's been an error running Reason's refmt parser on a file.
  This was the command:

  /Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/refmt.exe --print binary '/Users/pnore/dev/react/reasonml-playground/reprocessing02/src/index.re' > /var/folders/vd/_cgkbpk16sx746c9_0cf3r51dn9jy9/T/ocamlppe2f643

  Please file an issue on github.com/facebook/reason. Thanks!

ninja: error: rebuilding 'build.ninja': subcommand failed
error An unexpected error occurred: "Command failed.
Exit code: 2
Command: sh
Arguments: -c bsb -make-world -backend native
Directory: /Users/pnore/dev/react/reasonml-playground/reprocessing02
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/pnore/dev/react/reasonml-playground/reprocessing02/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This error is roughly the same as the one I was encountering earlier and posted to stack overflow about.

Any theories on what I should do to move forward? Is there a way to force reprocessing to use bsb-native@master?

Schmavery commented 6 years ago

Afaik bsb-native master should be on a pretty recent refmt. Note: bsb-native native master branch doesn't install properly on npm5/6 As usual, try deleting node modules and reinstalling, and make sure you're not using some globally installed stuff. If you still have problems I'd imagine it's because bsb-native is behind in refmt version or something but @bsansouci would know better in that case. I can't imagine any hard dependency on any version of bsb-native native from reprocessing master

bsansouci commented 6 years ago

Master has an almost-up-to-date version of refmt, but I'm still catching up and merging

codekiln commented 6 years ago

try deleting node modules and reinstalling

I've tried this a number of times:

pnore at pnore-mbp in ~DIR (master●)
$ cat package.json
{
  "name": "reprocessing-02",
  "scripts": {
    "start": "./lib/bs/bytecode/indexhot.byte",
    "start:native": "./lib/bs/native/index.native",
    "sn": "./lib/bs/native/index.native",
    "build": "bsb -make-world",
    "build:web": "bsb -make-world -backend js",
    "build:native": "bsb -make-world -backend native",
    "bn": "bsb -make-world -backend native",
    "clean": "bsb -clean-world"
  },
  "dependencies": {
    "Reprocessing": "schmavery/reprocessing"
  },
  "devDependencies": {
    "bs-platform": "bsansouci/bsb-native"
  }
}%

pnore at pnore-mbp in ~DIR (master●)
$ rm -rf node_modules

pnore at pnore-mbp in ~DIR (master●)
$ rm -rf yarn.lock

pnore at pnore-mbp in ~DIR (master●)
$ yarn
yarn install v1.5.1
warning package.json: No license field
info No lockfile found.
warning reprocessing-02: No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
success Saved lockfile.
✨  Done in 102.39s.

pnore at pnore-mbp in ~DIR (master●)
$ yarn bn
yarn run v1.5.1
warning package.json: No license field
$ bsb -make-world -backend native
[2/2] Building fake_src/sdl_index.mlast.d
[2/2] Building lib.cmxa
[4/4] Building run_build_script
[3/3] Building lib.cmxa
Warning package Tsdl: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tsdl/lib/tsdl_new.o' as it's automatically linked by the build-script, you can safely remove it from that list.
[4/4] Building run_build_script
[3/3] Building lib.cmxa
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/tgls_new.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/glad.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/soil_wrapper.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/SOIL.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/image_DXT.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/stb_image_aug.o' as it's automatically linked by the build-script, you can safely remove it from that list.
Warning package Tgls: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Tgls/lib/image_helper.o' as it's automatically linked by the build-script, you can safely remove it from that list.
[18/18] Building run_build_script
[8/10] Building src/native/reasongl_native.cmx

  Warning number 27
  /Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Reasongl/src/native/reasongl_native.re 132:17-25

  130 ┆  * osx will give us and one that has an API comparable to OpenGL ES 2
        .0 which is what WebGL uses.
  131 ┆  */
  132 ┆ let init = (~screen=?, ~argv as _) => {
  133 ┆   /* Screen is ignored for now, we always just create a new window. *
        /
  134 ┆   if (Sdl.Init.init(Sdl.Init.video lor Sdl.Init.audio) != 0) {

  unused variable screen.
[10/10] Building lib.cmxa
Warning package Reasongl: `static-libraries` doesn't need to have '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/Reasongl/lib/reasongl.o' as it's automatically linked by the build-script, you can safely remove it from that list.
[40/40] Building src/Reprocessing_Internal.mlast.d
[21/21] Building lib.cmxa
ninja: Entering directory `/Users/pnore/dev/react/reasonml-playground/reprocessing02/lib/bs/native'
[1/2] Building src/index.mlast
FAILED: src/index.mlast
/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/bsc.exe -pp "/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/refmt.exe --print binary"   -ppx /Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/belt_bsppx.exe -bs-super-errors -w -30-40+6+7+27+32..39+44+45+101 -bs-D BSB_BACKEND="native" -nostdlib -I '/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/ocaml' -no-alias-deps -color always -c -o src/index.mlast -bs-syntax-only -bs-simple-binary-ast -bs-binary-ast -impl /Users/pnore/dev/react/reasonml-playground/reprocessing02/src/index.re
File "/Users/pnore/dev/react/reasonml-playground/reprocessing02/src/index.re", line 85, characters 11-12:
Error: 904: <UNKNOWN SYNTAX ERROR>

  We've found a bug for you!
  /Users/pnore/dev/react/reasonml-playground/reprocessing02/src/index.re

  There's been an error running Reason's refmt parser on a file.
  This was the command:

/Users/pnore/dev/react/reasonml-playground/reprocessing02/node_modules/bs-platform/lib/refmt.exe --print binary '/Users/pnore/dev/react/reasonml-playground/reprocessing02/src/index.re' > /var/folders/vd/_cgkbpk16sx746c9_0cf3r51dn9jy9/T/ocamlppe02743

  Please file an issue on github.com/facebook/reason. Thanks!

ninja: error: rebuilding 'build.ninja': subcommand failed
error An unexpected error occurred: "Command failed.
Exit code: 2
Command: sh
Arguments: -c bsb -make-world -backend native
Directory: /Users/pnore/dev/react/reasonml-playground/reprocessing02
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/pnore/dev/react/reasonml-playground/reprocessing02/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

For reference, here's the error visually: image

The source is here - index.re.

It doesn't look like a syntax error to me; I can't figure this out. Any ideas?

make sure you're not using some globally installed stuff

From the paths in the above output, I do not believe I'm making use of the globally installed reason-cli refmt. Is there any other way that you know of that I could unknowingly be using globally installed stuff? I get the same result in VSCode with the reasonml plugin as I do using command line compilation.

Lyonsclay commented 6 years ago

I had this same error and then realized there was actually a syntax error in my code. The messaging was misleading, but once I fixed the error it compiled and built just fine.

bsansouci commented 6 years ago

Can you all try bsansouci/bsb-native#3.2.0? It doesn't fully work on windows yet, but works on linux and osx.

codekiln commented 6 years ago

@bsansouci thanks for your PR - after updating to the latest, I was still experiencing the issue. I commented out my code section by section until I identified that the problem was actually the fact I was using colons instead of = to provide parameters to Draw.subImage. Simple mistake to make; I just copied the documentation for Draw.subImage and didn't see the discrepancy:

image

Thanks for your help.

bsansouci commented 6 years ago

Yup! No problem.