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

Fatal error: Unable to write "dist/" file (Error code: EISDIR). #12

Open
deanhume opened this issue Jun 5, 2015 · 12 comments
Open

Fatal error: Unable to write "dist/" file (Error code: EISDIR). #12

deanhume opened this issue Jun 5, 2015 · 12 comments

Comments

@deanhume
Copy link
Contributor

deanhume commented Jun 5, 2015

Hi

I am running the following configuration in my Gruntfile:

critical: {
        dist: {
            options: {
                base: './',
                width: 1300,
                height: 900
            },
            src: '**/*.html',
            dest: 'dist/'
        }
    }
})

The idea is that I pick up all HTML files and then dump them into my "dist" folder. When I run this, I unfortunately get the following error:

"Fatal error: Unable to write "dist/" file (Error code: EISDIR)."

If I run the task with --stack, I get the following output

Error: EISDIR, illegal operation on a directory 'C:\Users\dean.hume\Documents\GitHub\typography\dist'
    at Object.fs.openSync (fs.js:427:18)
    at Object.fs.writeFileSync (fs.js:966:15)
    at Object.file.write (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt\lib\grunt\file.js:296:10)
    at C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\tasks\critical.js:63:36
    at C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\index.js:275:13
    at tryCatcher (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\util.js:24:31)
at Promise._settlePromiseFromHandler (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\promise.js:454:31)
    at Promise._settlePromiseAt (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\promise.js:530:18)
    at Promise._settlePromises (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\promise.js:646:14)
    at Async._drainQueue (C:\Users\dean.hume\Documents\GitHub\typography\node_modules\grunt-critical\node_modules\critical\node_modules\bluebird\js\main\async.js:177:16)
@deanhume
Copy link
Contributor Author

deanhume commented Jun 5, 2015

I've also tried running this without the subdirectory src, eg:

 src: '*.html',
 dest: 'dist/'

But unfortunately I still get the same error. I'm not sure if the task is looking for a file instead of a directory.....

@bezoerb
Copy link
Owner

bezoerb commented Jun 5, 2015

try

files: [
    {cwd: '.', src: ['*.html'], dest: 'dist'}
]

deanhume added a commit to deanhume/grunt-critical that referenced this issue Jun 5, 2015
As discovered in issue
[12](bezoerb#12), when trying
to write multiple files to a folder, the write fails because it assumes
that the path is a file and not a folder.

I have updated the code to check first if the destination is a folder
and update accordingly. See [this
issue](http://stackoverflow.com/a/20417119/335567) on SO for more
information.
@deanhume
Copy link
Contributor Author

deanhume commented Jun 5, 2015

Hmmm...that didn't seem to work for me. I've created a pull request and fixed the issue. Let me know what you think!

@bezoerb
Copy link
Owner

bezoerb commented Jun 6, 2015

@deanhume pr landed.

src: '*.html',
dest: 'dist/'

should work as expected. Wanna give it a try?

@deanhume
Copy link
Contributor Author

deanhume commented Jun 8, 2015

Hmmmm...almost there - except I get a different error this time.

Fatal error: Maximum call stack size exceeded

I am running it against 12 files. Not sure, but my original pull request seemed to work. Any ideas?

Thanks for you help!

@deanhume
Copy link
Contributor Author

deanhume commented Jun 9, 2015

If you need any more detail around this error, please let me know!

@bezoerb
Copy link
Owner

bezoerb commented Jun 9, 2015

@deanhume more detail please ;)
I'm not able to reproduce the call stack error on my side.

@bezoerb
Copy link
Owner

bezoerb commented Jun 18, 2015

@deanhume any updates on this?

@michaelthorne
Copy link

michaelthorne commented Nov 18, 2015

Hey @bezoerb I'm also experiencing the same issue:

Running "critical:dist" (critical) task
Unhandled rejection RangeError: Maximum call stack size exceeded
at new Error (native)
at Error (native)
at Object.fs.mkdirSync (fs.js:794:18)

And the critical Grunt task:

critical: {
    dist: {
        options: {
            base: './',
            css: [
                'dist/assets/css/style.css'
            ],
            ignore: ['@font-face'],
            width: 320,
            height: 480
        },
        src: ['dist/**/*.html'],
        dest: 'test/'
    }
},

It works fine if I change src to e.g. src: dist/index.html and dest to dest: dist/index.html i.e. replaces the existing file with the inline <style> element.

Versions:

npm 2.14.7
node 4.2.2

Windows 8.1

Any ideas? Thanks in advance!

@michaelthorne
Copy link

michaelthorne commented Nov 18, 2015

@bezoerb @deanhume the problem seems to be that src and dest only accept strings (file names).

If I change the Grunt task to:

src: 'dist/index.html',
dest: 'test/index.html'

It works as expected. If I change it to:

src: 'dist/index.html',
dest: 'test'

It creates a file test (without an extension) and works as expected (CSS is inlined).

If I change it to e.g.

src: 'dist/index.html',
dest: 'test/'

i.e. a directory test/ it throws this error:

Unhandled rejection RangeError: Maximum call stack size exceeded
    at new Error (native)
    at Error (native)
    at Object.fs.mkdirSync (fs.js:794:18)
    at mkdirsSync (C:\path_to_project\node_modules\grunt-critical\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:22:9)

@bezoerb
Copy link
Owner

bezoerb commented Nov 18, 2015

@michaelthorne thanks for the debugging :)
I hope to have some time within the next days to provide a fix

@michaelthorne
Copy link

@bezoerb no worries! Let me know if there's any testing I can help with. Thanks.

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

No branches or pull requests

3 participants