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

fs.copySync: Error: EPERM: operation not permitted, unlink #320

Closed
monolithed opened this issue Nov 18, 2016 · 2 comments
Closed

fs.copySync: Error: EPERM: operation not permitted, unlink #320

monolithed opened this issue Nov 18, 2016 · 2 comments

Comments

@monolithed
Copy link

monolithed commented Nov 18, 2016

let from = 'file.txt'
let to = '/tmp/'

fs.copySync(from, to); // error
fs.copySync(config, cache, () => { console.log('done') }); // no error, no file
fs.copy(from, to); // ok

from

-rw-r--r--    1 a.abashkin  staff   862 18 ноя 17:35 test.txt

to

drwxr-x---  138 a.abashkin  staff  4692 18 ноя 20:03 ..

The problem is that I cannot copy a file to directory (file to file is ok).

 @qa:npm-cache coping config /Users/a.abashkin/workspace/mail.ru/@qa/npm-cache/test.txt => /var/folders/0y/jg1cdcj50zv2vjsjzxtsfhqc0000gp/T/b68872c30295c440b0dc28c224bb9c3e +3ms
fs.js:988
  return binding.unlink(pathModule._makeLong(path));
                 ^

Error: EPERM: operation not permitted, unlink '/var/folders/0y/jg1cdcj50zv2vjsjzxtsfhqc0000gp/T/b68872c30295c440b0dc28c224bb9c3e'
    at Object.fs.unlinkSync (fs.js:988:18)
    at copyFileSync (/Users/a.abashkin/workspace/mail.ru/@qa/npm-cache/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js:12:10)
    at Object.copySync (/Users/a.abashkin/workspace/mail.ru/@qa/npm-cache/node_modules/fs-extra/lib/copy-sync/copy-sync.js:40:7)
    at Cache.copyConfig (/Users/a.abashkin/workspace/mail.ru/@qa/npm-cache/index.js:257:6)
    at Cache.installModules (/Users/a.abashkin/workspace/mail.ru/@qa/npm-cache/index.js:212:8)
    at Cache.setCache (/Users/a.abashkin/workspace/mail.ru/@qa/npm-cache/index.js:345:8)
    at request.response (/Users/a.abashkin/workspace/mail.ru/@qa/npm-cache/index.js:327:19)
    at Request.request.on.response (/Users/a.abashkin/workspace/mail.ru/@qa/npm-cache/utils/request.js:47:4)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)

supporting information:

  • npm -v prints: 3.10.8
  • node -v prints: v7.0.0
  • npm config get registry prints:
  • Windows, OS X/macOS, or Linux?: Darwin
@RyanZim
Copy link
Collaborator

RyanZim commented Nov 18, 2016

fs-extra does not support copying a file to a directory, you must specify directory/newFileName.txt.

Copying to a directory is implicit behavior since you're not actually specifying the destination, just the destination directory.

Quoting @jprichardson:

I believe that we as programmers should make our intentions explicit as writing code is easy but going back and reading code is hard.

So yeah, this is working as intended.

@misterbrownlee
Copy link

Repository owner locked and limited conversation to collaborators Feb 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants