Langflow not loading all required Environment variable mentioned in LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT
Describe the bug Trying to load 3 global variables from Environment. only the first variable is loaded and not the second
Browser and Version
- Browser: Edge
- Version: 126.0.2592.81
To Reproduce Steps to reproduce the behavior:
- my .env file: includes the lines:
LANGFLOW_STORE_ENVIRONMENT_VARIABLES = true
LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT='["default_gcp_project", "default_gcp_location", "default_gcp_dataset"]'
- launch Langflow:
python -m langflow run --components-path /src_backend_platform/ --env-file /env/.env - Only the first variable is loaded in Langflow:
default_gcp_project
Screenshots
@liwalayouni Hello! I'm here to help you with any issues you encounter. I can assist with bug fixes, answer questions, and guide you on becoming a contributor. While waiting for a human maintainer, feel free to ask me anything.
Ensure that your .env file includes the following line without spaces around the = sign:
LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true
Additionally, make sure that LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT is correctly formatted as a JSON-encoded string:
LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT='["default_gcp_project", "default_gcp_location", "default_gcp_dataset"]'
If the issue persists, it might be related to a known bug in Langflow v1.0.6, where the code attempts to override environment variables using locals(), which may not work as intended in all cases [1].
To continue talking to Dosu, mention @dosu.
@dosu, I made sure the .env is as the following:
LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true
LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT='["default_gcp_location", "default_gcp_dataset", "default_gcp_project"]'
this is still resulting into loading only the first variable.
To ensure that all specified environment variables are loaded in Langflow, verify the following:
-
Correct Formatting in
.envFile: Ensure there are no spaces around the=sign and the JSON string is correctly formatted:LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT='["default_gcp_location", "default_gcp_dataset", "default_gcp_project"]' -
Environment Variables Defined: Make sure that the environment variables
default_gcp_location,default_gcp_dataset, anddefault_gcp_projectare defined in your environment. -
Langflow Version: Ensure you are using the latest version of Langflow, as there might be fixes for known issues in newer releases.
-
Loading Mechanism: Langflow uses the
load_dotenvfunction to load environment variables. If there are issues, they might be logged. Check the logs for any errors or warnings related to environment variable loading.
If the issue persists, it might be related to a known limitation in Langflow v1.0.6, where only the first variable is loaded due to how the environment variables are processed. This can be found in the src/backend/base/langflow/__main__.py file [1].
You can also try setting the environment variables directly in your shell before running Langflow:
export default_gcp_location="your_value"
export default_gcp_dataset="your_value"
export default_gcp_project="your_value"
python -m langflow run --components-path /src_backend_platform/ --env-file /env/.env
This approach ensures that the variables are available in the environment when Langflow starts.
To continue talking to Dosu, mention @dosu.
Unfortunately still not working! looks like it is a bug. Anyone else can confirm able to load multiple environment variable?
I just posted a bug #2717 a few hours ago which may relate to your issue.
Hi, @codenprogressive . How are you?
The issue has been fixed in PR #2971. I tested it and was able to load the environment variables you mentioned, as shown in the image:
If you encounter any other issues, please open a new issue!
Thank you very much for your collaboration!