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

Errors running on windows in git bash: EPERM operation not permitted, could not find parent dir #18

Closed
klues opened this issue Aug 20, 2020 · 20 comments
Assignees
Labels
bug Something isn't working

Comments

@klues
Copy link

klues commented Aug 20, 2020

I get the following error on running npx yarn-audit-fix on windows in git bash:

npx yarn-audit-fix
Preparing temp assets...
Error: EPERM: operation not permitted, symlink '..\..' -> 'C:\data\src\<my project>\node_modules\.cache\yarn-audit-fix\node_modules'

running the same in a console with administrator privileges results in this error:

npx yarn-audit-fix
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Error: Could not find parent dir!
    at parentPackagePath (C:\data\src\<my project>\node_modules\synp\util\traverse.js:9:11)
    at C:\data\src\<my project>\node_modules\synp\lib\lockfileV1\tree.js:67:30

thanks for any hints to get it running.

@antongolub antongolub added the bug Something isn't working label Aug 20, 2020
@antongolub
Copy link
Owner

antongolub commented Aug 20, 2020

Hi @klues

There're some issues with synp and yarn-audit-fix we're trying to solve right now (imsnif/synp#46). Could you try out the latest 2.0.0-rc.5?

npx yarn-audit-fix@2.0.0-rc.5 --package-lock-only

UPD
I'd also recommend to pass --symlink=junction flag to bypass the permission restrictions.

@MattSwartz
Copy link

Same thing here. I did try the 2.0.0-rc.5 with the same results. See below

$ npx yarn-audit-fix@2.0.0-rc.5 --symlink=junction
npx: installed 375 in 11.943s
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Error: Could not find parent dir!
    at parentPackagePath (C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\util\traverse.js:9:11)
    at C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV1\tree.js:65:30
    at Array.reduce (<anonymous>)
    at buildNpmTree (C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV1\tree.js:51:8)
    at convertYarnToNpmV1 (C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV1\index.js:13:26)
    at convertYarnToNpm (C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\index.js:15:9)
    at Object.yarnToNpm (C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\index.js:15:12)
    at yarnLockToPkgLock (C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\target\es5\index.js:90:42)
    at C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\target\es5\index.js:179:21
    at step (C:\Users\matt\AppData\Roaming\npm-cache\_npx\33692\node_modules\yarn-audit-fix\target\es5\index.js:33:23)

Let me know what information I can supply to help.

@antongolub
Copy link
Owner

antongolub commented Aug 20, 2020

Oh... It seems to be all about path separators. Fixed imsnif/synp@5bfa495. Could you try 2.0.0-rc.7?

UPD I should add windows-based testing task

@antongolub
Copy link
Owner

@MattSwartz @klues

I've added windows os to build matrix. Everything seems to be ok.
https://travis-ci.com/github/antongolub/yarn-audit-fix/jobs/375950459

@antongolub antongolub self-assigned this Aug 20, 2020
@klues
Copy link
Author

klues commented Aug 21, 2020

thank you very much for the support!

I've tried rc7, this is the result:

npx yarn-audit-fix@2.0.0-rc.7 --symlink=junction
npx: Installierte 375 in 12.618s
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Applying npm audit fix...
invoke node node_modules/npm/bin/npm-cli.js audit fix --prefix=C:\data\src\<my-project>\node_modules\.cache\yarn-audit-fix
internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'C:\data\src\<my-project>\node_modules\.cache\yarn-audit-fix\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 11764,
  stdout: null,
  stderr: null
}

@antongolub
Copy link
Owner

antongolub commented Aug 21, 2020

@klues

I guess this is because npm audit fix is trying to eliminate the difference in the node_modules directory structure. Let's try this workaround:

  1. Restore the original node_modules state. yarn --force or rm-rf node_modules && yarn.
  2. Apply npx yarn-audit-fix@2.0.0-rc.7 --symlink=junction --package-lock-only. The last param should instruct npm not to modify node_modules contents.

@klues
Copy link
Author

klues commented Aug 21, 2020

I did

rm -rf node_modules
rm -rf yarn.lock
yarn
npx yarn-audit-fix@2.0.0-rc.7 --symlink=junction --package-lock-only

but unfortunately it results in the same error.
Maybe this line is the problem:
invoke node node_modules/npm/bin/npm-cli.js audit fix --prefix=C:\data\src\<my-project>\node_modules\.cache\yarn-audit-fix
where the current node_modules\.cache directory is passed as --prefix?!

@antongolub
Copy link
Owner

@klues

Most likely you are right. I'll experiment with this a little later.

@antongolub
Copy link
Owner

@klues, @MattSwartz

