-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
11ty gives EPERM error when trying to rename _site
to .11ty-vite
#22
Comments
Hmm, do you have a repo to reproduce? I did just try to reproduce unsuccessfully on Windows with @11ty/[email protected] and @11ty/[email protected] |
I have the same issue, although with a custom Running on Linux, e.g. this CI job, the build runs as expected. |
@aarongoldenthal I filed your issue at #23, with a few workarounds there. |
Thanks @zachleat. Looking at the plugin code I can see the potential problem with "public", although in my case I think I also have the issue here. Setting Looking more closely, the plugin is failing here, and it appears to be due to nodejs/node#29481. I do get successful results with the same config on Linux. My config:
|
To see if it made a difference, I checked a few other configurations:
...but got the same results. |
@zachleat The same error. My try to set up eleventy and vite-plugin https://github.com/kalininmax/eleventy-starter I can start dev server with |
@zachleat Sorry for the late response, I have created a test repo to reproduce the error here: https://github.com/haid0109/test-11ty-vite-plugin Running |
I'm also experiencing this issue on Windows. Looking at the node documentation for rename, I'm surprised that it is only an issue on Windows, and apparently not for everyone. The documentation states that "if there is a directory at |
A good description of how the current behavior on Windows doesn't match the documentation: nodejs/node#21957 (comment). That issue is closed as addressed in nodejs/node@e7ca398, though surprisingly the revised documentation still doesn't explain the current behavior properly. At the same time, more appropriate nodejs/node#22014 was closed. Anyhow, here we need to deal with the current behavior on Windows, which is not documented as of now.
This workaround works like a charm. @zachleat would you mind if I send a PR? |
We're experiencing the same issue on our project.
Would be great to get a PR in to fix the issue. In the meantime, @anantakrishna, would you mind sharing the specific code you used for the workaround? I tried creating it myself after seeing @sknoslo's comment, but was having trouble getting it to work. (Admittedly, I'm not really a regular js developer so am a little out of my depth here.) |
In async runBuild(input) {
let tmp = path.resolve(".", this.options.tempFolderName);
await fsp.mkdir(tmp, { recursive: true });
+ await fsp.rm(tmp, { recursive: true, force: true });
await fsp.rename(this.outputDir, tmp); It's worth noting that the same Besides this, I had to change a bit further down the method. viteOptions.build.rollupOptions.input = input
.filter(entry => !!entry.outputPath) // filter out `false` serverless routes
.filter(entry => (entry.outputPath || "").endsWith(".html")) // only html output
.map(entry => {
- if(!entry.outputPath.startsWith(this.outputDir + path.sep)) {
+ if(!entry.outputPath.startsWith(this.outputDir + '/')) {
throw new Error(`Unexpected output path (was not in output directory ${this.outputDir}): ${entry.outputPath}`);
} In my experience, |
Thank you @anantakrishna! That fix worked for me, though I also had to change |
There is a confirmation for this in the Eleventy repo: https://github.com/11ty/eleventy/blob/8e88b0786b4330182020dd0a7bc602ff774869f6/src/TemplatePermalink.js#L194 return normalize(outputDir + "/" + uri); Thus, the path is combined using a forward slash, and not the I hope that I don't miss anything. |
Hi, I've created a pull request for this issue and for #35 building on @anantakrishna . In particular we need to catch the Vite build error case without throwing another directory rename error, and I use path.normalize to ensure the correct path separator is checked. |
Thanks, @1619digital. I wonder where's Zach… |
Here is the patch-package until it's fixed upstream: diff --git a/node_modules/@11ty/eleventy-plugin-vite/EleventyVite.js b/node_modules/@11ty/eleventy-plugin-vite/EleventyVite.js
index cb546a0..5e785ad 100644
--- a/node_modules/@11ty/eleventy-plugin-vite/EleventyVite.js
+++ b/node_modules/@11ty/eleventy-plugin-vite/EleventyVite.js
@@ -49,7 +49,10 @@ class EleventyVite {
let tmp = path.resolve(".", this.options.tempFolderName);
await fsp.mkdir(tmp, { recursive: true });
- await fsp.rename(this.outputDir, tmp);
+
+ // see https://github.com/11ty/eleventy-plugin-vite/issues/22#issuecomment-1539443517
+ await fsp.cp(this.outputDir, tmp, { recursive: true });
+ await fsp.rm(this.outputDir, { recursive: true });
try {
let viteOptions = lodashMerge({}, this.options.viteOptions);
@@ -59,11 +62,13 @@ class EleventyVite {
.filter(entry => !!entry.outputPath) // filter out `false` serverless routes
.filter(entry => (entry.outputPath || "").endsWith(".html")) // only html output
.map(entry => {
- if(!entry.outputPath.startsWith(this.outputDir + path.sep)) {
+ // see https://github.com/11ty/eleventy/blob/8e88b0786b4330182020dd0a7bc602ff774869f6/src/TemplatePermalink.js#L194
+ //
+ if(!entry.outputPath.startsWith(this.outputDir + '/')) {
throw new Error(`Unexpected output path (was not in output directory ${this.outputDir}): ${entry.outputPath}`);
}
- return path.resolve(tmp, entry.outputPath.substr(this.outputDir.length + path.sep.length));
+ return path.resolve(tmp, entry.outputPath.substr(this.outputDir.length + '/'.length));
});
viteOptions.build.outDir = path.resolve(".", this.outputDir);
@@ -71,7 +76,9 @@ class EleventyVite {
await buildVite(viteOptions);
} catch(e) {
console.warn( `[11ty] Encountered a Vite build error, restoring original Eleventy output to ${this.outputDir}`, e );
- await fsp.rename(tmp, this.outputDir);
+ // see https://github.com/11ty/eleventy-plugin-vite/issues/22#issuecomment-1539443517
+ await fsp.cp(tmp, this.outputDir, { recursive: true });
+ await fsp.rm(tmp, { recursive: true });
throw e;
} finally {
// remove the tmp dir |
HI! I'm having the same error using Eleventy 2.0.1 and eleventy-plugin-vite 4.0.0. (I see the MR is still on wait) EPERM: operation not permitted, rename 'C:\PROJECTS\CNSA-FR.11ty-vite' -> 'C:\PROJECTS\CNSA-FR_site' (via Error) |
Still running in to this issue |
My patch still works |
If anybody here is up to upgrading to Eleventy v3 and checking out the latest alpha release of this plugin to test, if this bug still exists on Windows, would be awesome. Find the latest docs on the alpha branch and let me know if I can assist. If upgrading is not currently possible for you, it would also be helpful if you clone this repos |
I'm not ready to switch right now, but as soon as I do, will report back. Thank you for your efforts! |
@anantakrishna if you just have a few minutes you could try the example. If you have Node 18 or higher installed, just clone this repos' alpha branch and run:
Now you can check if the project builds successfully.
Now you can check if development server runs. |
Done it. Seems all is fine. At least no issues in the console.
|
Awesome, thank you! Happy to hear more reports. |
setup: windows 10, eleventy v2.0.0-beta.1, Node v16.14.1, vscode v1.74.3
code in
.eleventy.js
:output of running build:
running 11ty in debug mode does not give any more useful info for solving the problem:
debug mode output logs
I've tried running terminal in admin, closing vscode and opening it again, clearing vscode cache (as per recommendations online), to no avail.
Seems like a problem with the vite plugin.
The text was updated successfully, but these errors were encountered: