watchpack
watchpack copied to clipboard
Watchpack Error (initial scan): Error: EACCES: permission denied, lstat '/mnt/c/...'
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?
Can you provide structure of your project?
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 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
# 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.
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?
What is cwd
when you run NODE_ENV=development webpack --watch --watch-options-stdin
?
It's /mnt/c/Users/Philipp/repos/watchpack-reproduce
, I ran it quite exactly as posted above.
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.
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).
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.
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.log
s 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.
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.
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.
Also running into this. My watch options are only ignoring node_modules so I'm not sure why this would be happening.
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'
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'
Well i also run into the same error. Running windows 10 x64 bit
Watchpack Error (initial scan): Error: UNKNOWN: unknown error, lstat 'C:$360Section'
C:$360Section
interesting, can you provide path on your project?
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",
},
],
},
};
C:$360Section
looks like 360 total security dir
@obipascal I mean path to the project, i.e. C:\\path\to\project
and version of WSL
C:\Servers\xampp\htdocs\www\bitmoservice\public
this is the structure of the project dir
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
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!
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.
/cc @sokra
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'
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
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:
-
cd ~
your path here should be likeuser@user
which means/home/user/
in linux - now make git clone/set up project manually