Skip to content

feat: add Frappe bench setup script with dev environment#4

Closed
NagariaHussain wants to merge 1 commit intodevelopfrom
claude/setup-frappe-bench-WShAl
Closed

feat: add Frappe bench setup script with dev environment#4
NagariaHussain wants to merge 1 commit intodevelopfrom
claude/setup-frappe-bench-WShAl

Conversation

@NagariaHussain
Copy link
Contributor

@NagariaHussain NagariaHussain commented Jan 12, 2026

  • Add comprehensive setup script for Frappe bench development
  • Document installed tools: pyenv (Python 3.14), nvm (Node 24), Homebrew
  • Include MariaDB connector for mysqlclient Python package
  • Provide Docker and system install options for MariaDB
  • Add environment setup, asset building, and site creation instructions

Summary by CodeRabbit

  • New Features
    • Added an automated setup script that streamlines Frappe bench environment configuration. Features include MariaDB provisioning (Docker or local system), asset building, site creation, app installation, environment initialization, and step-by-step guidance with version verification.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add comprehensive setup script for Frappe bench development
- Document installed tools: pyenv (Python 3.14), nvm (Node 24), Homebrew
- Include MariaDB connector for mysqlclient Python package
- Provide Docker and system install options for MariaDB
- Add environment setup, asset building, and site creation instructions
@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

📝 Walkthrough

Walkthrough

Introduces a new Bash setup script that automates Frappe bench environment provisioning, including environment initialization, version validation, MariaDB configuration, asset building, site creation, app installation, and server startup with interactive guidance.

Changes

Cohort / File(s) Summary
Frappe Bench Setup Script
setup-frappe-bench.sh
New script automating bench provisioning with functions for environment setup (pyenv, nvm, Homebrew), version checks, MariaDB provisioning (Docker/system), asset building, site creation, Hazelnode app installation, bench server startup, and bashrc configuration. Outputs guidance commands for semi-automated flow.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Script as setup-frappe-bench.sh
    participant Env as Environment<br/>(pyenv, nvm, Homebrew)
    participant MariaDB as MariaDB<br/>(Docker/System)
    participant Build as Build System
    participant Bench as Bench Server

    User->>Script: Execute setup
    Script->>Env: setup_environment()
    Env-->>Script: Environment ready
    Script->>Script: check_versions()
    Script-->>User: Display versions
    Script->>MariaDB: setup_mariadb_docker()<br/>or system config
    MariaDB-->>Script: MariaDB ready
    Script->>Build: build_assets()
    Build-->>Script: Assets built
    Script->>Bench: create_site()
    Bench-->>Script: Site created
    Script->>Bench: install_hazelnode()
    Bench-->>Script: Hazelnode installed
    Script->>Bench: start_bench()
    Bench-->>Script: Server running
    Script->>Env: add_to_bashrc()
    Env-->>Script: Configuration updated
    Script-->>User: Setup complete
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A script to hop through setup with cheer,
From pyenv to bench, the path is clear!
Through MariaDB, assets, and sites we bound,
Hazelnode installed, bench server sound, 🎉
One file to rule them all, profound!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: a new Frappe bench setup script with development environment configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: 0

🧹 Nitpick comments (5)
setup-frappe-bench.sh (5)

24-42: Hardcoded paths reduce portability.

The function uses environment-specific paths (/opt/nvm, /home/linuxbrew/.linuxbrew) that won't work on other systems or macOS. Consider parameterizing these or adding detection logic if the script needs to be reusable.

