Skip to content

[Bug]: Frontend fails to start on ppc64le — __dirname error in next.config.ts and missing webpack fallback #2088

Description

@ethanchoe-2

OpenRAG Version

0.5.0

Deployment Method

Local development (make dev)

Operating System

Linux ppc64le

Python Version

No response

Affected Area

Frontend (Next.js UI, components)

Bug Description

next-swc has no prebuilt native bindings for linux/ppc64le. This causes two failures: (1) __dirname inside next.config.ts resolves incorrectly under the WASM fallback, breaking .env loading; (2) Turbopack (the default bundler) requires native SWC and fails on ppc64le. The fix adds an arch-detection wrapper (build.js) that forces --webpack on ppc64le, updates the build script to invoke it, and fixes the env path to use process.cwd() instead of __dirname.

Steps to Reproduce

  1. Set up a linux/ppc64le host (IBM Power machine)
  2. Clone the repository and cd into it
  3. Copy .env.example to .env and fill in required values

For the build failure (npm run build / make dev):
4. cd frontend && npm ci
5. Run npm run build (pre-fix, calls next build directly)

For the dev server failure (make frontend)
4. Run make frontend from the repo root

Expected Behavior

Frontend builds and dev server start successfully on ppc64le.

Actual Behavior

  • npm run build fails — Turbopack cannot initialize without native next-swc bindings for ppc64le; next.config.ts fails to load .env because __dirname resolves to Next.js internals under the WASM runtime instead of the project root

  • make frontend fails — npx next dev attempts to use Turbopack (default), which requires native SWC bindings unavailable on ppc64le

Relevant Logs

make frontend logs (pre-fix):

▲ Next.js 16.2.9 (Turbopack)
- Local:         http://localhost:3000
- Network:       http://0.0.0.0:3000
✓ Ready in 625ms
⚠ next-swc does not have native bindings for platform linux/ppc64. Native features like Turbopack will not be available.
  Using cached swc package @next/swc-wasm-nodejs...
⨯ Failed to load next.config.ts, see more info here https://nextjs.org/docs/messages/next-config-error
ReferenceError: __dirname is not defined in ES module scope
    at <unknown> (next.config.compiled.js:7:24)

make: *** [Makefile:728: frontend] Error 1


npm run build logs (pre-fix):

> frontend@0.1.0 build
> next build

⚠ next-swc does not have native bindings for platform linux/ppc64. Native features like Turbopack will not be available.
  Using cached swc package @next/swc-wasm-nodejs...
⨯ Failed to load next.config.ts, see more info here https://nextjs.org/docs/messages/next-config-error

> Build error occurred
ReferenceError: __dirname is not defined in ES module scope
    at <unknown> (next.config.compiled.js:7:24)

npm run build logs (post-fix):

⚠ next-swc does not have native bindings for platform linux/ppc64. Native features like Turbopack will not be available.
  Using cached swc package @next/swc-wasm-nodejs...
▲ Next.js 16.2.9 (webpack)
✓ Compiled successfully in 62s

Screenshots

No response

Additional Context

No response

Checklist

  • I have searched existing issues to ensure this bug hasn't been reported before.
  • I have provided all the requested information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug🔴 Something isn't working.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions