Hi all,
Having a bit of trouble with my Docker installation of Bolt.diy.
Things were working pretty well. I’m doing a local docker install of Bolt.diy. However, I configure my system to integrate with GitHub and Cloudflare pages for deployment. Some time after I did that I started getting errors in my Bolt.diy and things stopped working.
Here’s the Error in Bolt.diy
I dived into the wrangler logs and found this error that seems to be related:
--- 2025-01-04T03:39:57.132Z debug
Failed to load .env file "/app/.dev.vars": Error: ENOENT: no such file or directory, open '/app/.dev.vars'
at Object.openSync (node:fs:573:18)
at Object.readFileSync (node:fs:452:35)
at tryLoadDotEnv (/app/node_modules/.pnpm/wrangler@3.91.0_@cloudflare+workers-types@4.20241127.0/node_modules/wrangler/src/config/index.ts:684:34)
at loadDotEnv (/app/node_modules/.pnpm/wrangler@3.91.0_@cloudflare+workers-types@4.20241127.0/node_modules/wrangler/src/config/index.ts:697:10)
at getVarsForDev (/app/node_modules/.pnpm/wrangler@3.91.0_@cloudflare+workers-types@4.20241127.0/node_modules/wrangler/src/dev/dev-vars.ts:29:17)
at getPlatformProxy (/app/node_modules/.pnpm/wrangler@3.91.0_@cloudflare+workers-types@4.20241127.0/node_modules/wrangler/src/api/integrations/platform/index.ts:118:15)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at configureServer (/app/node_modules/.pnpm/@remix-run+dev@2.15.0_@remix-run+react@2.15.0_react-dom@18.3.1_react@18.3.1__react@18.3.1_typ_3djlhh3t6jbfog2cydlrvgreoy/node_modules/@remix-run/dev/dist/vite/cloudflare-proxy-plugin.js:55:11)
at _createServer (file:///app/node_modules/.pnpm/vite@5.4.11_@types+node@22.10.1_sass-embedded@1.81.0/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:63080:20)
at dev (/app/node_modules/.pnpm/@remix-run+dev@2.15.0_@remix-run+react@2.15.0_react-dom@18.3.1_react@18.3.1__react@18.3.1_typ_3djlhh3t6jbfog2cydlrvgreoy/node_modules/@remix-run/dev/dist/vite/dev.js:39:16)
at Object.viteDev (/app/node_modules/.pnpm/@remix-run+dev@2.15.0_@remix-run+react@2.15.0_react-dom@18.3.1_react@18.3.1__react@18.3.1_typ_3djlhh3t6jbfog2cydlrvgreoy/node_modules/@remix-run/dev/dist/cli/commands.js:221:3)
at Object.run (/app/node_modules/.pnpm/@remix-run+dev@2.15.0_@remix-run+react@2.15.0_react-dom@18.3.1_react@18.3.1__react@18.3.1_typ_3djlhh3t6jbfog2cydlrvgreoy/node_modules/@remix-run/dev/dist/cli/run.js:271:7) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/app/.dev.vars'
}```
Did a dive into ChatGPT and got this response
The error you’re encountering indicates that your Cloudflare Workers or Remix app using Bolt.diy is trying to load a .dev.vars
file but can’t find it. This is typically a file that contains environment variables for development mode, which the Wrangler tool expects.
Here’s how you can fix it:
Solution 1: Create the .dev.vars
file
Create a .dev.vars
file at the root of your project to hold your environment variables. For example:
- In your project root directory:
touch .dev.vars
- Add your variables inside
.dev.vars
:
# .dev.vars
API_KEY=your_api_key_here
DB_URL=your_database_url_here
Wrangler will automatically pick this file up when running your app locally.
Solution 2: Update wrangler.toml
to specify env vars
If you want to avoid the .dev.vars
file, you can define your environment variables directly in wrangler.toml
.
# wrangler.toml
[vars]
API_KEY = "your_api_key_here"
DB_URL = "your_database_url_here"
Solution 3: Pass environment variables through the command line
If you prefer not to create files, you can pass environment variables directly when starting the app:
npx wrangler dev --var API_KEY=your_api_key_here --var DB_URL=your_database_url_here
Solution 4: Ignore .dev.vars
in production
If .dev.vars
is only needed for local development, you can modify your start script to handle it gracefully:
In your package.json
:
"scripts": {
"dev": "if [ -f .dev.vars ]; then export $(cat .dev.vars | xargs); fi && npx wrangler dev"
}
Let me know how best to resolve this problem. Like I said was having a pretty good day bolt.diy until this happened.