Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sudo from READMEs #359

Open
jwnimmer-tri opened this issue Jan 17, 2025 · 4 comments
Open

Remove sudo from READMEs #359

jwnimmer-tri opened this issue Jan 17, 2025 · 4 comments
Assignees

Comments

@jwnimmer-tri
Copy link
Contributor

For any scripts in this repository, if they require root access then they should internally obtain that access (e.g., by conditionally prefixing certain commands like apt-get with a sudo). They should not instruct the user to run sudo setup/install_prereqs.

This is the policy Drake will be aiming for, moving forward (see e.g. RobotLocomotion/drake#22461).

@jwnimmer-tri
Copy link
Contributor Author

I noticed this in #357. It's OK by me if you'd like to merge the correct documentation first (which currently means telling the user to run sudo) and then circle back here later.

(However, that might be difficult in case macOS requires no-sudo but Ubuntu requires yes-sudo, and they share the same README.)

@BetsyMcPhail
Copy link
Contributor

I was just reviewing this on #357. I believe the setup/install_prereqs scripts in this repo (e.g. https://github.com/RobotLocomotion/drake-external-examples/blob/main/drake_bazel_external/setup/install_prereqs) are already setup as you described. Can you please confirm this is what you're looking for?

@jwnimmer-tri
Copy link
Contributor Author

jwnimmer-tri commented Jan 17, 2025

That's the right idea, we could call it 90% of the way there. The problem is that if someone is running in Docker and they are already root, sometimes sudo actually fails.

The ideal would be to only run sudo if we're not already root. Here's how I did that in my recent docs PR:

RobotLocomotion/drake@52876ee#diff-4ab58ad02a221a36b723ddbb13f04ef076ad887fa01c1d6fd0b1809ed9b39d1eR26-R30

  maybe_sudo=
  if [[ "${EUID}" -ne 0 ]]; then
    maybe_sudo=sudo
  fi
  ${maybe_sudo} apt-get ...etc...

@BetsyMcPhail
Copy link
Contributor

That makes sense, thanks for the clarification.

On closer inspection, it seems that the examples are not consistent. Some of the examples, like drake_bazel_external don't currently require sudo, while others like drake_bazel_download do.

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

No branches or pull requests

3 participants