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

Scandir errors instead of absolute path uses path relative to the module #1910

Closed
fstani opened this issue Sep 17, 2018 · 3 comments
Closed
Labels
needs followup We need some info or action from whoever filed this issue/PR.

Comments

@fstani
Copy link

fstani commented Sep 17, 2018

As informed in the rbtech/css-purge#32 project

Using node 6.6 on nvm, there seems to be an issue with scandir, it seems to be scanning relative to the path of the css-purge module rather then the absolute path of the dir

Running this command:
css-purge -i /absolute-path/to/css -o static/all.css

Directory read error: Something went wrong while reading the directory, check your [html] in config_css.json and please try again.
{ Error: ENOENT: no such file or directory, scandir '/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/absolute-path/to/css'
at Error (native)
at Object.fs.readdirSync (fs.js:951:18)
at getFilePaths (/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/lib/css-purge.js:1999:10)
at CSSPurgeEmitter.continueCSSFilesProcessAfterConfig (/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/lib/css-purge.js:1861:9)
at emitOne (events.js:96:13)
at CSSPurgeEmitter.emit (events.js:188:7)
at readConfig (/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/lib/css-purge.js:1714:14)
at CSSPurgeEmitter.continueCSSFilesProcess (/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/lib/css-purge.js:1908:5)
at emitOne (events.js:96:13)
at CSSPurgeEmitter.emit (events.js:188:7)
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: '/home/fabio/.nvm/versions/node/v6.6.0/lib/node_modules/css-purge/absolute-path/to/css' }

BTW, this works, providing the specific file

css-purge -i /absolute-path/to/css/one.css -o static/all.css

  • Operating system and version:
    ubuntu 16.04

  • nvm debug output:

nvm --version: v0.32.0
$SHELL: /usr/bin/zsh
$HOME: /home/fabio
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v6.6.0
which node: $NVM_DIR/versions/node/v6.6.0/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v6.6.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v6.6.0
npm root -g: $NVM_DIR/versions/node/v6.6.0/lib/node_modules
  • nvm ls output:
->       v6.6.0  
         system  
default -> node (-> v6.6.0)
node -> stable (-> v6.6.0) (default)
stable -> 6.6 (-> v6.6.0) (default)
iojs -> N/A (default)
lts/* -> lts/argon (-> N/A)
lts/argon -> v4.5.0 (-> N/A)
  • How did you install nvm? (e.g. install script in readme, Homebrew):
    git clone
  • What steps did you perform?
    Ran a node lib that scans a dir
  • What happened?
    Got an EACCESS error, instead of using the absolute path it used the path relative to the nvm module path
  • What did you expect to happen?
    scandir scans the absolute path providede
  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
@ljharb
Copy link
Member

ljharb commented Sep 17, 2018

I'm not clear on how this could possibly be related to nvm; presumably which css-purge places it inside npm root -g, which is itself inside nvm's directory for that node version.

Have you tried on other node versions with nvm? Have you tried on node 6.6 without nvm?

You can see here that it's using fs.realPath, which resolves symlinks - is either $NVM_DIR or $HOME a symlink?

@fstani
Copy link
Author

fstani commented Sep 17, 2018

I will run further testing and update this issue with more information.

@ljharb
Copy link
Member

ljharb commented Mar 11, 2020

Closing pending further info.

@ljharb ljharb closed this as completed Mar 11, 2020
@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs followup We need some info or action from whoever filed this issue/PR.
Projects
None yet
Development

No branches or pull requests

2 participants