Hey there,
Is there a way to avoid the installation of implicit dependencies, as in this case:
$ snapcraft
Installing build dependencies: golang-1.6-go golang-1.6-race-detector-runtime
golang-1.6-src golang-go golang-race-detector-runtime golang-src
I don’t need those dependencies on my system, and almost every other developer won’t either because that’s a pretty old version of Go. Somewhat ironically, these developers can install a newer Go version via snaps, so instead of hardcoding the deb install, the system should be introspected to check if that’s indeed necessary.
As an aside, when that does run and an error happens, a pretty ugly message is dumped into the user’s terminal due to unhandled exceptions:
Traceback
(...)
Unpacking golang-go (2:1.6-1ubuntu4) ...
dpkg: error processing archive /var/cache/apt/archives/golang-go_2%3a1.6-1ubuntu4_amd64.deb (--unpack):
trying to overwrite '/usr/bin/gofmt', which is also in package go:i386 1.4-godeb1
Selecting previously unselected package golang-1.6-race-detector-runtime.
Preparing to unpack .../golang-1.6-race-detector-runtime_0.0+svn252922-0ubuntu1_amd64.deb ...
Unpacking golang-1.6-race-detector-runtime (0.0+svn252922-0ubuntu1) ...
Selecting previously unselected package golang-race-detector-runtime.
Preparing to unpack .../golang-race-detector-runtime_2%3a1.6-1ubuntu4_amd64.deb ...
Unpacking golang-race-detector-runtime (2:1.6-1ubuntu4) ...
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
/var/cache/apt/archives/golang-go_2%3a1.6-1ubuntu4_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Traceback (most recent call last):
File "/usr/bin/snapcraft", line 9, in <module>
load_entry_point('snapcraft==2.35', 'console_scripts', 'snapcraft')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3/dist-packages/snapcraft/cli/__main__.py", line 19, in <module>
run(prog_name='snapcraft')
File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1037, in invoke
return Command.invoke(self, ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib/python3/dist-packages/snapcraft/cli/__init__.py", line 124, in run
ctx.forward(lifecyclecli.commands['snap'])
File "/usr/lib/python3/dist-packages/click/core.py", line 552, in forward
return self.invoke(cmd, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 140, in snap
project_options, directory=directory, output=output)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_packer.py", line 45, in snap
execute('prime', project_options)
File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle/_runner.py", line 63, in execute
config.build_tools)
File "/usr/lib/python3/dist-packages/snapcraft/internal/repo/_deb.py", line 205, in install_build_packages
[package[0] for package in new_packages])
File "/usr/lib/python3/dist-packages/snapcraft/internal/repo/_deb.py", line 243, in _install_new_build_packages
subprocess.check_call(apt_command + package_names, env=env)
File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', 'apt-get', '--no-install-recommends', '-y', '-o', 'Dpkg::Progress-Fanc
y=1', 'install', 'golang-1.6-go', 'golang-1.6-race-detector-runtime', 'golang-1.6-src', 'golang-go', 'golang-race-detec
tor-runtime', 'golang-src']' returned non-zero exit status 100