Why is every error message the same?

Hi,
I’m checking out ReScript, and I followed the installation steps. Everything has worked fine so far, except for one thing: every single error message I get is the same:

Fatal error: exception Invalid_argument("index out of bounds")

No matter what I try (unused variables, typos, incorrect syntax), the error is the same.
Why is this? How can I fix it?

1 Like

Hello. Do you have a repro? Editor, project template, code?

Editor: VSCode (and using the rescript-vscode plugin)

Project Template: GitHub - rescript-lang/rescript-project-template: Clone this repo to start your own project! (

code:

// Comment this line out to get a vague error:
let lst = list{ ..."a,b,c" }

let result = (x => x)(lst)

bsconfig.json:

{
  "name": "rescript-project-template",
  "version": "0.0.1",
  "sources": {
    "dir" : "src",
    "subdirs" : true
  },
  "package-specs": {
    "module": "es6",
    "in-source": true
  },
  "suffix": ".bs.js",
  "bs-dependencies": [
  ],
  "warnings": {
    "error" : "+101"
  }
}

P.S. I do sometimes see Warning number <n> in the error.
And I finally found the list of warning numbers: OCaml - Batch compilation (ocamlc)
This helps a lot, but it would still be better to have the errors in plain English rather than code number IMO.

Could you try rescript clean and rebuild? It’s weird that you’re getting this error

I did it, but still the same thing

terminal:

PS C:\Users\ronald\Desktop\rescript-project-template> npm run clean

> rescript-project-template@0.0.1 clean C:\Users\ronald\Desktop\rescript-project-template
> rescript clean -with-deps

Cleaning... 2 files.
PS C:\Users\ronald\Desktop\rescript-project-template> npm run clean2

> rescript-project-template@0.0.1 clean2 C:\Users\ronald\Desktop\rescript-project-template
> rescript clean

PS C:\Users\ronald\Desktop\rescript-project-template> npm run build 

> rescript-project-template@0.0.1 build C:\Users\ronald\Desktop\rescript-project-template
> rescript

rescript: [3/3] src/Main.cmj
FAILED: src/Main.cmj

  Warning number 26
  C:\Users\ronald\Desktop\rescript-project-template\src\Main.res:99:7
Fatal error: exception Invalid_argument("index out of bounds")
FAILED: cannot make progress due to previous errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! rescript-project-template@0.0.1 build: `rescript`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the rescript-project-template@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ronald\AppData\Roaming\npm-cache\_logs\2021-05-20T09_29_45_947Z-debug.log

debug log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build'
1 verbose cli ]
2 info using npm@6.14.11
3 info using node@v14.16.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle rescript-project-template@0.0.1~prebuild: rescript-project-template@0.0.1
6 info lifecycle rescript-project-template@0.0.1~build: rescript-project-template@0.0.1
7 verbose lifecycle rescript-project-template@0.0.1~build: unsafe-perm in lifecycle true
8 verbose lifecycle rescript-project-template@0.0.1~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\ronald\Desktop\rescript-project-template\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Haskell\bin;C:\Program Files\Haskell Platform\8.6.3\lib\extralibs\bin;C:\Program Files\Haskell Platform\8.6.3\bin;C:\Program Files\Haskell Platform\8.6.3\mingw\bin;C:\Program Files\PuTTY\;C:\Program Files (x86)\ChucK\/bin;C:\Program Files\Git\bin\;C:\Program Files\Git\cmd\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Microsoft VS Code\bin;C:\Program Files (x86)\GTK2-Runtime\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Elm\0.19.1\bin;C:\Users\ronald\AppData\Roaming\cabal\bin;C:\Users\ronald\AppData\Roaming\local\bin;C:\Program Files\nodejs;C:\Users\ronald\AppData\Local\now-cli;C:\Users\ronald\AppData\Local\Microsoft\WindowsApps;C:\Gradle\gradle-6.6.1\bin;C:\Program Files\Java\jdk-11.0.8\bin\bin;C:\Users\ronald\AppData\Roaming\npm
9 verbose lifecycle rescript-project-template@0.0.1~build: CWD: C:\Users\ronald\Desktop\rescript-project-template
10 silly lifecycle rescript-project-template@0.0.1~build: Args: [ '/d /s /c', 'rescript' ]
11 silly lifecycle rescript-project-template@0.0.1~build: Returned: code: 2  signal: null
12 info lifecycle rescript-project-template@0.0.1~build: Failed to exec build script
13 verbose stack Error: rescript-project-template@0.0.1 build: `rescript`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid rescript-project-template@0.0.1
15 verbose cwd C:\Users\ronald\Desktop\rescript-project-template
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v14.16.0
19 verbose npm  v6.14.11
20 error code ELIFECYCLE
21 error errno 2
22 error rescript-project-template@0.0.1 build: `rescript`
22 error Exit status 2
23 error Failed at the rescript-project-template@0.0.1 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

Let me know if you need any other info

@chenglou I believe this problem happens on windows. Happened to my friend too (on windows) but i couldn’t reproduce this on my machines (windows/linux)

can you just run npx rescript, what’s the output?
I could not reproduce your case on windows

output: rescript: [6/6] src/Main.cmj

so it just works, seems to be an editor error.

Fatal error: exception Invalid_argument("index out of bounds")

The error message suggests it is a native exception. cc @cristianoc

@JomoPipi it is a bit weird, is not npm run build exactly the same as npx rescript? what’s the output of running npm run build from terminal?

@Hongbo In case the source code has no errors compiler compiles successfully. Seems like it raises when it wants to print error messages. something like that.

Ah, sorry. I edited my code between then and when I ran npx rescript. But I ran it on my mac and I see much more helpful error messages now

Something weird here on Windows, now: My editor is giving the error even though I’m seeing Finish compiling in the terminal.

Can you disable the plugin first and see if you can reproduce it by tweaking the code and see if there is warnings?

I disabled the plugin and restarted my editor:
image

@JomoPipi Can you try this and show the output?

in cmd before running your build command, enter this command SET OCAMLRUNPARAM=b and hit enter, then run your build command.

image

I think set is not working on powerhsell try that on cmd if possible.