Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

fs.unlink on directory causes UNKNOWN error #2096

Closed
TrevorBurnham opened this issue Nov 14, 2011 · 6 comments
Closed

fs.unlink on directory causes UNKNOWN error #2096

TrevorBurnham opened this issue Nov 14, 2011 · 6 comments
Labels

Comments

@TrevorBurnham
Copy link

If 'dir' is a directory, then fs.unlinkSync('dir') throws, and fs.unlink passes,

Error: UNKNOWN, unknown error 'dir'

(tested on Node 0.6.1 under OS X). Is it possible to generate a more precise error? For comparison, rm dir provides the output

rm: dir: is a directory
@tshinnic
Copy link

Still true with 0.6.2 on Windows

  > fs.unlinkSync('foo');
  Error: UNKNOWN, unknown error 'foo'
      at Object.unlinkSync (fs.js:443:18)

With 0.6.2 on Linux, something more likely:

  > fs.unlinkSync('foo')
  Error: EISDIR, illegal operation on a directory 'foo'
      at Object.unlinkSync (fs.js:443:18)

@TrevorBurnham
Copy link
Author

Interesting. So the question is: Can we bring the EISDIR error to Windows and OS X?

On Nov 20, 2011, at 5:14 AM, [email protected] wrote:

Still true with 0.6.2 on Windows

fs.unlinkSync('foo');
Error: UNKNOWN, unknown error 'foo'
at Object.unlinkSync (fs.js:443:18)

With 0.6.2 on Linux, something more likely:

fs.unlinkSync('foo')
Error: EISDIR, illegal operation on a directory 'foo'
at Object.unlinkSync (fs.js:443:18)


Reply to this email directly or view it on GitHub:
#2096 (comment)

@peppage
Copy link

peppage commented Apr 23, 2014

I tried this on windows and I get a different error now.

$ node -v
v0.10.26
> fs.unlinkSync('foo');
Error: EPERM, operation not permitted 'c:\workspace\node-test\foo'
    at Object.fs.unlinkSync (fs.js:760:18)
    at repl:1:4
    at REPLServer.self.eval (repl.js:110:21)
    at repl.js:249:20
    at REPLServer.self.eval (repl.js:122:7)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.EventEmitter.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)

On linux I still get the EISDIR error.

@indutny
Copy link
Member

indutny commented Jun 30, 2014

@peppage EPERM is what OSX's unlink() syscall naturally returns for directories:

    [EPERM]            The named file is a directory and the effective user ID of the process is not the super-user.

     [EPERM]            The directory containing the file is marked sticky, and neither the containing directory nor the file to be removed are owned by the effective user ID.

Also, I think we should be returning the same thing for windows in the latest node (v0.11): https://github.com/joyent/libuv/blob/master/src/win/fs.c#L676 , could you please check it out?

@indutny
Copy link
Member

indutny commented Jun 30, 2014

Unfortunately, non-BSD systems seems to return EISDIR in such case indeed.

@indutny
Copy link
Member

indutny commented Jun 30, 2014

I don't think that we are going to unify it, sorry.

@indutny indutny closed this as completed Jun 30, 2014
wiedi pushed a commit to wiedi/node that referenced this issue Aug 15, 2015
Notable changes:

* buffer:
  - Due to changes in V8, it has been necessary to reimplement Buffer
    on top of V8's Uint8Array. While every effort has been made to
    maintain performance, users are likely to experience a different
    performance profile depending on how Buffer is used.
    (Trevor Norris) nodejs#1825.
  - Buffer can now take ArrayBuffers as a constructor argument
    (Trevor Norris) nodejs#2002.
  - When a single buffer is passed to Buffer.concat(), a new, copied
    Buffer object will be returned; previous behavior was to return
    the original Buffer object (Sakthipriyan Vairamani) nodejs#1937.
* build: PPC support has been added to core to allow compiling on
  pLinux BE and LE (AIX support coming soon) (Michael Dawson) nodejs#2124.
* dgram: If an error occurs within socket.send() and a callback has
  been provided, the error is only passed as the first argument to the
  callback and not emitted on the socket object; previous behavior was
  to do both (Matteo Collina & Chris Dickinson) nodejs#1796
* freelist: Deprecate the undocumented freelist core module
  (Sakthipriyan Vairamani) nodejs#2176.
* http:
  - Status codes now all use the official IANA names as per RFC7231,
    e.g. http.STATUS_CODES[414] now returns 'URI Too Long' rather than
    'Request-URI Too Large' (jomo) nodejs#1470.
  - Calling .getName() on an HTTP agent no longer returns a trailing
    colon, HTTPS agents will no longer return an extra colon near the
    middle of the string (Brendan Ashworth) nodejs#1617.
* node:
  - NODE_MODULE_VERSION has been bumped to 45 to reflect the break in
    ABI (Rod Vagg) nodejs#2096.
  - Introduce a new process.release object that contains a name
    property set to 'io.js' and sourceUrl, headersUrl and libUrl
    (Windows only) properties containing URLs for the relevant
    resources; this is intended to be used by node-gyp
    (Rod Vagg) nodejs#2154.
  - The version of node-gyp bundled with io.js now downloads and uses
    a tarball of header files from iojs.org rather than the full
    source for compiling native add-ons; it is hoped this is a
    temporary floating patch and the change will be upstreamed to
    node-gyp soon (Rod Vagg) nodejs#2066.
* repl: Persistent history is now enabled by default. The history file
  is located at ~/.node_repl_history, which can be overridden by the
  new environment variable NODE_REPL_HISTORY. This deprecates the
  previous NODE_REPL_HISTORY_FILE variable. Additionally, the format
  of the file has been changed to plain text to better handle file
  corruption. (Jeremiah Senkpiel) nodejs#2224.
* smalloc: The smalloc module has been removed as it is no longer
  possible to provide the API due to changes in V8
  (Ben Noordhuis) nodejs#2022.
* tls: Add server.getTicketKeys() and server.setTicketKeys() methods
  for TLS session key rotation (Fedor Indutny) nodejs#2227.
* v8: Upgraded to 4.4.63.26
  - ES6: Enabled computed property names
  - ES6: Array can now be subclassed in strict mode
  - ES6: Implement rest parameters in staging, use the
    --harmony-rest-parameters command line flag
  - ES6: Implement the spread operator in staging, use the
    --harmony-spreadcalls command line flag
  - Removed SetIndexedPropertiesToExternalArrayData and related APIs,
    forcing a shift to Buffer to be reimplemented based on Uint8Array
  - Introduction of Maybe and MaybeLocal C++ API for objects which may
    or may not have a value.
  - Added support for PPC

PR-URL: nodejs/node#2299
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants