fix: check if sudo command is available before using it in install.sh#575
fix: check if sudo command is available before using it in install.sh#575
Conversation
Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #575 +/- ##
=======================================
Coverage 21.93% 21.93%
=======================================
Files 72 72
Lines 4815 4815
=======================================
Hits 1056 1056
Misses 3662 3662
Partials 97 97 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes an installation failure on systems without sudo installed (e.g., minimal containers, embedded systems) by adding a check for sudo availability before attempting to use it.
Key Changes:
- Add conditional check using
command -v sudoto detect if sudo is available - Set
SUDO_CMDto empty string when sudo is not found, allowing installation to proceed if user already has write permissions
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Check if sudo is available | ||
| if command -v sudo &> /dev/null; then | ||
| SUDO_CMD="sudo" | ||
| else |
There was a problem hiding this comment.
When sudo is not available, the script silently sets SUDO_CMD to empty string without informing the user. This could lead to confusing permission errors later (lines 88-92, 95-103) if the user doesn't have write permissions to /usr/local/bin. Consider adding a warning message here to inform users that sudo is not available and they will need appropriate permissions to install to /usr/local/bin.
| else | |
| else | |
| echo "Warning: 'sudo' command not found. Proceeding without sudo." | |
| echo "Installation directory is '${INSTALL_DIR}'. Ensure you have write permissions to this directory (for example, run this script as root)." |
install.shfails on systems withoutsudoinstalled (minimal containers, embedded systems) withsudo: command not found.Changes
command -v sudocheck before settingSUDO_CMDOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.