Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.
This repository was archived by the owner on May 1, 2020. It is now read-only.

Error: spawn psc ENOENT #30

Closed
Closed

Description

@JohnGurin
$ gulp
[12:05:33] Using gulpfile ~\Documents\Purescript\gulpfile.js
[12:05:33] Starting 'purescript'...
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn psc ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1046:32)
    at child_process.js:1137:20
    at process._tickCallback (node.js:355:11)
//gulpfile.js
var gulp = require('gulp');
var purescript = require('gulp-purescript');

gulp.task('purescript', function(){
  return gulp.src('src/**/*.purs').
         pipe(purescript.psc({main:"Chapter2"})). //<-- if this line is commented the script works
         pipe(gulp.dest('build'));
});
gulp.task('default', ['purescript']);
-- Chapter2.purs
module Chapter2 where
import Debug.Trace
main = trace "Hello"
$ node -v
v0.12.1

$ npm -v
2.5.1

$ gulp -v
[12:05:49] CLI version 3.8.11
[12:05:49] Local version 3.8.11
#local node_modules
gulp\
gulp-dest\
gulp-purescript\
gulp-util\
logalot\
minimist\
multipipe\
resolve-bin\
through2\
which\
#this works
john@HOME-PC ~/Documents/Purescript
$ psc src/Chapter2.purs --output dist/Main.js --main=Chapter2 --module=Chapter2

Windows 8.1 x64

Activity

  1. self-assigned this
    on May 11, 2015
  2. ethul commented on May 11, 2015

    @ethul
    Contributor

    Thanks for the report. I haven't tried the library with node 0.12.x. I will take a look.

  3. garyb commented on May 11, 2015

    @garyb
    Member

    I'm using node 0.12.2 so I'm not necessarily sure it's related to that.

    @JohnGurin what do you get for where psc?

  4. JohnGurin commented on May 11, 2015

    @JohnGurin
    Author

    @garyb

    john@HOME-PC ~/Documents/Purescript
    $ where psc
    c:\Users\john\AppData\Roaming\npm\psc
    c:\Users\john\AppData\Roaming\npm\psc.cmd
  5. JohnGurin commented on May 20, 2015

    @JohnGurin
    Author

    So, I think I found the problem. http://stackoverflow.com/a/17537559
    Made the gulp-purescript work by adding

    // node_modules\gulp-purescript\index.js line:2196
    function spawnFn(command, args, errback, callback) {
          command = command + ".cmd";  //<-- added this line
          return function(){
            var child_process = __webpack_require__(35);
            var process = child_process.spawn(command, args);
    ...

    Now the gulp compiles *.purs to psc.js ignoring options

  6. ethul commented on May 24, 2015

    @ethul
    Contributor

    @JohnGurin thanks for digging into this.

    I wonder if we are running into nodejs/node-v0.x-archive#2318

    From that thread, it looks like one solution is to drop-in the following replacement for spawn.
    https://github.com/IndigoUnited/node-cross-spawn

    Would you possibly be able to try this module locally to see if it solves the problem (without adding the .cmd extension)? Sorry that I can't give this a go myself. I don't have access to windows at all.

    Not sure if this is the best way to go, but might be worth a try.

  7. JohnGurin commented on May 27, 2015

    @JohnGurin
    Author
    // node_modules\gulp-purescript\index.js line:2196
    function spawnFn(command, args, errback, callback) {
          command = command + ".cmd";  //<-- added this line
          return function(){
            //var child_process = __webpack_require__(35);
            //var process = child_process.spawn(command, args);
               console.log(command);
            var process = require('cross-spawn')(command, args); //<-- added this line
    ...

    results in the same as in previous attempt: gulp works but purescript.psc(options) options is not respected.

  8. ethul commented on May 27, 2015

    @ethul
    Contributor

    Thanks for giving this a try @JohnGurin

    Did you happen to try it without adding the .cmd to command? I.e., removing:

    command = command + ".cmd";  //<-- added this line

    So it would be

    // node_modules\gulp-purescript\index.js line:2196
    function spawnFn(command, args, errback, callback) {
          return function(){
            //var child_process = __webpack_require__(35);
            //var process = child_process.spawn(command, args);
            var process = require('cross-spawn')(command, args); //<-- added this line
    ...

    If this does not work as well, what are the options passed to psc? Can you please provide the values of command and args?

    Thanks for all of this!

  9. JohnGurin commented on May 27, 2015

    @JohnGurin
    Author
    gulp.task('purescript', function(){
      return gulp.src('src/**/*.purs').
             pipe(purescript.psc({noPrelude:true,main:'Chapter2',module:'Chapter2'})).
             pipe(gulp.dest('build'));
    });

    Sorry, I tested without command = command + ".cmd";, copy pasted it from previous message and missed the line.
    console.log(command) prints psc

  10. ethul commented on May 27, 2015

    @ethul
    Contributor

    Ah, no worries. Thanks for the info. Just for good measure, would you mind console.log-ing the command and args variables and providing the output? I.e., the precise values passed to cross-spawn.

    Thanks!

  11. JohnGurin commented on May 27, 2015

    @JohnGurin
    Author
    function spawnFn(command, args, errback, callback) {
         return function(){
            //var child_process = __webpack_require__(35);
            //var process = child_process.spawn(command, args);
            console.log(command);
            console.log(args);
            var process = require('cross-spawn')(command, args);
    ...
    john@HOME-PC ~/Documents/Purescript
    $ gulp purescript
    [19:03:52] Using gulpfile ~\Documents\Purescript\gulpfile.js
    [19:03:52] Starting 'purescript'...
    psc
    [ 'C:\\Users\\john\\Documents\\Purescript\\src\\Chapter2.purs' ]
    [19:03:52] Finished 'purescript' after 407 ms
  12. ethul commented on May 27, 2015

    @ethul
    Contributor

    Interesting. The value of args looks to be missing your options passed to psc in the gulpfile.

    Perhaps cross-spawn is working properly, but somewhere outside of spawnFn the options are getting lost. I will look into this further, but if you have a chance to trace back the args value a bit to see where they might be getting lost, it would be a great help!

  13. JohnGurin commented on May 27, 2015

    @JohnGurin
    Author
    // node_modules\gulp-purescript\index.js line:191
    var psc = function (opts) {
            console.log(opts); //<--
                var run = function (i) {
                var _1330 = GulpPurescript_Options.pscOptionsNoOutput(opts);
            console.log(_1330); //<--
                return Prelude["<$>"]/*...*/(_1330.value0)))(/*...*/)(_1330.value1)));
            };
            return Prelude["<*>"]/*...*/(run));
        };
    john@HOME-PC ~/Documents/Purescript
    $ gulp purescript
    [19:33:57] Using gulpfile ~\Documents\Purescript\gulpfile.js
    [19:33:57] Starting 'purescript'...
    { noPrelude: true, main: 'Chapter2', module: 'Chapter2' }
    { value0: {}, value1: [] }
    [19:33:57] Finished 'purescript' after 424 ms

    btw, what is the right way to traceback nodejs?

  14. ethul commented on May 27, 2015

    @ethul
    Contributor

    Thanks!

    What version of gulp-purescript are you on? Can you please try this with 0.4.2?

    There was a previous fix (#24) for parsing the psc main option. Maybe an update will solve the options issue. If so, I can migrate to using cross-spawn.

    And the way you traced is how I would have done it. Not sure if there is a better way.

  15. 3 remaining items

  16. JohnGurin commented on May 27, 2015

    @JohnGurin
    Author
    john@HOME-PC ~/Documents/Purescript
    $ gulp purescript
    [23:02:39] Using gulpfile ~\Documents\Purescript\gulpfile.js
    [23:02:39] Starting 'purescript'...
    { noPrelude: true, main: 'Chapter2', module: [ 'Chapter2' ] }
    { value0: {},
      value1: [ '--no-prelude', '--main=Chapter2', '--module=Chapter2' ] }
    events.js:85
          throw er; // Unhandled 'error' event
                ^
    Error: Error in module Chapter2:
    Error at C:\Users\john\Documents\Purescript\src\Chapter2.purs line 3, column 1 - line 5, column 1:
      Unknown module Debug.Trace
    See https://github.com/purescript/purescript/wiki/Error-Code-UnknownModule for more information, or to contribute conten
    t related to this error.
    ...

    Oops. noPrelude:true is the cause.
    Everything works purescript.psc({main:"Chapter2",module:["Chapter2"]})

  17. ethul commented on May 27, 2015

    @ethul
    Contributor

    @JohnGurin Just to confirm, having noPrelude:true was causing the ENOENT error?

    Glad it works now by the way!

  18. JohnGurin commented on May 27, 2015

    @JohnGurin
    Author

    No, only

    Error: Error in module Chapter2:
    Error at C:\Users\john\Documents\Purescript\src\Chapter2.purs line 3, column 1 - line 5, column 1:
      Unknown module Debug.Trace

    Switching to non-cross-spawn brings ENOENT back. So ENOENT issue is resolved.

  19. ethul commented on May 28, 2015

    @ethul
    Contributor

    To clarify, when cross-spawn is not being used (i.e., vanilla gulp-purescript @ 0.4.2), do you still get the ENOENT error? Given that you are using the options:

    purescript.psc({main:"Chapter2",module:["Chapter2"]})

    Thanks!

  20. JohnGurin commented on May 28, 2015

    @JohnGurin
    Author

    Yes

  21. ethul commented on May 28, 2015

    @ethul
    Contributor

    Thanks. I will reopen the issue and add cross-spawn.

  22. reopened this on May 28, 2015
  23. added a commit that references this issue on May 29, 2015
    16f0539
  24. added a commit that references this issue on May 29, 2015
    dee1515
  25. ethul commented on May 29, 2015

    @ethul
    Contributor

    Released in version 0.4.3. Please let me know if it works for you.

    Thanks!

  26. JohnGurin commented on May 29, 2015

    @JohnGurin
    Author

    👍

  27. doivosevic commented on Dec 2, 2015

    @doivosevic

    I have just tried installing purescript-angular from scratch and after following the steps I got the same error as mentioned at the beginning of this article. I have Node 4.2.1 and npm 2.14.7 . I have tried changing

    "gulp-purescript": "0.1.2",
    

    to

    "gulp-purescript": "*",
    

    but then i got

    [14:55:01] Warning: gulp version mismatch:
    [14:55:01] Global gulp is 3.9.0
    [14:55:01] Local gulp is 3.8.10
    [14:55:02] Using gulpfile ~\Desktop\purescript-angular\gulpfile.js
    [14:55:02] Starting 'clean'...
    [14:55:02] Finished 'clean' after 25 ms
    [14:55:02] Starting 'todomvc'...
    [14:55:02] 'todomvc' errored after 11 ms
    [14:55:02] Error in plugin 'gulp-purescript'
    Message:
        Type mismatch: expected array, found Undefined
    
  28. ethul commented on Dec 2, 2015

    @ethul
    Contributor

    @DominikDitoIvosevic would you be able to verify the version of gulp-purescript you have installed? Also, have you tried to match your local gulp with your global gulp version?

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions