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

Cannot run with locally-installed tools #45

Open
robyoder opened this issue Jan 26, 2022 · 2 comments · May be fixed by #47
Open

Cannot run with locally-installed tools #45

robyoder opened this issue Jan 26, 2022 · 2 comments · May be fixed by #47

Comments

@robyoder
Copy link

robyoder commented Jan 26, 2022

I've created a sample project to show the problem.

STR

  1. npm install
  2. ./node_modules/.bin/elm-coverage --elm-test ./node_modules/.bin/elm-test

Expected

It would work. This is the documented way to use non-global binaries.

Actual

[11:36:29.78] Instrumenting sources...
[11:36:29.83] Running tests...
node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: spawn ./node_modules/.bin/elm-test ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn ./node_modules/.bin/elm-test',
  path: './node_modules/.bin/elm-test',
  spawnargs: [
    '--compiler',
    '/Users/rob/Projects/elm-coverage-bug/node_modules/elm-coverage/bin/fake-elm',
    'tests/'
  ]
}

I also tried ./node_modules/.bin/elm-coverage --elm-test ./node_modules/.bin/elm-test -- --compiler ./node_modules/.bin/elm, but the only difference that made was tacking on a couple more arguments to spawnargs:

  spawnargs: [
    '--compiler',
    '/Users/rob/Projects/elm-coverage-bug/node_modules/elm-coverage/bin/fake-elm',
    'tests/',
    '--compiler',
    './node_modules/.bin/elm'
  ]

It looks like /Users/rob/Projects/elm-coverage-bug/node_modules/elm-coverage/bin/fake-elm is looking for a global elm install, but even if I npm i -g elm I get the same result for ./node_modules/.bin/elm-coverage --elm-test ./node_modules/.bin/elm-test:

[11:43:51.49] Instrumenting sources...
[11:43:51.54] Running tests...
node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: spawn ./node_modules/.bin/elm-test ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn ./node_modules/.bin/elm-test',
  path: './node_modules/.bin/elm-test',
  spawnargs: [
    '--compiler',
    '/Users/rob/Projects/elm-coverage-bug/node_modules/elm-coverage/bin/fake-elm',
    'tests/'
  ]
}

Looking closer, it appears as though relative paths are not resolved correctly. Providing an absolute path to elm-test works.

In any case, I don't want to globally install these things because I want the versions to be pinned in each of my projects.

Additional info

% npm --version
8.1.2
@robyoder
Copy link
Author

Looking closer, it appears as though relative paths are not resolved correctly. Providing an absolute path to elm-test works. Added this to the description, and I'm looking into a fix to allow local installs of both elm-test and elm.

@robyoder
Copy link
Author

robyoder commented Jan 27, 2022

I also found #20, where @zwilias recommends using npm-which to find the elm executable. Part of me wonders if we shouldn't have another argument --elm like we have --elm-test, but for my use case npm-which will work just fine.

@robyoder robyoder linked a pull request Jan 27, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant