Hi, after installing gatsby globally in my WSL terminal i'm receiving the below error when running
gatsby new blog https://github.com/gatsbyjs/gatsby-starter-hello-world
1.Install WSL Ubuntu 18.04
2.Curl install npm
3.Install gatsby with npm install -g gatsby-cli
4.New gatsby app with gatsby new blog https://github.com/gatsbyjs/gatsby-starter-hello-world
Create a new app without an errors
Logs below
gareth@DESKTOP-5ANEVFU:~/blog-website/services$ gatsby new blog https://github.com/gatsbyjs/gatsby-starter-hello-world
info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-hello-world.git
Cloning into 'blog'...
remote: Enumerating objects: 16, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 16 (delta 0), reused 9 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), done.
success Created starter directory layout
info Installing packages...
✔ Which package manager would you like to use ? › npm
info Preferred package manager set to "npm"
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/gareth/blog-website/services/blog/node_modules/babel-runtime
npm ERR! dest /home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/babel-runtime' -> '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'
npm ERR! [OperationalError: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/babel-runtime' -> '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'] {
npm ERR! cause: [Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/babel-runtime' -> '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/home/gareth/blog-website/services/blog/node_modules/babel-runtime',
npm ERR! dest: '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'
npm ERR! },
npm ERR! stack: "Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/babel-runtime' -> '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/home/gareth/blog-website/services/blog/node_modules/babel-runtime',
npm ERR! dest: '/home/gareth/blog-website/services/blog/node_modules/.babel-runtime.DELETE',
npm ERR! parent: 'blog'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/gareth/.npm/_logs/2020-03-01T11_19_51_193Z-debug.log
ERROR
Command failed with exit code 243: npm install
Error: Command failed with exit code 243: npm install
- error.js:56 makeError
[lib]/[gatsby-cli]/[execa]/lib/error.js:56:11
- index.js:114 handlePromise
[lib]/[gatsby-cli]/[execa]/index.js:114:26
- task_queues.js:97 processTicksAndRejections
internal/process/task_queues.js:97:5
System:
OS: Linux 4.4 Ubuntu 18.04.4 LTS (Bionic Beaver)
CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 13.9.0 - ~/.nvm/versions/node/v13.9.0/bin/node
Yarn: 1.22.0 - /usr/bin/yarn
npm: 6.13.7 - ~/.nvm/versions/node/v13.9.0/bin/npm
Languages:
Python: 2.7.17 - /usr/bin/python
npmGlobalPackages:
gatsby-cli: 2.9.0
@garethiv Also using WSL (Ubuntu 18.04.4)
gatsby: v2.19.23 and 2.19.22 (fail with error)
I started seeing:
warn Error persisting state: EACCES: permission denied, rename '/mnt/d/Git/Tailwind/tailwind-gatsby-example/www/site/.cache/redux' ->
I downgraded my version of Gatsby (v2.19.21) and it started working.
@talves that worked thanks a lot man!
For the gatsby team ref:
The issue is resolved as @talves pointed out by downgrading gatsby v to 2.19.21. It's worth pointing out though that I still see warnings in the logs (below) and can see 2 reduxcache folders being created (unsure whether this is expected behaviour or not).
warn Error persisting state: EACCES: permission denied, rename 'reduxcachex3k3tg' ->
warn Error persisting state: EACCES: permission denied, rename
I'm also getting this error message on my WSL
warn Error persisting state: EACCES: permission denied, rename 'reduxcacheN0NDd9' -> '/home/.../Development/.../.docz/.cache/redux'
I'm trying to figure out if the .cache/redux reports are the same problem as the original report (despite the downgrade being a workaround). I'm the one who worked on the redux cache recently and the messages from the original issue here seem unrelated to those changes.
One thing you could try is to make sure that none of the folders have permission problems and that Gatsby isn't called with elevated (sudo / root) priviledges. (And if you do, every call should be using the same user/permissions, but please use a regular user to run gatsby).
To get this try to sudo rm -rf node_modules ~/.npm public .cache (from the project root) and then to run yarn; gatsby build. If the problem persists then the problem might be somehow related to the /tmp folder or the .cache folder's original permissions and I'm not quite sure what might cause that.
Could somebody facing this problem please try hard dropping those folders and rerunning the build? Thanks!
I didn't have the exact same problem but I did encounter the "error persisting state" problem (one message is printed to stdout every second) in development mode (but with the gatsby-remark-katex plugin) and also had tons of of reduxstate* directories created (looks like one "error persisting state" message correspond to one reduxstate* directory created). Maybe https://github.com/gatsbyjs/gatsby/issues/20538 is relevant?
@huy-nguyen fwiw, the solution to your problem as posted in that issue does not seem to relate to cache handling at all. That said, the cache basically creates a temporary folder, stores the cache there, renames current cache to old, renames tmp folder to current cache, then drops old cache. If either of the first two renames fails then it's likely the tmp folder is left behind, yeah. But you're saying this is resolved by options.strict = "ignore"? Because that's very unexpected to me.
@pvdz doing a sudo rm -rf node_modules ~/.npm public .cache and upgrading back to 2.9.23 does work for the .cache rename error
Next time, try to remove them one by one, see if there's a particular folder causing this.
Also, do you know if you ever run nodejs stuff through sudo? (Or as root through other ways). That could cause this for a million different reasons.
I would never run nodejs commands through sudo, so that was not the case. I thought I should've ran those separately, but unfortunately, I already spent too much time chasing the error yesterday and figuring out what version was the issue.
I'm 🤞 there will not be a next time. If I do see it again, I will do one at a time to get the culprit for you.
@garethiv can you check whether removing the folders solves your problem as well? One by one would be nice (and if that doesn't work, all at once, just in case) to help triage the source of this problem. Permission problems have a wide breadth of origins so it's a little hard to tell what might cause it. But once permissions are inconsistent, it's hard to get things done right.
@pvdz it does seem odd that we are fine with all those permissions with the change being ^2.9.22, so can't you determine the culprit from that change on the redux cache
@talves well, I wrote that whole change. There's a few things at play but at its core it creates a new tmp folder, using a nodejs built in function for that. Then it generates a bunch of files inside that folder. Once that's done it will _rename_ the existing redux folder. It will _rename_ the tmp folder to be the new redux folder (basically moving it there). It will then go ahead to rm -rf (rimraf) the old redux folder. It will also try to remove the legacy file, in case that matters.
So there are five places where this error may occur, as far as the change goes;
.cache/redux folder to .cache/redux.bakxxx (maybe the existing folder has the wrong permissions or the .cache folder has the wrong permissions).cache/redux folder (this would fail if the previous rename failed, or if the folder we created has incorrect permissions, or outside potentially when the tmp folder has weird permissions preventing a rename)I'm a little surprised there's a few people reporting this, but it seems everybody that's reporting it is on WSL. So my hunch would be that the tmp folder does not get the correct permissions. Maybe you can check this?
@pvdz hey I tried to delete one by one following the bellow steps:
1-Deleted .cache & ran gatsby develop > same error message & creation of redux folders
2-Deleted node_modules & ran npm install > got a bunch off different permission errors on something else this time (logs below) - I switched over to Windows CMD and everything worked fine (install & gatsby develop & no redux folders being created)
This makes me think it's a problem with npm permissions in WSL but it's not clear to me why i'm now not able to run npm install at all nor why gatsby develop worked fine after downgrading
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/postcss
npm ERR! dest /home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/.postcss.DELETE
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/postcss' -> '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/.postcss.DELETE'
npm ERR! [OperationalError: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/postcss' -> '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/.postcss.DELETE'] {
npm ERR! cause: [Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/postcss' -> '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/.postcss.DELETE'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/postcss',
npm ERR! dest: '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/.postcss.DELETE'
npm ERR! },
npm ERR! stack: "Error: EACCES: permission denied, rename '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/postcss' -> '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/.postcss.DELETE'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/postcss',
npm ERR! dest: '/home/gareth/blog-website/services/blog/node_modules/css-loader/node_modules/.postcss.DELETE',
npm ERR! parent: 'css-loader'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
Very strange indeed :( One option is that the new changes to the cache inadvertedly cause incorrect permissions to be set somewhere in the chain. But they don't (or at least, shouldn't) change anything in the node_modules folder. It might just be a red herring and caused by a different change in the same set (although I remember there aren't that many changes for that patch bump)
I wonder what's trying to rename folders to add the suffix .DELETE to it. That's definitely not my change. You posted a log that contained it, like first message, but for a different folder.
Could you paste the debug.log log that npm prints? Or well, I'm interested in the stack trace. What's the source of this rename call.
I'm running gatsby with netlify dev inside of the VS Code terminal on macOS Catalina 10.15.3. Shortly after the project starts up (usually with gatsby clean && netlify dev) I get an error like the one below and it continues creating "reduxcache" folders until I close the terminal
error Generating development JavaScript bundle failed
ENOENT: no such file or directory, open '/Users/williamfendler/Sites/xxxxxx/.cache/app.js'
failed Re-building development bundle - 0.069s
warning Error persisting state: ENOENT: no such file or directory, rename 'reduxcachem7w4vQ' -> '/Users/williamfendler/Sites/xxxxxx/.cache/redux'

All of my work right now depends on netlify dev so I haven't tried using gatsby develop without Netlify CLI to know if that's part of the problem. I also haven't tried recreating it with an example repo. Until I have a minute to do those I thought I'd chime in with a few details in case it's helpful!
It might also be worth noting that Netlify CLI is constantly competing with Gatsby to log info to the terminal so it could also be hiding some more useful errors but I'm not sure how to surface those. Let me know if you have any questions or suggestions that could help solve this.
@pvdz the explanation above by @wfendler was the same exact thing happening in WSL, so it looks like it is not contained to just WSL, since he is on a Mac.
So I deleted the node modules folder again and ran npm install - here is the complete npm log
2020-03-05T09_02_01_119Z-debug.log
+1, same issue on wsl
@wfendler
and it continues creating "reduxcache" folders until I close the terminal
I hope you don't mean in like an infinite loop? That'd be pretty bad and a little weird. (Unless gatsby gets auto-restarted by something, every time)
/app.js is unrelated to the cache, though.
One thing I noticed now is this line
warning Error persisting state: ENOENT: no such file or directory, rename 'reduxcachem7w4vQ' -> '/Users/williamfendler/Sites/xxxxxx/.cache/redux'
Why is the "source" not an absolute path? I see the same in an earlier report above so that's not a mac thing. I wonder if that's just a loggging artefact or the actual problem (as the path ought to be in /tmp).
@wfendler I suppose in your case it's all netlify so there's no point to delete the ~/.npm or node_modules. That makes this problem even stranger, since that means it's not necessarily permission related.
@garethiv thank you for that report. Something cleared up that I somehow missed. There are two issues at play here; one is when installing npm and the other is the redux cache problem. They are conflating but I'm convinced they are separate issues since in the first case Gatsby never gets to run at all.
As such I'm going to close this ticket and open two new ones. Please continue your discussion in the issue that's appropriate for you.
1: WSL npm install problem: https://github.com/gatsbyjs/gatsby/issues/21980
2: reduxcache problem: https://github.com/gatsbyjs/gatsby/issues/21982
Go to #21980 if you are running into _npm_ problems, where Gatsby never starts at all.
Go to #21982 if you can run gatsby build or gatsby develop but it fails with reduxcache related error messages near the end (when the redux store gets saved).
Thank you. Closing this issue permanently to prevent more confusion.
(There is still the possibility that "renaming", through nodejs or otherwise, is just broken on WSL. But since npm is hit by this as well I don't expect us to be doing anything crazy to trigger this kind of problem suddenly. It's just that in both reports the problem occurs at the renaming step.)
Most helpful comment
I'm running gatsby with
netlify devinside of the VS Code terminal on macOS Catalina 10.15.3. Shortly after the project starts up (usually withgatsby clean && netlify dev) I get an error like the one below and it continues creating "reduxcache" folders until I close the terminalAll of my work right now depends on
netlify devso I haven't tried usinggatsby developwithout Netlify CLI to know if that's part of the problem. I also haven't tried recreating it with an example repo. Until I have a minute to do those I thought I'd chime in with a few details in case it's helpful!It might also be worth noting that Netlify CLI is constantly competing with Gatsby to log info to the terminal so it could also be hiding some more useful errors but I'm not sure how to surface those. Let me know if you have any questions or suggestions that could help solve this.