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

Bun does not load .env when run via bin #15155

Open
jasongitmail opened this issue Nov 14, 2024 · 0 comments
Open

Bun does not load .env when run via bin #15155

jasongitmail opened this issue Nov 14, 2024 · 0 comments
Labels
bug Something isn't working runtime

Comments

@jasongitmail
Copy link

jasongitmail commented Nov 14, 2024

What version of Bun is running?

1.1.35-canary.51+357581c61

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

  1. Create .env with some value TEST_ENV_VAR=123
  2. Create an index.ts containing
#!/usr/bin/env bun

console.log(process.env)
  1. Add a bin property to package.json
{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "bin": {
    "bunrepro": "./index.ts"
  },
  "type": "module",
  "author": "",
  "dependencies": {
  },
  "devDependencies": {
  }
}
  1. Now run:
bun install 
npm link // `bun link` does not create a global link, which I assume is known behavior
bunrepro 

What is the expected behavior?

When running bunrepo, you should see our TEST_ENV_VAR=123 within the console log output of process.env. (We do see TEST_ENV_VAR=123 in this output when running bun index.ts directly, as expected.)

What do you see instead?

When running bunrepo, TEST_ENV_VAR=123 is NOT present in the console log output of process.env.

Additional information

No response

@jasongitmail jasongitmail added bug Something isn't working needs triage labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working runtime
Projects
None yet
Development

No branches or pull requests

2 participants