Skip to content

fs.rename() throws a permissions error #6335

@Gum-Joe

Description

@Gum-Joe
  • Version: v5.10.1
  • Platform: 64-bit
  • Subsystem: File System

When attempting to rename a file on my Windows 10 PC, I get the following error message:

...previous console output...
        throw err;
        ^

Error: EPERM: operation not permitted, rename 'C:\Users\Gum-Joe\.retis\plugins\.tmp\extract\retis-tester-1-master' -> 'C:\Users\Gum-Joe\.retis\plugins\.tmp\extract\retis-example'
  at Error (native)

I had a look at Medium/phantomjs#19, where one of the comments states that this issue is only on Windows, which is true for my issue as my program works on my Raspberry Pi, which runs Raspian.

Here is a small test case (~/ = windows home directory) :

  1. Create the directory ~/.retis/plugins/.tmp/extract/test
  2. Run this code:
const fs = require('fs');
const os = require('os');
fs.rename(
  `${os.homedir()}/.retis/plugins/.tmp/extract/test`,
  `${os.homedir()}/.retis/plugins/.tmp/extract/renamed`,
  (err) => {
    if (err) {
      throw err;
    }
  };

Feel free to check out my own source code:
Coffee Script: https://github.com/jakhu/retis-ci/blob/master/src/plugins/unpacker.coffee
Compiled JavaScript: https://github.com/jakhu/retis-ci/blob/master/lib/plugins/unpacker.js

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions