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

langflow not respecting env file. #3820

Closed
jtoy opened this issue Sep 16, 2024 · 3 comments · Fixed by #4002
Closed

langflow not respecting env file. #3820

jtoy opened this issue Sep 16, 2024 · 3 comments · Fixed by #4002
Assignees
Labels
bug Something isn't working

Comments

@jtoy
Copy link

jtoy commented Sep 16, 2024

Bug Description

I start langflow like this:
python3 -m langflow run --env-file .langflow.env
it doesn't respect the env file.

Here is the env file I am using:
LANGFLOW_SUPERUSER=admin
LANGFLOW_SUPERUSER_PASSWORD=password
LANGFLOW_AUTO_LOGIN=false
LANGFLOW_HOST=0.0.0.0

Reproduction

  1. pip install langlow

Expected behavior

it should respect the .env file.

Who can help?

No response

Operating System

Ubuntu 20.04.4 LTS

Langflow Version

1.0.18

Python Version

3.10

Screenshot

No response

Flow File

No response

@jtoy jtoy added the bug Something isn't working label Sep 16, 2024
Copy link

dosubot bot commented Sep 16, 2024

There are a couple of similar issues that might be relevant to your problem:

  1. Features change when langflow is run from the Env Variables - This issue was closed and the solution involved ensuring that the correct options were included in the configuration files.
  2. LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT not loading any environment variables - This issue was also closed, and the solution was to format the environment variables as a comma-separated list instead of a JSON-encoded string.

For your specific issue, ensure that the --env-file parameter is correctly passed in the command. The correct command should be:

python3 -m langflow run --env-file .langflow.env

Make sure that the .env file is correctly named and located in the same directory from which you are running the command. According to the Langflow documentation, the --env-file option specifies the path to the .env file containing environment variables, and the default is .env. The code snippet shows that the env_file parameter is used to load environment variables if provided:

if env_file:
    load_dotenv(env_file, override=True)

Additionally, other configuration files or settings in Langflow, such as config.yaml and command-line options, might override or conflict with the .env file settings [1][2][3].

To continue talking to Dosu, mention @dosu.

@italojohnny italojohnny self-assigned this Sep 16, 2024
@italojohnny
Copy link
Member

Hi there! How’s it going?
I followed the steps you described, and everything worked perfectly for me. I had to log in using 'admin' and 'password'. I also tried using a different password, and it worked as expected.
Could you be more specific about the error or behavior you're encountering?

@italojohnny
Copy link
Member

italojohnny commented Sep 27, 2024

I think I understand your issue.
If you try the following command, I believe you won't encounter any problems:

export $(xargs < .langflow.env) && langflow run --env-file .langflow.env

This happens because we have two configuration methods: one through the CLI using typer, and another via a configuration file using pydantic-settings.

The --env-file parameter in typer, which specifies an alternate file with environment variables, can't override its own settings like --host. Therefore, for it to work as expected, you would need to have already declared LANGFLOW_HOST in your environment.

It's definitely confusing and should be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants