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

Result "ERROR: The specified config file doesn’t exist or is unreadable:" when config file does exist and is readable #428

Closed
terry-webfox opened this issue Nov 2, 2015 · 11 comments

Comments

@terry-webfox
Copy link

Running this command from within my project folder:

html-minifier -c html-minifier.cfg -o lib/welcome.html client/welcome.html

gives error:

ERROR: The specified config file doesn’t exist or is unreadable:
/var/www/projectfolder/html-minifier.cfg

The config file does exist and is readable, so surely this error shouldn't occur?

Am using v1.0.0 from Linux Mint

@terry-webfox
Copy link
Author

I installed v0.8.0:

sudo npm install -g html-minifier@0.8.0

and then the command given above worked. Looks like it's a bug specific to version 1.0.0

@mosbth
Copy link

mosbth commented Nov 18, 2015

I got the same error when using html-minifier on Travis where version 1.0.0 was installed. It was installed through npm -g html-minifier.

$ html-minifier --version
html-minifier v1.0.0

It failed with this error:

WARNING html-minifier failed: build//clearfix/clear-no.html
ERROR: The specified config file doesn’t exist or is unreadable:
/home/travis/build/mosbth/htmlphp/.html-minifier.conf

My config file is:

$ more .html-minifier.conf 
{                                               
  "removeComments": true,                       
  "collapseWhitespace": true,                   
  "conservativeCollapse": true,                 
  "collapseBooleanAttributes": true,            
  "removeAttributeQuotes": true,                
  "removeRedundantAttributes": true,            
  "useShortDoctype": true,                      
  "removeEmptyAttributes": false,               
  "removeOptionalTags": false,                  
  "removeEmptyElements": false,                 
  "lint": false,                                
  "keepClosingSlash": true,                     
  "caseSensitive": true,                        
  "minifyJS": true,                             
  "minifyCSS":  true                            
}                                               

The travis build is here:
https://travis-ci.org/mosbth/htmlphp/builds/91836199

I updated html-minifier on my local debian (unstable) and it worked fine with 1.0.0. So perhaps its something special with the Travis environment.

I installed version 0.8.0 at Travis which worked fine (see the build):
https://travis-ci.org/mosbth/htmlphp/builds/91842585

@alexlamsl
Copy link
Collaborator

@terry-webfox @mosbth since you two have reproducible environments, may I ask you to:

  • install the latest version (1.1.1)
  • confirms the issue still exists
  • comment out this line
  • run again to see if the problem persists?

@mosbth
Copy link

mosbth commented Feb 5, 2016

@alexlamsl I can confirm that version 1.1.1 gives the same error on Travis.
https://travis-ci.org/mosbth/htmlphp/jobs/107185469

I'm not able to comment out the line on Travis, so I can not try to see if the problem exists after that.

@alexlamsl
Copy link
Collaborator

@mosbth can you run node on the machine?

If so, try fs.accessSync('/path/to/conf') and see what returns?

@alexlamsl
Copy link
Collaborator

@mosbth I meant to say fs.accessSync('/path/to/file.conf', fs.R_OK)

@mosbth
Copy link

mosbth commented Feb 5, 2016

It looks like this:

Complete build:
https://travis-ci.org/mosbth/htmlphp/jobs/107198002

The interesting part when Travis runs the test:

$ node test.js
Trying fs.accessSync('.html-minifier.conf');
/home/travis/build/mosbth/htmlphp/test.js:7
fs.accessSync('.html-minifier.conf');
   ^
TypeError: Object #<Object> has no method 'accessSync'
    at Object.<anonymous> (/home/travis/build/mosbth/htmlphp/test.js:7:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3

The script test.js:

/**
 *
 */
var fs = require('fs');

console.log("Trying fs.accessSync('.html-minifier.conf');");
fs.accessSync('.html-minifier.conf');

Same result rerunning the build using fs.R_OK
https://travis-ci.org/mosbth/htmlphp/jobs/107199737

So, hey, perhaps just old version of node which does not have this method available.
Travis automatically installs older version of node.

$ node --version
v0.10.36

@alexlamsl
Copy link
Collaborator

@mosbth definitely not available on that version of Node.js

@kangax I don't think we need the call to this, plus there are related issues that imply this is not entirely reliable. Would it be okay to remove a call to this altogether?

@kangax
Copy link
Owner

kangax commented Feb 5, 2016

What's the purpose of that call in the first place?

@alexlamsl
Copy link
Collaborator

AFAICT, it is to check if the configuration file is accessible - which I think is duplicating the exception to be potentially thrown by readFileSync()

@kangax
Copy link
Owner

kangax commented Feb 5, 2016

Ok, let's remove it then.

@alexlamsl alexlamsl mentioned this issue Feb 5, 2016
@kangax kangax closed this as completed in 97ae178 Feb 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants