watchpack icon indicating copy to clipboard operation
watchpack copied to clipboard

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/...'

Open Philipp91 opened this issue 4 years ago • 91 comments

I run webpack --watch --watch-options-stdin ... and amidst its initial build (not the subsequent builds triggered by changed files), it prints:

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/DumpStack.log.tmp'
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/hiberfil.sys'
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/pagefile.sys'
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/swapfile.sys'

Someone already reported the problem here, so I'll refer to those details for reproduction. Key elements are webpack v5 and WSL1 under Windows.

The directory /mnt/c maps to the Windows root drive C:\, which contains these special files like the swapfile, to which the user doesn't have access. That is, the command ls /mnt/c fails on the command line too. So it's not surprising that it fails for watchpack too.

What is surprising (to me) is that watchpack attempts to list that directory to begin with. I have no config telling webpack/watchpack what to watch, only that --watch flag. Can someone explain this to me?

Philipp91 avatar Jan 04 '21 11:01 Philipp91

Can you provide structure of your project?

alexander-akait avatar Jan 04 '21 13:01 alexander-akait

See here. I can additionally provide my own setup, but it would take quite a while to strip it down to something that can be posted on GitHub.

Philipp91 avatar Jan 04 '21 13:01 Philipp91

@Philipp91 Yep, please try to provide, and I will investigate this problem, I think something wrong in plugins/loaders/webpack-dev-server, because we are warning /mnt/ and it should not happens

alexander-akait avatar Jan 04 '21 14:01 alexander-akait

# Use WSL 1
cd /mnt/c/Users/....
mkdir watchpack-reproduce
cd watchpack-reproduce
npm init -y && npm install webpack webpack-cli --save-dev
mkdir src
echo Test > index.html
echo 'console.log(window)' > src/index.js
NODE_ENV=development webpack --watch --watch-options-stdin
# Now the 4 errors posted above appear.

Philipp91 avatar Jan 04 '21 15:01 Philipp91

compilation.fileDependencies contains:

[
  '/mnt/c/Users/Philipp/repos/watchpack-reproduce/package.json',
  '/mnt/c/Users/Philipp/repos/watchpack-reproduce/src',
  '/mnt/c/Users/Philipp/repos/watchpack-reproduce/src/index.js',
  '/mnt/c/Users/Philipp/repos/watchpack-reproduce',
  '/mnt/c/Users/Philipp/repos',
  '/mnt/c/Users/Philipp',
  '/mnt/c/Users',
  '/mnt/c',
  '/mnt',
  '/'
]

This may be a new behavior in webpack v5. Is it okay for webpack to tell watchpack to watch all those directories up to the root?

Philipp91 avatar Jan 04 '21 15:01 Philipp91

What is cwd when you run NODE_ENV=development webpack --watch --watch-options-stdin?

alexander-akait avatar Jan 05 '21 12:01 alexander-akait

It's /mnt/c/Users/Philipp/repos/watchpack-reproduce, I ran it quite exactly as posted above.

Philipp91 avatar Jan 05 '21 18:01 Philipp91

It's normal that these directories are watched. The relevant entry is /mnt/c/Users which is watched because the Users directory could theoretically change to a symlink to some different location. Watchpack always watches to complete directory instead of single files for performance reasons.

So the errors are actually irrelevant for watching these the Users directory. It would probably make sense to ignore them internally until these files are actually watched.

sokra avatar Jan 06 '21 14:01 sokra

Okay that makes sense. I find it a bit complex to implement due to the series of DirectoryWatcher instances. Now the instance with path="/mnt/c" needs to know that it should suppress all (?) kinds of errors for all (?) files except the /mnt/c/Users subdirectory (which this particular watcher instance doesn't know about, or at least doesn't that it's special).

Philipp91 avatar Jan 06 '21 19:01 Philipp91

which this particular watcher instance doesn't know about

Each instances knows which files are watched on this instance. So there is a /mnt/c instance where only Users is watched. Suppressing the warnings is probably the easy part. More tricky is that someone might start watching hiberfil.sys at a later time. In this case we need to show the warning at this later time.

sokra avatar Feb 07 '21 16:02 sokra

FWIW I found this thread after running into the same error on Arch Linux. I use pCloud which puts a fuse mount in my home directory and was getting Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/home/whoops/pCloudDrive'. Needless to say, my project isn't in that directory and has no dependency on it. After reading this thread and confirming with some console.logs sure enough WatchPack was trying to lstat that mount point when watching my home directory.

I'm also not sure why it was getting permission denied when it tried, but it was certainly confusing and sent me down some rabbit holes trying to figure out what I misconfigured to make it even try.

Whoops avatar Feb 27 '21 05:02 Whoops

What terminal do you use? I have Windows and I am having the same issue with wsl. Try to use cmd instead. It worked for me. Good luck.

DavidDolyak avatar Mar 06 '21 14:03 DavidDolyak

I am having the same problem. I am in a process of migrating from Gatsby v2 to v3. As far as i understand, this has something to do with WSL2. I just hope that Gatsby team will not forget this issue.

stefanradovanovic avatar Mar 12 '21 04:03 stefanradovanovic

Also running into this. My watch options are only ignoring node_modules so I'm not sure why this would be happening.

jljorgenson18 avatar Mar 30 '21 21:03 jljorgenson18

Plus one running into the same issue with WSL2 + Windows 10. I have root mounted as / in WSL, so:

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/c/DumpStack.log.tmp' Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/c/hiberfil.sys' Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/c/pagefile.sys' Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/c/swapfile.sys'

dmondev avatar Mar 31 '21 20:03 dmondev

Plus another, also with WSL2 + Windows 10

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/DumpStack.log.tmp' Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/hiberfil.sys' Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/pagefile.sys' Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/swapfile.sys'

TravelFiend avatar Apr 01 '21 05:04 TravelFiend

Well i also run into the same error. Running windows 10 x64 bit

Watchpack Error (initial scan): Error: UNKNOWN: unknown error, lstat 'C:$360Section'

obipascal avatar Apr 02 '21 11:04 obipascal

C:$360Section interesting, can you provide path on your project?

alexander-akait avatar Apr 02 '21 11:04 alexander-akait


js

const path = require("path");

// webpack config
module.exports = {
  // partner area main app entry for
  entry: {
    "App.bspa": "./App.bspa.js",
    "App.Admin": "./App.Admin.js",
  },
  output: {
    filename: "[name].min.js",
    path: path.resolve(__dirname, "www/dist"),
  },
  mode: "development",
  watch: true,
  devtool: "eval-source-map",
  watchOptions: {
    ignored: ["**/node_modules"],
    poll: 1000,
    aggregateTimeout: 100,
  },

  module: {
    rules: [
      {
        test: /\.css$/i,
        use: ["style-loader", "css-loader"],
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif)$/i,
        type: "asset/resource",
      },
      {
        test: /\.(woff|woff2|eot|ttf|otf)$/i,
        type: "asset/resource",
      },
    ],
  },
};

obipascal avatar Apr 02 '21 11:04 obipascal

C:$360Section looks like 360 total security dir

obipascal avatar Apr 02 '21 11:04 obipascal

@obipascal I mean path to the project, i.e. C:\\path\to\project and version of WSL

alexander-akait avatar Apr 02 '21 11:04 alexander-akait

C:\Servers\xampp\htdocs\www\bitmoservice\public

obipascal avatar Apr 02 '21 11:04 obipascal

image this is the structure of the project dir

obipascal avatar Apr 02 '21 12:04 obipascal

I have this issue on WSL2 path to project: /mnt/c/Users/username/Documents/Projects/gatsby-blog

 ERROR

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/DumpStack.log.tmp'


 ERROR

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/hiberfil.sys'


 ERROR

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/pagefile.sys'


 ERROR

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/swapfile.sys'

Can reproduce like this

gatsby new my-blog-starter https://github.com/gatsbyjs/gatsby-starter-blog
cd my-blog-starter
gatsby develop

darvesh avatar Apr 12 '21 15:04 darvesh

I kind of wonder what watchpack is doing with swapfile.sys or through which part. Not sure if this help or not, but I started hacking react with 'babel' & 'live-server' running manually via command-line. This works fine.

As the course progress, the instructor introduced webpack, and hence, this problem!

hypotheses avatar Apr 14 '21 04:04 hypotheses

So the errors are actually irrelevant for watching these the Users directory. It would probably make sense to ignore them internally until these files are actually watched.

@sokra It seems like you had a particular workaround in mind. It would be great if you could implement and release that. As you say, the errors are harmless. But they don't look like that, and in the face of any (unrelated) issues with Webpack, people will waste lots of time investigating them, and some of the end up here and even take the time to post screenshots and repro-instructions here, which shows how much time they've previously spent on debugging. We should save that time by suppressing the errors.

Philipp91 avatar Apr 14 '21 07:04 Philipp91

/cc @sokra

alexander-akait avatar Apr 14 '21 10:04 alexander-akait

Same here: WSL 2, win 10

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/d/DumpStack.log.tmp'
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/d/pagefile.sys'

lightmyfire17 avatar Apr 16 '21 10:04 lightmyfire17

Same here: WSL 2, win 10

Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/d/DumpStack.log.tmp'
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/d/pagefile.sys'

I get this as well in windows 10 wsl 2, after converting to gatsby 3 in my project

aaronendsley avatar Apr 16 '21 21:04 aaronendsley

Okay, finally fixed it. The problem is with the path as already someone said. Your project should not be located at /mnt/d/... or somewhere on your windows machine. Instead just make sure you have did this:

  1. cd ~ your path here should be like user@user which means /home/user/ in linux
  2. now make git clone/set up project manually

lightmyfire17 avatar Apr 16 '21 22:04 lightmyfire17