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

[3.0 Beta] Having a data folder in root breaks build #5851

Closed
maxswjeon opened this issue Apr 15, 2024 · 7 comments
Closed

[3.0 Beta] Having a data folder in root breaks build #5851

maxswjeon opened this issue Apr 15, 2024 · 7 comments
Assignees
Labels
[cant-reproduce] If an issue cannot be reproduced

Comments

@maxswjeon
Copy link

maxswjeon commented Apr 15, 2024

Link to reproduction

maxswjeon/payload-data-folder-build-repoduce

Describe the Bug

Having a data folder on the root of the folder results in build failure.

To Reproduce

  1. Clone provided repository
  2. Run bash create-env.sh to create environment variables
  3. Run pnpm install
  4. Run docker compose up -d
  5. Run pnpm build
  6. Encounter the error.
$ pnpm build
 WARN  Unsupported engine: wanted: {"node":">=18.19.0"} (current: {"node":"v18.17.1","pnpm":"8.15.7"})

> payload-data-folder-build-repoduce@1.0.0 build /home/swjeon/projects/payload-data-folder-build-repoduce
> cross-env NODE_OPTIONS=--no-deprecation next build

   ▲ Next.js 14.2.0-canary.23
   - Environments: .env

   Creating an optimized production build ...
glob error [Error: EACCES: permission denied, scandir '/home/swjeon/projects/payload-data-folder-build-repoduce/data/mongodb/.mongodb'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/home/swjeon/projects/payload-data-folder-build-repoduce/data/mongodb/.mongodb'
}
Failed to compile.

Error: EACCES: permission denied, scandir '/home/swjeon/projects/payload-data-folder-build-repoduce/data/mongodb/.mongodb'