♻️ Suggested improvement for flexibility
 setup_environment() {
     # Pyenv
     export PYENV_ROOT="$HOME/.pyenv"
     export PATH="$PYENV_ROOT/bin:$PATH"
     eval "$(pyenv init -)"

     # NVM
-    export NVM_DIR="/opt/nvm"
+    export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
     [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
     nvm use 24 > /dev/null

     # Homebrew
-    eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
+    if [ -x "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
+        eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
+    elif [ -x "/opt/homebrew/bin/brew" ]; then
+        eval "$(/opt/homebrew/bin/brew shellenv)"
+    fi

113-122: Hardcoded app path won't work for other users.

The path /home/user/hazelnode is specific to one user's system. Consider using a placeholder or environment variable.

♻️ Suggested improvement
 install_hazelnode() {
     echo "=== Install Hazelnode App ==="
     echo ""
+    echo "Note: Replace <path-to-hazelnode> with your actual hazelnode directory"
+    echo ""
     cat << 'APP_CMD'
 cd ~/frappe/frappe-bench
-bench get-app /home/user/hazelnode
+bench get-app <path-to-hazelnode>
 bench --site hazelnode.local install-app hazelnode
 APP_CMD
     echo ""
 }

136-161: Function name is misleading.

add_to_bashrc doesn't actually modify ~/.bashrc - it only prints the snippet. Consider renaming to print_bashrc_snippet or show_bashrc_additions to match the actual behavior.

♻️ Suggested rename
-add_to_bashrc() {
-    echo "=== Add to ~/.bashrc ==="
+print_bashrc_snippet() {
+    echo "=== Add the following to ~/.bashrc ==="

163-178: Environment changes don't persist after script exits.

setup_environment() modifies the shell environment, but these changes only apply within the script's execution context. Users will still need to source their .bashrc or run the setup manually for subsequent terminal sessions. Consider adding a note about this.

Also, Line 177 repeats the hardcoded /home/user/hazelnode path.

♻️ Suggested improvement
 echo "=== Setup Complete ==="
 echo ""
+echo "NOTE: Run 'source ~/.bashrc' or open a new terminal to load the environment."
+echo ""
 echo "Bench location: ~/frappe/frappe-bench"
 echo "Frappe app: ~/frappe/frappe-bench/apps/frappe"
-echo "Hazelnode app: /home/user/hazelnode"
+echo "Hazelnode app: <your-hazelnode-directory>"
 echo ""

61-74: Improve MariaDB readiness check and document security considerations.

The Docker instructions have several reliability and security concerns:

  1. Fixed sleep is unreliablesleep 10 may not be sufficient on slower systems or excessive on fast ones; a retry loop with an actual database query is more robust.
  2. Password visible in process list-padmin exposes credentials in process listings; use the MYSQL_PWD environment variable instead.
  3. Weak credentials — Acceptable for local development but should be explicitly documented as dev-only.
♻️ Suggested improvement for reliability
 docker run -d \
     --name mariadb \
     -p 3306:3306 \
     -e MYSQL_ROOT_PASSWORD=admin \
     -e MYSQL_DATABASE=frappe \
     mariadb:11.8

-# Wait for MariaDB to be ready
-sleep 10
+# Wait for MariaDB to be ready (retry loop)
+until docker exec mariadb mariadb -uroot -padmin -e "SELECT 1" &>/dev/null; do
+    echo "Waiting for MariaDB..."
+    sleep 2
+done

-# Test connection
-mysql -h 127.0.0.1 -u root -padmin -e "SELECT 1"
+# Test connection (use MYSQL_PWD to avoid password in process list)
+MYSQL_PWD=admin mysql -h 127.0.0.1 -u root -e "SELECT 1"
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6127f3 and b241038.

📒 Files selected for processing (1)
  • setup-frappe-bench.sh
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-11T16:50:59.725Z
Learnt from: CR
Repo: BuildWithHussain/hazelnode PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-11T16:50:59.725Z
Learning: Run tests using: bench --site test_site run-tests --app hazelnode

Applied to files:

  • setup-frappe-bench.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Server
  • GitHub Check: Playwright E2E Tests
🔇 Additional comments (3)
setup-frappe-bench.sh (3)

44-54: LGTM!

Version checking logic is sound and provides helpful output for verification.


87-111: LGTM!

Build and site creation instructions are clear. The admin password is acceptable for local development purposes.


5-11: The documented tool versions are accurate and were released in December 2025, making them current for January 2026. No action needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants