elm-live icon indicating copy to clipboard operation
elm-live copied to clipboard

build.js errorMsg does not exist

Open JesterXL opened this issue 6 years ago • 2 comments

Crazy edge case I know, but causes a null pointer. I'm setting up a new Mac and forgot to install Elm, lol... so that means elm-live is like "waaaat...".

Line 99 of build.js:

proc.on('error', function (error) {
    if (error.name === 'ENOENT') {
      reject(elmNotFound(model.elm))
    } else {
      // reject(errorMsg(model.elm, error, model.recover))
      console.log("error:", error)
      reject(new Error('boom'))
    }
  })

Apparently errorMsg doesn't actually exist in messages.js. Anyway, the error looks like this:

error: Error: spawn elm ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn elm',
  path: 'elm',
  spawnargs: [ 'make', '--report=json', 'src/Main.elm', '--output=src/elm.js' ]
}

There might be a way to parse that and go "Are you sure Elm is actually installed or in your $PATH?" or something like that. Also, not sure what errorMsg is supposed to do.

JesterXL avatar Sep 27 '19 19:09 JesterXL

It appears like there never actually was an errorMsg function in messages.js. The import appears in commit 8339d43 seemingly derived from the field of an object.

I experienced the crash from the attempted call to errorMsg when I got this error from mixing up my argument order (causing elm-live to attempt to use my source code as the elm binary):

Error: spawn src/Main.elm EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: 'EACCES',
  code: 'EACCES',
  syscall: 'spawn src/Main.elm',
  path: 'src/Main.elm',
  spawnargs: [ 'make', '--report=json', '--output=src/elm.js' ]
}

It also seems like the errno or code field on error should be checked instead of name (which in my case seems to have the value "Error") because your error definitely should have been caught by the true part of the if statement.

1000000000 avatar Oct 03 '19 20:10 1000000000

I ran into a similar problem trying to start elm-live (and elm) installed on local node_modules directory. I also agree that the errno or code field on error could be checked for "ENOENT" and "EACCES". I attempted to run ./node_modules/.bin/elm-live using WSL1 Bash on Windows.

Inspecting error object in proc.on('error') callback inside build.js:

Error: spawn elm ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  [stack]: 'Error: spawn elm ENOENT\n' +
    '    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)\n' +
    '    at onErrorNT (internal/child_process.js:456:16)\n' +
    '    at processTicksAndRejections (internal/process/task_queues.js:80:21)',
  [message]: 'spawn elm ENOENT',
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn elm',
  path: 'elm',
  spawnargs: [ 'make', '--report=json', [length]: 2 ]
}

JustForFun119 avatar Dec 04 '19 16:12 JustForFun119