feat: add Frappe bench setup script with dev environment#4
feat: add Frappe bench setup script with dev environment#4NagariaHussain wants to merge 1 commit intodevelopfrom
Conversation
- 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
📝 WalkthroughWalkthroughIntroduces 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
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
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
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/hazelnodeis 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_bashrcdoesn't actually modify~/.bashrc- it only prints the snippet. Consider renaming toprint_bashrc_snippetorshow_bashrc_additionsto 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.bashrcor run the setup manually for subsequent terminal sessions. Consider adding a note about this.Also, Line 177 repeats the hardcoded
/home/user/hazelnodepath.♻️ 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:
- Fixed sleep is unreliable —
sleep 10may not be sufficient on slower systems or excessive on fast ones; a retry loop with an actual database query is more robust.- Password visible in process list —
-padminexposes credentials in process listings; use theMYSQL_PWDenvironment variable instead.- 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
📒 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
adminpassword 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.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.