jakejs / jake

JavaScript build tool, similar to Make or Rake. Built to work with Node.js.
http://jakejs.com
Apache License 2.0
1.97k stars 190 forks source link

jake watch does not work #206

Open ryandesign opened 11 years ago

ryandesign commented 11 years ago

I added this line to my Jakefile:

watchTask(['default']);

But with jake 0.6.7 on node 0.10.13, running jake watch fails:

$ ./node_modules/.bin/jake watch --trace
WatchTask started for: default
jake aborted.
Error: watch EMFILE
    at errnoException (fs.js:1019:11)
    at FSWatcher.start (fs.js:1051:11)
    at Object.fs.watch (fs.js:1076:11)
    at createWatcher (/path/to/node_modules/jake/node_modules/utilities/lib/file.js:199:12)
    at /path/to/node_modules/jake/node_modules/utilities/lib/file.js:217:9
    at Object.oncomplete (fs.js:107:15)
ryandesign commented 11 years ago

I should add this is on OS X 10.8.4.

mde commented 11 years ago

Do you have a "default" task to run?

On Tue, Jul 23, 2013 at 2:04 PM, Ryan Schmidt notifications@github.comwrote:

I should add this is on OS X 10.8.4.

— Reply to this email directly or view it on GitHubhttps://github.com/mde/jake/issues/206#issuecomment-21445919 .

ryandesign commented 11 years ago

Certainly! And just running jake runs it just fine.

mde commented 11 years ago

Ah, here we go: https://github.com/joyent/node/issues/2479

Looks like it's a problem with the number of files in the directory.

Apparently there's a possible workaround which involves switching to fs.watchFile in this case, but I'd have to do some more investigation to see how well this works.

On Tue, Jul 23, 2013 at 2:11 PM, Ryan Schmidt notifications@github.comwrote:

Certainly! And just running jake runs it just fine.

— Reply to this email directly or view it on GitHubhttps://github.com/mde/jake/issues/206#issuecomment-21446326 .

ryandesign commented 11 years ago

Thanks. ulimit -n 10000 before running jake watch works fine so I can use that. There shouldn't be that many files though.

Your readme says:

By default, it will watch the current directory for these files:

[ './**/*.js'
, './**/*.coffee'
, './**/*.css'
, './**/*.less'
, './**/*.scss'
]

It will exclude these files:

[ 'node_modules/**'
, '.git/**'
]

I don't have any .coffee, .less or .scss files, and only 63 .js and .css files, so I should not have been exceeding the 256 open file limit. There are about 1500 files if I include those in node_modules, but you're supposed to be ignoring those...

mde commented 11 years ago

Ah, actually, no -- the include/exclude only tells the WatchTask what it should or should not react to changes on. It does a watch on the entire directory.

I'm not sure if there's a good fix for this, but maybe at bare minimum we can special-case the .node_modules directory.

On Tue, Jul 23, 2013 at 2:24 PM, Ryan Schmidt notifications@github.comwrote:

Thanks. ulimit -n 10000 before running jake watch works fine so I can use that. There shouldn't be that many files though.

Your readme says:

By default, it will watch the current directory for these files:

[ './/.js' , './/_.coffee' , './_/.css' , './/.less' , './/*.scss' ]

It will exclude these files:

[ 'node_modules/' , '.git/' ]

I don't have any .coffee, .less or .scss files, and only 63 .js and .css files, so I should not have been exceeding the 256 open file limit. There are about 1500 files if I include those in node_modules, but you're supposed to be ignoring those...

— Reply to this email directly or view it on GitHubhttps://github.com/mde/jake/issues/206#issuecomment-21447182 .

felixrabe commented 10 years ago

I don't get how I properly get jake watch to work with version 8.0.8 on OS X 10.9:

jakefile.js:

task('default', function() {
  console.log('default');
});

watchTask(['default']);

Terminal:

$ jake watch
WatchTask started for: 

And it just sits there, even if I update jakefile.js (which should get caught in my understanding).

If I add an empty anonymous function:

task('default', function() {
  console.log('default');
});

watchTask(['default'], function() { });

it will actually work:

$ jake watch
WatchTask started for: default
default

But it is too laggy. I have to cause several changes (save a few times) before it triggers. (This is a directory that contains only jakefile.js.)

mde commented 10 years ago

Yes, looks like it actually requires a definition function to be passed. That's a bug. I have filed an issue for this: https://github.com/jakejs/jake/issues/273

I cannot repro the other problem you're reporting. I am not seeing any sort of lag if I pass it the dummy function. I created a test directory with nothing in it but the Jakefile and a foo.js file. Every time I make a change to the foo.js file, I see the log appear immediately in the console.