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

ShellJS: internal error Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys' #514

Closed
bortexz opened this issue Aug 29, 2016 · 3 comments
Labels
electron Bugs specific to the electron framework fix Bug/defect, or a fix for such a problem help wanted low priority

Comments

@bortexz
Copy link

bortexz commented Aug 29, 2016

Node version (or tell us if you're using electron or some other framework):

4.3.1, using electron

ShellJS version (the most recent version/Github branch you see the bug on):

0.7.2

Operating system:

Windows 10

Description of the bug:

When trying to ls on C:, it fires the following error:

ShellJS: internal error
Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys'
    at Error (native)
    at fs.lstatSync (fs.js:982:18)
    at Object.fs.lstatSync (ELECTRON_ASAR.js:238:16)
    at pushFile (C:\Users\alberto\Projects\quercus\node_modules\shelljs\src\ls.js:63:25)

Example ShellJS command to reproduce the error:

let sh = require('shelljs')
sh.cd('C:\\')
sh.ls('-lA')
@bortexz
Copy link
Author

bortexz commented Aug 29, 2016

Could something like this be an approach?

function pushFile(abs, relName, stat) {
    if (process.platform === 'win32') {
      relName = relName.replace(/\\/g, '/');
    }
    if (options.long) {
      try {
        stat = stat || fs.lstatSync(abs);
      } catch (e) {
        console.log(e.code)
        stat = {}
      } finally {
        list.push(addLsAttributes(relName, stat));
      }
    } else {
      // list.push(path.relative(rel || '.', file));
      list.push(relName);
    }
  }

It's done fast, not a real solution at all. Problem with this is you need to test for any function if it exists or not, and doesn't specify that a file was locked.

Any ideas?

Kind to make a PR for this when agree on the approach :)

bortexz added a commit to bortexz/shelljs that referenced this issue Aug 29, 2016
Temporary solution for shelljs#514

Adds the 'locked' attribute when file cannot be accessed.
bortexz added a commit to bortexz/quercus that referenced this issue Aug 29, 2016
For that, changed shelljs to use my fork with a temporary solution for shelljs/shelljs#514
@nfischer
Copy link
Member

@bertofer Sorry, I didn't notice this until now!

It looks to me like we don't have permission to read that file? Why would that be?

I'm not opposed to this as a PR if it's the best approach. If there's a way we can stat the file, that would be even better.

Some points:

  • Please remove the console.log()
  • Please add a test. If you can find a way to repro this on unix (perhaps by changing permissions), that would be ideal. Otherwise, add a Windows-specific test-case (just skip if process.platform !== 'win32').

@nfischer nfischer added fix Bug/defect, or a fix for such a problem low priority labels Nov 20, 2016
@nfischer nfischer added this to the v0.7.x milestone Nov 20, 2016
@nfischer nfischer assigned nfischer and unassigned nfischer Nov 20, 2016
@nfischer nfischer removed this from the v0.7.x milestone Dec 20, 2016
@nfischer nfischer added the electron Bugs specific to the electron framework label Jun 7, 2017
@nfischer
Copy link
Member

nfischer commented Jun 7, 2017

Closing this, since we don't officially support electron. I see that some ASAR stuff is mentioned, perhaps you might find a suitable workaround in our wiki page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron Bugs specific to the electron framework fix Bug/defect, or a fix for such a problem help wanted low priority
Projects
None yet
Development

No branches or pull requests

2 participants