HookWebpackError: Cannot read properties of undefined (reading 'server')
    at makeWebpackError (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:28:312635)
    at /home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:28:106060
    at eval (eval at create (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:20:1)
-- inner error --
TypeError: Cannot read properties of undefined (reading 'server')
    at FlightClientEntryPlugin.createActionAssets (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/plugins/flight-client-entry-plugin.js:634:66)
    at /home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/plugins/flight-client-entry-plugin.js:162:31
    at fn (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:28:69745)
    at _next6 (eval at create (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:12:17)
    at eval (eval at create (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:31:1)
caused by plugins in Compilation.hooks.processAssets
TypeError: Cannot read properties of undefined (reading 'server')
    at FlightClientEntryPlugin.createActionAssets (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/plugins/flight-client-entry-plugin.js:634:66)
    at /home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/plugins/flight-client-entry-plugin.js:162:31
    at fn (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:28:69745)
    at _next6 (eval at create (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:12:17)
    at eval (eval at create (/home/swjeon/projects/payload-data-folder-build-repoduce/node_modules/.pnpm/next@14.2.0-canary.23_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:31:1)


> Build failed because of webpack errors
 ELIFECYCLE  Command failed with exit code 1.

Payload Version

3.0.0-beta.10

Adapters and Plugins

No response

@maxswjeon maxswjeon added the [possible-bug] Possible bug which hasn't been reproduced yet label Apr 15, 2024
@maxswjeon
Copy link
Author

Added Minimal Reproduction https://github.com/maxswjeon/payload-data-folder-build-repoduce

@maxswjeon maxswjeon changed the title Having a data folder in root breaks build in 3.0 beta [3.0 Beta] Having a data folder in root breaks build Apr 15, 2024
@denolfe
Copy link
Member

denolfe commented Apr 17, 2024

This is likely a permissions issue on that particular directory. Your reproduction did not include a data directory as this bug report states.

It appears that your mongodb data directory is being embedded inside your project instead of (typically) outside of your project.

I would be curious what the permissions are for that directory. What does ls -lat return? This solution might work for you.

@maxswjeon
Copy link
Author

maxswjeon commented Apr 17, 2024

Running through reproduction steps creates a data directory, at the docker compose up -d phase. I think the existence of data directory in root folder should not affect build.

@denolfe
Copy link
Member

denolfe commented Apr 22, 2024

I would be curious what the permissions are for that directory. What does ls -lat return? vercel/next.js#8908 (comment) might work for you.

This information would be helpful.

Either way, to be clear, this is Next.js trying to build, and you have a directory in your project that has invalid permissions.

Where did you source this docker compose file? All of our examples have the following for mongo volumes:

    volumes:
      - data:/data/db

This differs from yours in that you have a relative path.

@maxswjeon
Copy link
Author

maxswjeon commented Apr 23, 2024

$ ls -lat
total 284
drwxrwxr-x 37 swjeon swjeon   4096 Apr 21 11:49 ..
drwxrwxr-x  4 swjeon swjeon   4096 Apr 15 22:44 .next
drwxrwxr-x  8 swjeon swjeon   4096 Apr 15 22:32 .git
-rw-rw-r--  1 swjeon swjeon    172 Apr 15 22:31 README.md
-rw-rw-r--  1 swjeon swjeon    448 Apr 15 22:28 .gitignore
-rw-rw-r--  1 swjeon swjeon   1371 Apr 15 22:28 package.json
-rwxrwxr-x  1 swjeon swjeon    292 Apr 15 22:27 create-env.sh
drwxrwxr-x  7 swjeon swjeon   4096 Apr 15 22:24 .
drwxrwxr-x  6 swjeon swjeon   4096 Apr 15 22:24 node_modules
-rw-rw-r--  1 swjeon swjeon 210052 Apr 15 22:24 pnpm-lock.yaml
drwxrwxr-x  3 swjeon swjeon   4096 Apr 15 22:23 data
-rw-rw-r--  1 swjeon swjeon    356 Apr 15 22:23 docker-compose.yml
-rw-rw-r--  1 swjeon swjeon    186 Apr 15 22:22 .env
drwxrwxr-x  4 swjeon swjeon   4096 Apr 15 22:19 src
-rw-rw-r--  1 swjeon swjeon     92 Apr 15 06:44 .env.example
-rw-rw-r--  1 swjeon swjeon    157 Apr 15 06:44 .eslintrc.cjs
-rw-rw-r--  1 swjeon swjeon     90 Apr 15 06:44 .prettierrc.json
-rw-rw-r--  1 swjeon swjeon    439 Apr 15 06:44 Dockerfile
-rw-rw-r--  1 swjeon swjeon    194 Apr 15 06:44 next.config.mjs
-rw-rw-r--  1 swjeon swjeon    652 Apr 15 06:44 tsconfig.json
$ ls -lat data
total 12
drwxr-xr-x 5 lxd    root   4096 Apr 23 17:46 mongodb
drwxrwxr-x 7 swjeon swjeon 4096 Apr 15 22:24 ..
drwxrwxr-x 3 swjeon swjeon 4096 Apr 15 22:23 .
$ ls -lat data/mongodb
total 360
drwx------ 2 lxd    docker  4096 Apr 23 17:46 diagnostic.data
drwxr-xr-x 5 lxd    root    4096 Apr 23 17:46 .
-rw------- 1 lxd    docker  1486 Apr 23 17:46 WiredTiger.turtle
-rw------- 1 lxd    docker 77824 Apr 23 17:46 WiredTiger.wt
-rw------- 1 lxd    docker 36864 Apr 21 16:01 sizeStorer.wt
-rw------- 1 lxd    docker  4096 Apr 21 16:00 index-6-3854372353127327401.wt
-rw------- 1 lxd    docker 36864 Apr 21 16:00 collection-2-3854372353127327401.wt
-rw------- 1 lxd    docker 36864 Apr 21 16:00 index-3-3854372353127327401.wt
-rw------- 1 lxd    docker 20480 Apr 21 15:59 collection-0-3854372353127327401.wt
-rw------- 1 lxd    docker 20480 Apr 21 15:59 index-1-3854372353127327401.wt
-rw------- 1 lxd    docker 20480 Apr 21 15:59 _mdb_catalog.wt
drwx------ 2 lxd    docker  4096 Apr 21 15:59 journal
-rw------- 1 lxd    docker     2 Apr 21 15:59 mongod.lock
-rw------- 1 lxd    docker  4096 Apr 21 15:59 WiredTigerHS.wt
-rw------- 1 lxd    docker  4096 Apr 15 22:23 collection-4-3854372353127327401.wt
-rw------- 1 lxd    docker 20480 Apr 15 22:23 collection-7-3854372353127327401.wt
-rw------- 1 lxd    docker  4096 Apr 15 22:23 index-5-3854372353127327401.wt
-rw------- 1 lxd    docker 20480 Apr 15 22:23 index-8-3854372353127327401.wt
-rw------- 1 lxd    docker 20480 Apr 15 22:23 index-9-3854372353127327401.wt
drwx------ 3 lxd    docker  4096 Apr 15 22:23 .mongodb
-rw------- 1 lxd    docker   114 Apr 15 22:23 storage.bson
-rw------- 1 lxd    docker    50 Apr 15 22:23 WiredTiger
-rw------- 1 lxd    docker    21 Apr 15 22:23 WiredTiger.lock
drwxrwxr-x 3 swjeon swjeon  4096 Apr 15 22:23 ..

@maxswjeon
Copy link
Author

The source of the docker compose file is myself. I didn't wanted to make a non-bound docker volume (located at /var/lib/docker/...) because it is hard to find them if I stop developing on the project.

@denolfe denolfe added [cant-reproduce] If an issue cannot be reproduced and removed [possible-bug] Possible bug which hasn't been reproduced yet labels Apr 29, 2024
@denolfe
Copy link
Member

denolfe commented Apr 29, 2024

This still feels like a permissions issue on your machine for that data directory, though the permissions on mine look even less permissive.

drwxr-xr-x@ 3 elliot staff 96 Apr 21 19:59 data

I ran through the recreation steps, and it is able to get past where you were (failed on unrelated my-route dir). After removing the my-route dir, I was able to build just fine.

CleanShot 2024-04-29 at 10 11 17 CleanShot 2024-04-29 at 10 08 47

@denolfe denolfe closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[cant-reproduce] If an issue cannot be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants