Closed JohnGurin closed 9 years ago
Thanks for the report. I haven't tried the library with node 0.12.x. I will take a look.
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
?
@garyb
john@HOME-PC ~/Documents/Purescript
$ where psc
c:\Users\john\AppData\Roaming\npm\psc
c:\Users\john\AppData\Roaming\npm\psc.cmd
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
@JohnGurin thanks for digging into this.
I wonder if we are running into joyent/node#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.
// 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.
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!
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
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!
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
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!
// 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?
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.
// node_modules\gulp-purescript\package.json
...
"version": "0.4.2",
...
Thanks. Okay. There must still be an issue here. I will take a look. Thanks again for all of your help.
I noticed that the module
option should be an array of strings. Instead of
purescript.psc({noPrelude:true,main:'Chapter2',module:'Chapter2'})
it should be
purescript.psc({noPrelude:true,main:'Chapter2',module:['Chapter2']})
I think this may do the trick to solve the options problem. However, I am thinking the plugin should provide an error message when an option has the wrong type. I've opened a separate issue #31 for this.
If this works, I will use cross-spawn
to provide cross-platform command invocation.
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"]})
@JohnGurin Just to confirm, having noPrelude:true
was causing the ENOENT
error?
Glad it works now by the way!
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.
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!
Yes
Thanks. I will reopen the issue and add cross-spawn.
Released in version 0.4.3
. Please let me know if it works for you.
Thanks!
:+1:
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
@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?
Windows 8.1 x64