Skip to content

Issue: Environment variable misconfiguration prevents running bun run start effectively #82

@MateuszKlusek

Description

@MateuszKlusek

Issue: Environment Variable Misconfiguration Prevents Running bun run start Effectively

Context

When attempting to run the development server using bun run start in the packages/demo directory, the process fails or does not behave as expected due to a missing environment variable.

The .env.example file currently suggests that the required environment variable is named:

BLOCKFROST_API_KEY

and instructs users to create a .env.local (or equivalent) file including this variable.

Problem

  • The variable BLOCKFROST_API_KEY is not actually used in the codebase.

  • Instead, the code expects two separate environment variables to be set for API keys:

    • BLOCKFROST_API_KEY_PREVIEW
    • BLOCKFROST_API_KEY_MAINNET
  • Because only BLOCKFROST_API_KEY is indicated in .env.example and expected in .env.local (or in an equivalent file), the app does not receive the correct keys and cannot start properly.

  • On top of that, the current setup doesn't automatically load variables

Proposed Changes

  1. Update the start script in packages/demo/package.json

    Change from:

"start": "NODE_ENV=development webpack serve --env local --open --config ./webpack.config.cjs",

to

"start": "NODE_ENV=development dotenv -e .env.local webpack serve --env local --open --config ./webpack.config.cjs",

This ensures that the environment variables defined in .env.local are loaded properly when running the start command.

  1. Revise .env.example to reflect the correct environment variables

Replace the current content with:

BLOCKFROST_API_KEY_PREVIEW=
BLOCKFROST_API_KEY_MAINNET=

This clarifies which keys need to be set by the user and aligns the example file with the actual variables used in the code.

Summary

  • The current .env.example template is misleading with the naming convention BLOCKFROST_API_KEY.
  • There is no working mechanism to successfully load env vars from .env* files.
  • The code requires BLOCKFROST_API_KEY_PREVIEW and BLOCKFROST_API_KEY_MAINNET.
  • Updating the start script to load .env.local explicitly and correcting the .env.example file will resolve the issue and improve developer experience.

Thank you for considering this fix to improve the clarity and functionality of the environment setup.


P.S. I wanted to add a MR with a proposed changes, but it appears that an access needs to be granted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions