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.rename() throws a permissions error #6335

Closed
Gum-Joe opened this issue Apr 21, 2016 · 2 comments
Closed

fs.rename() throws a permissions error #6335

Gum-Joe opened this issue Apr 21, 2016 · 2 comments
Labels
fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.

Comments

@Gum-Joe
Copy link

Gum-Joe commented Apr 21, 2016

  • 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!

@mscdex mscdex added fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform. labels Apr 21, 2016
@claudiorodriguez
Copy link
Contributor

I had no issues running the code you provided (after adding a parenthesis at the end) on a Win10 machine. The folder was renamed correctly with no errors thrown. Are you sure you don't have the folder open in a Windows Explorer, or a command prompt?

@Gum-Joe
Copy link
Author

Gum-Joe commented Apr 22, 2016

@claudiorodriguez I rebootes my PC and the issue was fixed! The problems was either:

  1. I had a windows explorer or command prompt (git-bash for me) window open, or a file in the folder open in my text editor (atom).
  2. The folder already existed, so I couldn't overwrite the folder (proven by testing).

Thank you for all the help!

@Gum-Joe Gum-Joe closed this as completed Apr 22, 2016
Gum-Joe added a commit to Gum-Joe/retis that referenced this issue Apr 22, 2016
📦 Added pip installer.
🔈 Added info about which package manager using for global
installation of packages.
🔈 Added "(language)" to installer info, with colour to show
language installing for.
🔈 Added BOLDNESS to STDERR & STDOUT output (makes it lighter)
🔈 Added ERROR! logging method (red coloured)
🎨 Moved the NVM warning into a new warnings file
(src/warnings.coffee), where the user is alerted about warnings before
build.
🎨 Added RVM to local build warnings
🐛 Fixed nodejs/node#6335
🎨 Added removal of old packages if already existed, when using
--force option
⬆️ Installed rimraf@^2.5.2 for recursive removal of old
directories of plugins when using --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

3 participants