preflight check for sudo

Bug #1800918 reported by Evan
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

We're missing a preflight check for the sudo binary:

Traceback (most recent call last):
  File "/snap/snapcraft/current/legacy_snapcraft/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.43.1', 'console_scripts', 'snapcraft')()
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/snapcraft/cli/lifecycle.py", line 187, in prime
    _execute(steps.PRIME, parts, **kwargs)
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/snapcraft/cli/lifecycle.py", line 98, in _execute
    lifecycle.execute(step, project_config, parts)
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_runner.py", line 66, in execute
    installed_packages = repo.Repo.install_build_packages(project_config.build_tools)
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/snapcraft/internal/repo/_deb.py", line 281, in install_build_packages
    cls._install_new_build_packages([package[0] for package in new_packages])
  File "/snap/snapcraft/current/legacy_snapcraft/lib/python3.5/site-packages/snapcraft/internal/repo/_deb.py", line 340, in _install_new_build_packages
    subprocess.check_call(apt_command + package_names, env=env)
  File "/snap/snapcraft/current/legacy_snapcraft/usr/lib/python3.5/subprocess.py", line 576, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/snap/snapcraft/current/legacy_snapcraft/usr/lib/python3.5/subprocess.py", line 557, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/snap/snapcraft/current/legacy_snapcraft/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/snap/snapcraft/current/legacy_snapcraft/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'sudo'

Revision history for this message
林博仁(Buo-ren, Lin) (buo-ren-lin) wrote :

Seemed to encounter this in a docker 18.04 container without sudo package installed.

IMHO snapcraft should avoid using sudo if it is run as root and already have the required permission to build.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.