I've added several tweak ups. Could you take a look at 2.0.0-rc.9 build?

@klues
Copy link
Author

klues commented Aug 21, 2020

this is my result for rc.9:

npx yarn-audit-fix@2.0.0-rc.9 --symlink=junction --package-lock-only
npx: Installierte 375 in 13.941s
Preparing temp assets...
Generating package-lock.json from yarn.lock...
Applying npm audit fix...
invoke C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\node_modules\.bin\npm audit fix --package-lock-only --prefix=C:\data\src\<project>\node_modules\.cache\yarn-audit-fix
{
  error: Error: spawnSync C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\node_modules\.bin\npm ENOENT
      at Object.spawnSync (internal/child_process.js:1045:20)
      at Object.spawnSync (child_process.js:597:24)
      at Object.exports.invoke (C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\target\es5\util.js:23:42)
      at npmAuditFix (C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\target\es5\index.js:105:12)
      at C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\target\es5\index.js:179:21
      at step (C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\target\es5\index.js:33:23)
      at Object.next (C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\target\es5\index.js:14:53)
      at C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\target\es5\index.js:8:71
      at new Promise (<anonymous>)
      at __awaiter (C:\Users\<user>\AppData\Roaming\npm-cache\_npx\18796\node_modules\yarn-audit-fix\target\es5\index.js:4:12) {
    errno: -4058,
    code: 'ENOENT',
    syscall: 'spawnSync C:\\Users\\<user>\\AppData\\Roaming\\npm-cache\\_npx\\18796\\node_modules\\yarn-audit-fix\\node_modules\\.bin\\npm',
    path: 'C:\\Users\\<user>\\AppData\\Roaming\\npm-cache\\_npx\\18796\\node_modules\\yarn-audit-fix\\node_modules\\.bin\\npm',
    spawnargs: [
      'audit',
      'fix',
      '--package-lock-only',
      '--prefix=C:\\data\\src\\<project>\\node_modules\\.cache\\yarn-audit-fix'
    ]
  },
  status: null,
  signal: null,
  output: null,
  pid: 0,
  stdout: null,
  stderr: null
}

@antongolub
Copy link
Owner

Again my carelessness. Sorry. I have not posted the latest edits:

exports.getNpm = function () { return path_1.resolve(require.resolve('npm'), '../../../.bin/npm'); };

should be

export const getNpm = () => resolve(require.resolve('npm'), '../../../.bin', isWindows() ? 'npm.cmd' : 'npm')

2.0.0-rc.10 is waiting for review.

@klues
Copy link
Author

klues commented Aug 21, 2020

unfortunately still looks the same as rc.9

@antongolub
Copy link
Owner

antongolub commented Aug 21, 2020

Looks like I'm having some kind of publishing issue. Try out rc.11 please.

Screenshot 2020-08-21 at 14 52 45

@MattSwartz
Copy link

MattSwartz commented Aug 21, 2020

rc.11 does get past the first part then bombs out here:


found 0 vulnerabilities
npm timing command:audit Completed in 19147ms
npm verb exit [ 0, true ]
npm timing npm Completed in 19956ms
npm info ok
Updating yarn.lock from package-lock.json...
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at flattenPackageLock (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\util\format.js:7:17)
    at buildYarnTree (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV1\tree.js:22:34)
    at convertNpmV1ToYarn (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV1\index.js:26:22)
    at convertNpmV2ToYarn (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\lockfileV2\index.js:84:12)
    at convertNpmToYarn (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\lib\index.js:31:9)
    at Object.npmToYarn (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\node_modules\@antongolub\synp\index.js:17:12)
    at yarnImport (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\target\es5\index.js:114:39)
    at C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\target\es5\index.js:179:21
    at step (C:\Users\matt\AppData\Roaming\npm-cache\_npx\44120\node_modules\yarn-audit-fix\target\es5\index.js:33:23)

@antongolub
Copy link
Owner

In any case, this is a step forward.

@antongolub
Copy link
Owner

antongolub commented Aug 21, 2020

@MattSwartz, could you share a link to your repo? As far as I understand, this issue is related to synp, and invokes code of 2017.

package.json + yarn.lock would be enough

@klues
Copy link
Author

klues commented Aug 21, 2020

rc.11 worked for me, thank you very much for your efforts! 👍

@MattSwartz
Copy link

https://gist.github.com/MattSwartz/710103987633f938a851ba8d80bfe286 let me know if this helps. This is a private repo so I can't share a link to it.

@antongolub
Copy link
Owner

@MattSwartz

I think this is enough for research. Let's deal with this separately: #20

@antongolub
Copy link
Owner

If there is no objections, I'm going to close this for now as the main issue seems to be solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants