Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 17, 2025

install.sh fails on systems without sudo installed (minimal containers, embedded systems) with sudo: command not found.

Changes

  • Add command -v sudo check before setting SUDO_CMD
  • If sudo unavailable, proceed without it (allows install when user already has write permissions)
# Before: unconditionally set sudo
SUDO_CMD="sudo"

# After: check availability first
if command -v sudo &> /dev/null; then
  SUDO_CMD="sudo"
else
  SUDO_CMD=""
fi
Original prompt

main: line 83: sudo: command not found
Failed to create /usr/local/bin directory. Please check your permissions and try again.

有些系统没有这个的,所以可以不需要,在最前面的地方检测一下


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Dec 17, 2025
Copilot AI changed the title [WIP] Check availability of sudo command before directory creation fix: check if sudo command is available before using it in install.sh Dec 17, 2025
Copilot AI requested a review from bytemain December 17, 2025 07:02
@bytemain bytemain marked this pull request as ready for review December 17, 2025 07:03
Copilot AI review requested due to automatic review settings December 17, 2025 07:03
@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.93%. Comparing base (1ca4237) to head (69bb28f).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 sudo to detect if sudo is available
  • Set SUDO_CMD to 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
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
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)."

Copilot uses AI. Check for mistakes.
@bytemain bytemain merged commit df862ce into main Dec 17, 2025
10 checks passed
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