Ошибка eperm operation not permitted

This is a typical error caused by Antivirus. There is a workaround for cases like mine, where I can’t disable A/V (Company Policy).

You have to change the polyfills.js inside Npm package:

[NODE_HOME]/node_modules/npm/node_modules/graceful_fs/polyfills.js

Look for this statement:

if (process.platform === "win32") {

Inside of this statement, there is a timeout making a retry in case of error. The problem is that in some cases, after the timeout, the file is still locked by the A/V. The solution is rip out the timeout and let this statement in loop. The change with the previous code commented:

if (platform === "win32") {

fs.rename = (function (fs$rename) { return function (from, to, cb) {
  var start = Date.now()
  var backoff = 0;
  fs$rename(from, to, function CB (er) {
    if (er
        && (er.code === "EACCES" || er.code === "EPERM")
        /*&& Date.now() - start < 60000*/) {
            console.log("Retrying rename file: " + from + " <> " + to)
            fs$rename(from, to, CB);
      /*setTimeout(function() {
        fs.stat(to, function (stater, st) {
          if (stater && stater.code === "ENOENT")
            fs$rename(from, to, CB);
          else
            cb(er)
        })
      }, backoff)*/
      if (backoff < 100)
        backoff += 10;
      return;
    }
    if (cb) cb(er)
  })
}})(fs.rename)
}

I am fighting this for more than a year, so clearly this is independent of npm and or node version. Just now, I got:

λ npm install
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated express@2.5.11: express 2.x series is deprecated
npm WARN deprecated connect@1.9.2: connect 1.x series is deprecated
npm ERR! path H:workaurelia-toolsacb-samplesskeleton-typescript-clinode_modulesfseventsnode_modulesgetpassnode_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'H:workaurelia-toolsacb-samplesskeleton-typescript-clinode_modulesfseventsnode_modulesgetpassnode_modules'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'H:workaurelia-toolsacb-samplesskeleton-typescript-clinode_modulesfseventsnode_modulesgetpassnode_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir 'H:\work\aurelia-tools\acb-samples\skeleton-typescript-cli\node_modules\fsevents\node_modules\getpass\node_modules'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'H:\work\aurelia-tools\acb-samples\skeleton-typescript-cli\node_modules\fsevents\node_modules\getpass\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersnikAppDataRoamingnpm-cache_logs2017-09-15T21_38_03_356Z-debug.log

Then, I just removed the node_modules and run nom install again:

npm install
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated express@2.5.11: express 2.x series is deprecated
npm WARN deprecated connect@1.9.2: connect 1.x series is deprecated
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 1042 packages in 69.35s

I am pretty sure that there is more than one source of this same manifestation, that include the «interference» from running instance of vscode as well as various virus and malware checkers (I have both of them running — and at this time, vscode was not).

The problem is obviously npm’s failure to execute:

scandir 'H:workaurelia-toolsacb-samplesskeleton-typescript-clinode_modulesfseventsnode_modulesgetpassnode_modules'

because «some other running process* has a lock on that folder. This problem is further compounded by the fact that this folder is temporary, making it impossible to look for the lock owner after the fact. Probably the best approach would be that npm «learns» some of the tricks explained in https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows article and dump that data into its log.

thumb

Recently, when attempting to use the gulp command in the Terminal app, I saw an error message saying Error: EPERM: operation not permitted, uv_cwd. In this tutorial, you’ll learn how to solve this problem.

How to fix: Error: EPERM: operation not permitted, uv_cwd

What causes this error

In my case, the below error appeared when attempting to run the gulp command inside my app project directory in the Terminal app.

$ gulp build
internal/bootstrap/switches/does_own_process_state.js:129
    cachedCwd = rawMethods.cwd();
                           ^

Error: EPERM: operation not permitted, uv_cwd
    at process.wrappedCwd [as cwd] (internal/bootstrap/switches/does_own_process_state.js:129:28)
    at Yargs (/usr/local/lib/node_modules/gulp-cli/node_modules/yargs/yargs.js:33:27)
    at Argv (/usr/local/lib/node_modules/gulp-cli/node_modules/yargs/index.js:11:16)
    at Object.<anonymous> (/usr/local/lib/node_modules/gulp-cli/node_modules/yargs/index.js:6:1)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (internal/modules/cjs/helpers.js:72:18) {
  errno: -1,
  code: 'EPERM',
  syscall: 'uv_cwd'
}

This seemed strange to me because I had just used the gulp tool and everything was fine. Then I tried to use the bundle update command, thinking that this can be a hint to localize the problem.

$ bundle update
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Operation not permitted
Traceback (most recent call last):
	9: from /usr/local/bin/bundle:23:in <main>
	8: from /Library/Ruby/Site/2.6.0/rubygems.rb:294:in `activate_bin_path'
	7: from /Library/Ruby/Site/2.6.0/rubygems.rb:264:in `find_spec_for_exe'
	6: from /Library/Ruby/Site/2.6.0/rubygems/dependency.rb:284:in `matching_specs'
	5: from /Library/Ruby/Site/2.6.0/rubygems/bundler_version_finder.rb:45:in `filter!'
	4: from /Library/Ruby/Site/2.6.0/rubygems/bundler_version_finder.rb:7:in `bundler_version'
	3: from /Library/Ruby/Site/2.6.0/rubygems/bundler_version_finder.rb:22:in `bundler_version_with_reason'
	2: from /Library/Ruby/Site/2.6.0/rubygems/bundler_version_finder.rb:73:in `lockfile_version'
	1: from /Library/Ruby/Site/2.6.0/rubygems/bundler_version_finder.rb:85:in `lockfile_contents'
/Library/Ruby/Site/2.6.0/rubygems/bundler_version_finder.rb:85:in pwd': Operation not permitted - getcwd (Errno::EPERM)

The error appeared again, but now the error message is self explanatory. It saying that the shell-init cannot access parent directories, and this is because error retrieving current directory.

In my case, this makes sense because I used the Finder to delete my app project catalog and restore it from the backup after trying new things and changed my mind to keep them. Facepalm >_<

Now we know what caused this error.

How to solve it

Once we know what is causing the gulp run to fail, we can use it to solve the problem. It is a really easy process. To solve this problem, we just need to re-enter into our app project directory. Now, step by step guide.


In the Terminal app, type the following command and press the Enter key to go up one level in the directory.


Now, type the following command and press the Enter key to navigate to your working directory (in this example the my_app_dir catalog is used).

Important! In my case the working directory is the catalog of my app project called my_app_dir where the problem has occurred. Change the command above to suit your case.

Conclusion

That’s it, you’re done. Now the gulp should run without the Error: EPERM: operation not permitted, uv_cwd error. So simple isn’t it?

If you are having trouble fixing this problem with the instructions above, but are being able to solve this problem with any another method please describe it in the comment section below. Thanks!

I hope this article has helped you learn how to fix the Error: EPERM: operation not permitted, uv_cwd error. If this article has helped you then please leave a comment :smiley:

Thanks for reading!

Пhи выполнении галп выдает ошибку. Запуск от администратора не помогает, что очень мистическое, так это что что при удалении файла стилей куда всё компилируется галп работает, т. е. без файла стилей запускаю, он создается, галп выключаю, снова включаю, и ошибка, если .css снова удалить, галп заработает. Многие сервисы не дали ответа, решил обратиться туда где мне точно помогут.5a2cbb9b52c87801676829.png


  • Вопрос задан

    более трёх лет назад

  • 14132 просмотра

I am logged in as root

# whoami
root

I have a file

# ls -l /usr/share/applications/google-chrome.desktop
-rw-r--r-- 1 root root 8424 Dec  3 10:29 /usr/share/applications/google-chrome.desktop

It is a text file

# file /usr/share/applications/google-chrome.desktop
/usr/share/applications/google-chrome.desktop: UTF-8 Unicode text

I want to remove it, but am unable to due to an EPERM error

# rm /usr/share/applications/google-chrome.desktop
rm: cannot remove ‘/usr/share/applications/google-chrome.desktop’: Operation not permitted

Attempting to touch it fails with an EACCES error

# touch /usr/share/applications/google-chrome.desktop
touch: cannot touch ‘/usr/share/applications/google-chrome.desktop’: Permission denied

I can’t change permissions on the file (but changing permissions on other files in the same directory is possible)

# chmod 666 /usr/share/applications/google-chrome.desktop
chmod: changing permissions of ‘/usr/share/applications/google-chrome.desktop’: Operation not permitted

Attempting to recursively change permissions on the parent directory fails because of this file

# chmod -R u+w /usr/share/applications
chmod: changing permissions of ‘/usr/share/applications/google-chrome.desktop’: Operation not permitted

Insufficient disk space is not an issue

# df -h
Filesystem                        Size  Used Avail Use% Mounted on
/dev/sda9                         126G   84G   36G  70% /
none                              4.0K     0  4.0K   0% /sys/fs/cgroup
udev                              3.8G  4.0K  3.8G   1% /dev
tmpfs                             780M  1.2M  779M   1% /run
none                              5.0M     0  5.0M   0% /run/lock
none                              3.9G  152K  3.9G   1% /run/shm
none                              100M   28K  100M   1% /run/user
/dev/sda7                         465M  107M  331M  25% /boot
/dev/sda2                         256M   56M  201M  22% /boot/efi

I have rebooted, this is still an issue.

Here is an strace of the rm call which fails with EPERM

# strace rm /usr/share/applications/google-chrome.desktop
execve("/bin/rm", ["rm", "/usr/share/applications/google-c"...], [/* 29 vars */]) = 0
brk(0)                                  = 0xb87000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f65a6901000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=130454, ...}) = 0
mmap(NULL, 130454, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f65a68e1000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1320372"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1845024, ...}) = 0
mmap(NULL, 3953344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f65a631b000
mprotect(0x7f65a64d6000, 2097152, PROT_NONE) = 0
mmap(0x7f65a66d6000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bb000) = 0x7f65a66d6000
mmap(0x7f65a66dc000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f65a66dc000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f65a68e0000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f65a68de000
arch_prctl(ARCH_SET_FS, 0x7f65a68de740) = 0
mprotect(0x7f65a66d6000, 16384, PROT_READ) = 0
mprotect(0x60d000, 4096, PROT_READ)     = 0
mprotect(0x7f65a6903000, 4096, PROT_READ) = 0
munmap(0x7f65a68e1000, 130454)          = 0
brk(0)                                  = 0xb87000
brk(0xba8000)                           = 0xba8000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7216688, ...}) = 0
mmap(NULL, 7216688, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f65a5c39000
close(3)                                = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
newfstatat(AT_FDCWD, "/usr/share/applications/google-chrome.desktop", {st_mode=S_IFREG|0644, st_size=8424, ...}, AT_SYMLINK_NOFOLLOW) = 0
geteuid()                               = 0
unlinkat(AT_FDCWD, "/usr/share/applications/google-chrome.desktop", 0) = -1 EPERM (Operation not permitted)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f65a6900000
read(3, "# Locale name alias data base.n#"..., 4096) = 2570
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f65a6900000, 4096)            = 0
open("/usr/share/locale/en_AU/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_AU/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=63459, ...}) = 0
mmap(NULL, 63459, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f65a68f1000
close(3)                                = 0
open("/usr/share/locale-langpack/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=619, ...}) = 0
mmap(NULL, 619, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f65a68f0000
close(3)                                = 0
open("/usr/lib/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "rm: ", 4rm: )                     = 4
write(2, "cannot remove 342200230/usr/share/appl"..., 65cannot remove ‘/usr/share/applications/google-chrome.desktop’) = 65
open("/usr/share/locale/en_AU/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_AU/LC_MESSAGES/libc.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=3100, ...}) = 0
mmap(NULL, 3100, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f65a68ef000
close(3)                                = 0
open("/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Operation not permitted", 25: Operation not permitted) = 25
write(2, "n", 1
)                       = 1
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++

Here is an strace of the touch call which fails with EACCES

# strace touch /usr/share/applications/google-chrome.desktop
execve("/usr/bin/touch", ["touch", "/usr/share/applications/google-c"...], [/* 29 vars */]) = 0
brk(0)                                  = 0x105c000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9a020af000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=130454, ...}) = 0
mmap(NULL, 130454, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9a0208f000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "177ELF2113>1320372"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1845024, ...}) = 0
mmap(NULL, 3953344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9a01ac9000
mprotect(0x7f9a01c84000, 2097152, PROT_NONE) = 0
mmap(0x7f9a01e84000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bb000) = 0x7f9a01e84000
mmap(0x7f9a01e8a000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f9a01e8a000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9a0208e000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9a0208c000
arch_prctl(ARCH_SET_FS, 0x7f9a0208c740) = 0
mprotect(0x7f9a01e84000, 16384, PROT_READ) = 0
mprotect(0x60d000, 4096, PROT_READ)     = 0
mprotect(0x7f9a020b1000, 4096, PROT_READ) = 0
munmap(0x7f9a0208f000, 130454)          = 0
brk(0)                                  = 0x105c000
brk(0x107d000)                          = 0x107d000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=7216688, ...}) = 0
mmap(NULL, 7216688, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9a013e7000
close(3)                                = 0
open("/usr/share/applications/google-chrome.desktop", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = -1 EACCES (Permission denied)
utimensat(AT_FDCWD, "/usr/share/applications/google-chrome.desktop", NULL, 0) = -1 EACCES (Permission denied)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9a020ae000
read(3, "# Locale name alias data base.n#"..., 4096) = 2570
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f9a020ae000, 4096)            = 0
open("/usr/share/locale/en_AU/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_AU/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=63459, ...}) = 0
mmap(NULL, 63459, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9a0209f000
close(3)                                = 0
open("/usr/share/locale-langpack/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=619, ...}) = 0
mmap(NULL, 619, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9a0209e000
close(3)                                = 0
open("/usr/lib/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "touch: ", 7touch: )                  = 7
write(2, "cannot touch 342200230/usr/share/appli"..., 64cannot touch ‘/usr/share/applications/google-chrome.desktop’) = 64
open("/usr/share/locale/en_AU/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_AU/LC_MESSAGES/libc.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=3100, ...}) = 0
mmap(NULL, 3100, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9a0209d000
close(3)                                = 0
open("/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Permission denied", 19: Permission denied)     = 19
write(2, "n", 1
)                       = 1
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++

What is going on here? How can I remove this file?

Понравилась статья? Поделить с друзьями:
  • Ошибка epc на фольксваген caddy
  • Ошибка epc элинж
  • Ошибка epc на мерседес 210
  • Ошибка epc шкода румстер
  • Ошибка epc на мерседес 203