cartesi / cli

Cartesi CLI tool
Apache License 2.0
10 stars 8 forks source link

Deployment .env file taking precedence in dev environment #60

Open riseandshaheen opened 2 months ago

riseandshaheen commented 2 months ago

๐Ÿ™‚ Expected behavior

When you deploy a Cartesi app on a cloud provider, you have a .env file for node configuration in the app directory. After deployment, if you switch back to local development and run the node, the CLI should ignore the .env file and the Node should run smoothly as it did before deployment.

๐Ÿซ  Actual behavior

When you spin up the node with cartesi run, the Cartesi CLI reads the node env variables from .env and overrides the default values. This creates a timeout issue for local node as shown below:

Attaching to prompt-1, validator-1
validator-1  | 2024-08-01T15:07:48.190 ERR ERROR r2d2: unnamed prepared statement does not exist service=graphql-server
validator-1  | 2024-08-01T15:07:48.195 ERR ERROR r2d2: unnamed prepared statement does not exist service=graphql-server
validator-1  | 2024-08-01T15:07:50.760 ERR Service timed out service=graphql-server
validator-1  | 2024-08-01T15:07:50.824 ERR Node exited with an error error="timed out waiting for service to be ready"

๐Ÿงช Minimal test case

Steps to reproduce:

  1. Create a .env file inside app directory with some production env variables defined.
  2. Build and run the app locally.

๐ŸŒŽ Environment

Local Dev environment - Mac M1 Pro Cartesi CLI version 0.15.1

โœ”๏ธ Possible solutions

Currently, quick fix is to simply rename .env file when you're running node in locally.

endersonmaia commented 2 months ago

Since .env can be a valid file for the development environment, we could emit a WARNING in the CLI, suggesting the user to rename the file or be careful with which variable are chosen.

Also, suggest using cartesi.env to override rollups-node ENV variables.

I'm just thinking out loud here.

tuler commented 2 months ago

Why is there a .env file there? Is it the one created by the deployment procedure? Can we generate one with a different name?

endersonmaia commented 2 months ago

Why is there a .env file there? Is it the one created by the deployment procedure? Can we generate one with a different name?

Yes, we could save with da difffent name.

But there are some language frameworks that use dotenv.