Skip to content
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

git serve can't restart when file changes #1379

Closed
SimonTart opened this issue Jun 10, 2016 · 49 comments
Closed

git serve can't restart when file changes #1379

SimonTart opened this issue Jun 10, 2016 · 49 comments

Comments

@SimonTart
Copy link

SimonTart commented Jun 10, 2016

I built gitbook serve success, but when I change file the gitbook serve restart fail.
Here is the error message.

Starting server ...
Serving book on http://localhost:4000
Restart after change in file SUMMARY.md

Stopping server
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, lstat 'G:\gitbook-touchevent\_book'
    at Error (native)

node version:4.4.2
gitook version: 2.2.0

@thoemmi
Copy link

thoemmi commented Jun 15, 2016

I'm experiencing the same issue, though the error message is slightly different:

Error: EPERM: operation not permitted, mkdir 'D:\testbook_book'

Node: 4.4.5
Gitbook: 2.2.0

@ExByt3s
Copy link

ExByt3s commented Jul 30, 2016

I have the same problem

 gitbook serve
Live reload server started on port: 35729
Press CTRL+C to quit ...

info: 7 plugins are installed
info: loading plugin "livereload"... OK
info: loading plugin "highlight"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 1 pages
info: found 0 asset files
info: >> generation finished with success in 1.0s !

Starting server ...
Serving book on http://localhost:4000
Restart after change in file SUMMARY.md

Stopping server

Error: EPERM: operation not permitted, mkdir 'C:\Users\cleopatra\Desktop\abum_code\_book'

Microsoft Windows [Versión 10.0.10586]

node -v
v4.4.7

gitbook -V
CLI version: 2.3.0
GitBook version: 3.2.0

@eminoda
Copy link

eminoda commented Aug 10, 2016

md file changed, operation not permitted

@marshhj
Copy link

marshhj commented Aug 20, 2016

I meet tooooooo!!

@CoDEmanX
Copy link

CoDEmanX commented Sep 14, 2016

Having this problem too.

  • NodeJS v6.2.0
  • CLI version: 2.2.0
  • GitBook version: 3.2.0

Starting server ...
Serving book on http://localhost:4000
Restart after change in file SUMMARY.md

Stopping server

Error: EPERM: operation not permitted, mkdir 'C:...\gitbook3\Manual_book'

@leohxj
Copy link

leohxj commented Sep 18, 2016

Same problem:

Stopping server
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, lstat 'F:\leo-workspace\share\gitbook\gitbook-demo\_book'
    at Error (native)

F:\leo-workspace\share\gitbook\gitbook-demo>gitbook -V
CLI version: 2.3.0
GitBook version: 3.2.0

F:\leo-workspace\share\gitbook\gitbook-demo>node --version
v4.2.0

F:\leo-workspace\share\gitbook\gitbook-demo>npm --version
3.10.6

@craigbutcher
Copy link

Same issue here.

  • Windows 7 N
  • NodeJS v6.5.0
  • CLI version: 2.3.0
  • GitBook version: 3.2.0
Starting server ...
Serving book on http://localhost:4000
Restart after change in file environments\list-of-environments.md

Error: EPERM: operation not permitted, open 'C:\Users\craig\playground\gitbook\_book\456\README.md'

I'm not sure why it is trying to access the README.md even the file is available?

@CliffHan
Copy link

CliffHan commented Oct 20, 2016

same issue, EPERM on mkdir operation, windows 10

@budiadiono
Copy link

budiadiono commented Oct 24, 2016

I have same issue with Windows 10. While waiting for this issue get resolved, I've created gulp task using browser-sync and gulp-run to replace gitbook serve in my project:

// gulpfile.js

var browserSync = require('browser-sync');
var gulp = require('gulp')
var run = require('gulp-run')

gulp.task('browser-sync', function() {
    browserSync({
        server: {
            baseDir: "./docs/_book"
        }
    });
});

gulp.task('build-doc', function () {
    run('npm run docs:build').exec('', function() {
        run('echo docs:build DONE!').exec().pipe(browserSync.reload({stream:true}));
    });

})

gulp.task('watch', function() {
    gulp.watch('./docs/**/*.md', ['build-doc']);
})

gulp.task('default', ['build-doc', 'browser-sync', 'watch']);
// package.json

"scripts": {
  "docs:build": "cd docs && gitbook build",
  ... 

Maybe this could help someone life. Or any better idea?

UPDATE
This one: https://gist.github.com/budiadiono/dd409e2168c801c9e7429766ee0101c3 is much better.

@mlidbom
Copy link

mlidbom commented Oct 27, 2016

Same problem as #1309?

@mlidbom
Copy link

mlidbom commented Oct 27, 2016

I have a branch on a public repository where I see this problem every time any file is updated: https://github.com/mlidbom/AsciiDocScratch/tree/gitbook-serve-bug-repro

Hope this might help with tracking down the problem.

@budiadiono
Copy link

In Windows 10, the problem gone when I run gitbook serve from git bash maybe this is Windows issue with bash command instead?

I'm using these versions:

Gitbook CLI version: 2.3.0
GitBook version: 3.2.2
Node v6.9.1

@CliffHan
Copy link

CliffHan commented Oct 31, 2016

To budiadiono:
I just tried git bash, and the problem still exists with the same response.
"Error: EPERM: operation not permitted, mkdir '....._book'"

Gitbook CLI version: 2.3.0
GitBook version: 3.2.2
Node v4.4.7

@budiadiono
Copy link

Hi @CliffHan, what is the emulator version of gitbash did you use? My machine installed with git version 2.5.1.windows.1 along with gitbash that using mintty emulator version 2.0.3 (x86_64-pc-msys). Maybe to workaround you want to use msys2 instead?

@CliffHan
Copy link

Hi @budiadiono , my git version is 2.9.2 for windows.
bash version:
GNU bash, version 4.3.46(2)-release-(x86_64-pc-msys)
msys2? Maybe I'd like to give a try.

@CliffHan
Copy link

CliffHan commented Nov 4, 2016

Last Friday it worked normally, and today it failed again.
I DO think it's some kind of permission issue, with some gitbook/nodejs service or service they used.

@cortexcompiler
Copy link

cortexcompiler commented Nov 8, 2016

I see this issue on Windows also. I have seen some threads related to grunt that say you can avoid the problem by running the CMD window as administrator. I am not a big fan of that solution but it may work for some.

@ghost
Copy link

ghost commented Dec 15, 2016

+1 fails quite often, Windows 7

@githoniel
Copy link

+1 fails quite often, Windows 10

@iulo
Copy link

iulo commented Mar 13, 2017

any update?

@jptissot
Copy link

jptissot commented Mar 15, 2017

Same for me, I see this error everytime I save a file.

I'm using

  • Windows 10 Latest update
  • VSCode 1.10.2 integrated Powershell
  • node v7.7.2.
  • GitBook 3.2.2

@teaho2015
Copy link

Same problem.

  • Windows version: 8.1
  • node version: v6.9.4
  • Gitbook version: 3.2.2

@marekgregor
Copy link

I suppose issue relates to weird inability to change read-only flag on folder in Windows
I haven't fixed the cause of this problem, but I have one very dumb workaround to the consequence - just create and run this .bat file in the console window - it will automatically call gitlab serve command after it will crash:

@Echo off
:Start
call gitbook serve
goto Start

@mistory
Copy link

mistory commented Apr 25, 2017

same, windows 7
CLI version: 2.3.0
GitBook version: 3.0.2
node version: 4.4.4

@yufengwang
Copy link

any solutions? this really bother me a lot. I have to go back to my Ubuntu again...

@wz5891
Copy link

wz5891 commented May 24, 2017

the old version 2.6.7 can live relaod on win10

gitbook fetch 2.6.7
gitbook -v 2.6.7
gitbook serve --gitbook=2.6.7

@ska2342
Copy link

ska2342 commented Aug 3, 2017

I'd like to add another mee too. This is keeping us from starting with Gitbook at all, because the majority of our authors is on Windows and the local server crashes on every single change.

@creatop-john
Copy link

Here's a solution

  1. gitbook serve
  2. delete _book folder once
  3. now each time you change the md file, the server will stop and start over again and again

@wangluzhou
Copy link

@creatop-john Thanks, it solved my problem!

@jptissot
Copy link

For us, the issue turned out to be a blank .md file, after inserting dummy data in it, gitbook serve worked properly.

@ouweiya
Copy link

ouweiya commented Sep 25, 2017

@creatop-john Thank you for running successfully, but the refresh is too slow to affect the writing experience.

@tonnyone
Copy link

@creatop-john Thank you for running successfully

@SkyRockMoon
Copy link

I am still seeing problems with this:

Windows 7 SP1 64-bit
Node v8.9.4
npm 5.6.0

Starting from scratch this is what I did:
npm install gitbook-cli -g
gitbook init ./gitbooktest
gitbook serve

When I saved a change to README.md it breaks. See below.


> C:\Code\docs\gitbooktest>gitbook serve
> Live reload server started on port: 35729
> Press CTRL+C to quit ...
> 
> info: 7 plugins are installed
> info: loading plugin "livereload"... OK
> info: loading plugin "highlight"... OK
> info: loading plugin "search"... OK
> info: loading plugin "lunr"... OK
> info: loading plugin "sharing"... OK
> info: loading plugin "fontsettings"... OK
> info: loading plugin "theme-default"... OK
> info: found 1 pages
> info: found 0 asset files
> info: >> generation finished with success in 0.6s !
> 
> Starting server ...
> Serving book on http://localhost:4000
> Restart after change in file README.md
> 
> Stopping server
> events.js:183
>       throw er; // Unhandled 'error' event
>       ^
> 
> Error: EPERM: operation not permitted, lstat 'C:\Code\docs\gitbooktest\_book'
> 
> C:\Code\docs\gitbooktest>node -v
> v8.9.4
> 
> C:\Code\docs\gitbooktest>npm -v
> 5.6.0

@DexterHaslem
Copy link

I'll dogpile in as well, just curious what the status of this is.
Are there plans to bump dependencies like some of the forks have? is it just waiting for someone to PR?

@frantzyy
Copy link

I had the same issue but noticed that my SUMMARY.md didn't include all the links to pages I was trying to access. Once I added them I was able update files and have the "gitbook serve" restart successfully. Might not be the same issue you all are seeing just wanted to point that out.

@localdevm
Copy link

Same here . While @creatop-john 's solution worked at first, when using chapters I am unable to delete the /book even though I have full admin privileges.

@wslx520
Copy link

wslx520 commented Jul 7, 2018

Two years past, the bug is still here, what have happened?!

@unzoa
Copy link

unzoa commented Jul 10, 2018

really

@wikilike7
Copy link

Same error, Anyone have new solution?

@mulder21c
Copy link

I have same issue also.

I tried the steps below, and I could see that they would be reloaded without problems.

run gitbook serve

$ gitbook serve

on another terminal

$ rm ./_book -r -f

modify & save some files

then, reload & livereload work well.

Restart after change in file README.md

Stopping server
info: 7 plugins are installed
info: loading plugin "livereload"... OK
info: loading plugin "highlight"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 1 pages
info: found 0 asset files
info: >> generation finished with success in 0.6s !

Starting server ...
Serving book on http://localhost:4000

@localdevm
Copy link

This is unfortunately only a temporary solution @mulder21c

@tehcon
Copy link

tehcon commented Oct 15, 2018

Win10 64bit
I run "gitbook serve" in an Administrator cmd and it works well

@wslx520
Copy link

wslx520 commented Oct 16, 2018

Maybe someone need: alternative solution for this, vuepress, new, easy to use, more powerful and well maintained

@TomYeoman
Copy link

TomYeoman commented Dec 2, 2018

I still have the same error, with none of the solutions working.. Is there an official solution to this it's blocking me from using gitbook :(

e/

Running gitbook serve and then deleting _book seems to sometimes work for me, other times it doesn't. ( node 10.10.0, npm 6.4.1

@samperumal
Copy link

Solution by @mulder21c works, but needs to be done every time the server is started.

@yuh926323
Copy link

It works for me and well. @mulder21c

  • Windows 10 (64-bit)
  • NodeJS v8.12.0
  • CLI version: 2.3.2
  • GitBook version: 3.2.3

@Vivianluolita
Copy link

It's seems like that the only way is to add virtual data,hope others can deal it.

@mulder21c
Copy link

mulder21c commented Feb 8, 2019

I modified the serve.js in gitbook to reduce the inconvenience of deleting the _book directory each time the server started, and I found that it works fine.

I hope this will help those who are having problems like me.

modify the c:\Users\{user name}\.gitbook\versions\3.2.3\lib\cli\serve.js file as follows.

var Server = require('./server');
var watch = require('./watch');

// load fs, path module
var fs = require('fs');
var path = require('path');

...

  .then(function() {
    if (!hasWatch) {
      return waitForCtrlC();
    }

    return watch(book.getRoot())
    .then(function(filepath) {
      // set livereload path
      lrPath = filepath;
      console.log('Restart after change in file', filepath);
      console.log('');

      // add this scripts
      fs.readdir(outputFolder, (err, files) => {
        for (const file of files) {
          fs.unlink(path.join(outputFolder, file), err => {});
        }
      });

      return generateBook(args, kwargs);
    });
  });

@rougeyan
Copy link

unkonwn reason in win10, but i find we need to keep the built file directory in a service state.

example:
here is a temporary way to solve this problem;
step:

  1. install http-server npm install http-server -g ;
  2. cd to directory _book and run commond http-server;
  3. open a new shell/bash and cd to our file directory to run gitbook serve;

you will find the problem is solved;

thanks for @lguoliang @JaydenShum

win10/win8
node version: 8.12.0
CLI version: 2.3.2
GitBook version: 3.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests