vintasoftware / django-react-boilerplate

Django 5, React, Bootstrap 5 with Python 3 and Webpack project boilerplate
MIT License
1.97k stars 479 forks source link

Error: EISDIR: illegal operation on a directory, open 'webpack-stats.json' #440

Closed 72L closed 4 years ago

72L commented 4 years ago

Describe the bug webpack-stats.json appears to be a directory, but something is attempting to open it as a file.

frontend_1  | Error: EISDIR: illegal operation on a directory, open 'webpack-stats.json'
frontend_1  |     at Object.openSync (fs.js:457:3)
frontend_1  |     at Object.writeFileSync (fs.js:1298:35)
frontend_1  |     at Plugin.writeOutput (/app/node_modules/webpack-bundle-tracker/lib/index.js:124:6)
frontend_1  |     at compile (/app/node_modules/webpack-bundle-tracker/lib/index.js:58:10)
frontend_1  |     at SyncHook.eval (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:5:1)
frontend_1  |     at SyncHook.lazyCompileHook (/app/node_modules/tapable/lib/Hook.js:154:20)
frontend_1  |     at /app/node_modules/webpack/lib/Compiler.js:665:23
frontend_1  |     at AsyncSeriesHook.eval [as callAsync] (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:4:1)
frontend_1  |     at AsyncSeriesHook.lazyCompileHook (/app/node_modules/tapable/lib/Hook.js:154:20)
frontend_1  |     at Compiler.compile (/app/node_modules/webpack/lib/Compiler.js:662:28) {
frontend_1  |   errno: -21,
frontend_1  |   syscall: 'open',
frontend_1  |   code: 'EISDIR',
frontend_1  |   path: 'webpack-stats.json'
frontend_1  | }

In the backend:

backend_1   | Internal Server Error: /
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.6/site-packages/webpack_loader/loader.py", line 26, in _load_assets
backend_1   |     with open(self.config['STATS_FILE'], encoding="utf-8") as f:
backend_1   | IsADirectoryError: [Errno 21] Is a directory: '/home/user/app/../webpack-stats.json'
backend_1   | 
...

To Reproduce Steps to reproduce the behavior:

  1. Install following README instructions
  2. Run docker-compose up
  3. Look at the logs

Expected behavior There should be no errors when following the setup instructions without any modification.

Screenshots image

Desktop (please complete the following information):

vanessa commented 4 years ago

Hi @72L, thanks for bringing this issue. We're working on a fix now.

This happens because docker tries to bind webpack-stats.json on backend before this file is created by the frontend, so it ends up creating a directory. A workaround while we don't push a fix is:

  1. Remove the directory created by docker: rm -rf webpack-stats.json/
  2. Create this file manually: echo {} >> webpack-stats.json
  3. Run docker-compose up

After the frontend container runs, if you check webpack-stats.json, it should have new content with info about the bundle.

72L commented 4 years ago

Thanks for the response, but it doesn't seem to work:

$ rm -rf webpack-stats.json/
$ echo {} >> webpack-stats.json
$ docker-compose up
Starting frontend_1 ... done
Starting db_1       ... done
Starting broker_1   ... done
Starting result_1   ... done
Starting celery_1   ... 
Starting backend_1  ... error

ERROR: for backend_1  Cannot start service backend: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/.../webpack-stats.json\\\" to rootfs \\\"/var/lib/docker/overlay2/78fe24f7b5a9851d7b0a430a0e046a7135e9ef8e7a83700ffee535Starting celery_1   ... done
 Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

ERROR: for backend  Cannot start service backend: OCI runtime create failed: container_linux.go:346: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/.../webpack-stats.json\\\" to rootfs \\\"/var/lib/docker/overlay2/78fe24f7b5a9851d7b0a430a0e046a7135e9ef8e7a83700ffee535faf632c3d7/merged\\\" at \\\"/var/lib/docker/overlay2/78fe24f7b5a9851d7b0a430a0e046a7135e9ef8e7a83700ffee535faf632c3d7/merged/home/user/webpack-stats.json\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
vanessa commented 4 years ago

@72L Got it, seems like we still have something from the webpack-stats.json directory in this container.

Does ls -d */ | grep webpack return anything? If yes, the removal probably didn't work. Does it break if you try to build the frontend and backend again, then try to run them?

72L commented 4 years ago

Thanks, building it again helped!