Skip to content

Conversation

@Cristhianzl
Copy link
Member

@Cristhianzl Cristhianzl commented Jul 28, 2025

This pull request enhances the Windows build and run scripts for Langflow by adding support for .env files. The scripts now automatically detect and use a .env file if it exists, or fall back to default configurations if it does not. This improvement ensures better configuration management for the application.

Enhancements to .env file handling:

  • Batch script (scripts/windows/build_and_run.bat):

    • Added logic to check for the existence of a .env file in the project root directory and set an --env-file parameter if the file is found. If the file is not found, a message is displayed, and the script uses the default configuration.
    • Updated the command to run Langflow (uv run langflow run) to include the --env-file parameter when applicable.
  • PowerShell script (scripts/windows/build_and_run.ps1):

    • Implemented similar logic to detect the .env file and set the --env-file parameter dynamically. Informative messages are displayed based on whether the file is found.
    • Modified the Langflow execution command to conditionally include the --env-file parameter.

Summary by CodeRabbit

  • New Features

    • The Windows build and run scripts now automatically detect and use a .env configuration file if present, or notify users when the default configuration is used.
  • Chores

    • Improved script messaging for clarity regarding environment configuration.

…from .env file

🔧 (build_and_run.ps1): add support for loading environment variables from .env file
…nment variables

🐛 (build_and_run.ps1): fix path to .env file to correctly load environment variables
…pass to langflow run

🔧 (build_and_run.ps1): set env file parameter if .env file exists to pass to langflow run
…v file path for Langflow run

📝 (build_and_run.ps1): enhance script to dynamically locate and set .env file path for Langflow run
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The Windows batch (.bat) and PowerShell (.ps1) scripts for building and running Langflow have been updated to check for the presence of a .env file at the project root. If found, the scripts pass this file as an argument to the Langflow run command; otherwise, they proceed with default configuration.

Changes

Cohort / File(s) Change Summary
Windows Build & Run Scripts
scripts/windows/build_and_run.bat, scripts/windows/build_and_run.ps1
Added logic to detect a .env file two directories above script location. If present, pass as --env-file to Langflow run command; otherwise, run without this argument. No changes to build/copy steps.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Suggested labels

enhancement, lgtm

Suggested reviewers

  • ogabrielluiz
  • deon-sanchez
  • mfortman11
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cz/load-env-win-script

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 28, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b7513e5 and a0f4260.

📒 Files selected for processing (2)
  • scripts/windows/build_and_run.bat (3 hunks)
  • scripts/windows/build_and_run.ps1 (4 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Starter project files auto-format after langflow run; these formatting changes can be committed or ignored
Learnt from: namastex888
PR: langflow-ai/langflow#9018
File: src/frontend/src/modals/apiModal/utils/get-curl-code.tsx:139-184
Timestamp: 2025-07-11T21:32:57.160Z
Learning: In TypeScript/JavaScript cURL code generation for Langflow, PowerShell commands must use backticks (`) for line continuation and follow the pattern: `curl --request POST \` followed by `--url`, `--header` flags on separate lines. Unix commands use backslashes (\) for line continuation. File upload commands should maintain platform-specific formatting just like other cURL commands in the codebase.
scripts/windows/build_and_run.bat (2)

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Starter project files auto-format after langflow run; these formatting changes can be committed or ignored

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Frontend builds should output static files to src/frontend/dist/ for production deployment.

scripts/windows/build_and_run.ps1 (2)

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Starter project files auto-format after langflow run; these formatting changes can be committed or ignored

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Frontend builds should output static files to src/frontend/dist/ for production deployment.

🔇 Additional comments (3)
scripts/windows/build_and_run.ps1 (1)

5-16: Path resolution and parameter construction look solid.

The PowerShell implementation correctly uses Split-Path, Resolve-Path, and Join-Path for robust path handling. The parameter construction with proper quoting handles paths with spaces correctly.

scripts/windows/build_and_run.bat (2)

88-92: Conditional execution logic is correct.

The batch file correctly uses if defined ENV_FILE_PARAM to conditionally include the environment file parameter, which is the appropriate way to check for variable existence in batch files.


4-15: PowerShell and Batch .env Handling Are In Sync

I’ve verified that both scripts perform the same steps:

  • Resolve the project root
  • Check for the existence of .env in that root
  • Set an environment-file parameter when present
  • Invoke uv run langflow run with or without the --env-file flag

No behavioral discrepancies were found. No changes required.

scripts/windows/build_and_run.ps1
scripts/windows/build_and_run.bat

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@SonicDMG SonicDMG temporarily deployed to cz/load-env-win-script - langflow-manual-install PR #9214 July 28, 2025 20:17 — with Render Destroyed
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 28, 2025
…ile' instead of a string variable 'envFileParam' to improve readability and maintainability

🔧 (build_and_run.ps1): update uvicorn command to use '--env-file' flag directly instead of building the command with a string variable
@github-actions github-actions bot added the lgtm This PR has been approved by a maintainer label Jul 28, 2025
@Cristhianzl Cristhianzl enabled auto-merge July 28, 2025 21:08
@SonicDMG SonicDMG temporarily deployed to cz/load-env-win-script - langflow-manual-install PR #9214 July 28, 2025 21:11 — with Render Destroyed
@Cristhianzl Cristhianzl added this pull request to the merge queue Jul 28, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 28, 2025
@sonarqubecloud
Copy link

Merged via the queue into main with commit 86c54de Jul 28, 2025
15 checks passed
@Cristhianzl Cristhianzl deleted the cz/load-env-win-script branch July 28, 2025 21:22
2getsandesh pushed a commit to 2getsandesh/langflow-IBM that referenced this pull request Aug 6, 2025
* 🔧 (build_and_run.bat): add support for loading environment variables from .env file
🔧 (build_and_run.ps1): add support for loading environment variables from .env file

* 🐛 (build_and_run.bat): fix path to .env file to correctly load environment variables
🐛 (build_and_run.ps1): fix path to .env file to correctly load environment variables

* 🔧 (build_and_run.bat): set env file parameter if .env file exists to pass to langflow run
🔧 (build_and_run.ps1): set env file parameter if .env file exists to pass to langflow run

* 📝 (build_and_run.bat): improve script to dynamically find and set .env file path for Langflow run
📝 (build_and_run.ps1): enhance script to dynamically locate and set .env file path for Langflow run

* Update scripts/windows/build_and_run.bat

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* 🔧 (build_and_run.ps1): refactor script to use a boolean flag 'useEnvFile' instead of a string variable 'envFileParam' to improve readability and maintainability
🔧 (build_and_run.ps1): update uvicorn command to use '--env-file' flag directly instead of building the command with a string variable

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants