ROS2 with snaps tutorial

I’m following the ROS2 snaps document here for Core 22 on my 22.04 LTS host. The build step produces the following error. Does anyone have any idea where to look for a solution?

$ SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 snapcraft
*EXPERIMENTAL* extension 'ros2-humble' enabled                                        
Launching instance...                                                                 Traceback (most recent call last):
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_providers/bases/buildd.py", line 798, in _setup_snapd_proxy
executor.execute_run(command, capture_output=True, check=True)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_providers/lxd/lxd_instance.py", line 289, in execute_run
return self.lxc.exec(
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_providers/lxd/lxc.py", line 329, in exec
return runner(final_cmd, **kwargs)  # pylint: disable=subprocess-run-check
  File "/snap/snapcraft/8528/usr/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['lxc', '--project', 'snapcraft', 'exec', 'local:snapcraft-ros2-talker-listener-on-amd64-for-amd64-5643208', '--', 'env', 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'SNAPCRAFT_MANAGED_MODE=1', 'SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1', 'snap', 'unset', 'system', 'proxy.http']' returned non-zero exit status 127.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_providers/lxd/lxd_provider.py", line 126, in launched_environment
instance = launch(
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_providers/lxd/launcher.py", line 176, in launch
base_configuration.warmup(executor=instance)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_providers/bases/buildd.py", line 394, in warmup
self._setup_snapd_proxy(executor=executor, deadline=deadline)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_providers/bases/buildd.py", line 809, in _setup_snapd_proxy
raise BaseConfigurationError(
craft_providers.bases.errors.BaseConfigurationError: Failed to set the snapd proxy.
* Command that failed: 'lxc --project snapcraft exec local:snapcraft-ros2-talker-listener-on-amd64-for-amd64-5643208 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin SNAPCRAFT_MANAGED_MODE=1 SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 snap unset system proxy.http'
* Command exit code: 127
* Command standard error output: b'env: \xe2\x80\x98snap\xe2\x80\x99: No such file or directory\nError: Command not found\n'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/snap/snapcraft/8528/bin/snapcraft", line 8, in <module>
sys.exit(run())
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/snapcraft/cli.py", line 228, in run
_run_dispatcher(dispatcher)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/snapcraft/cli.py", line 204, in _run_dispatcher
dispatcher.run()
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run
return self._loaded_command.run(self._parsed_command_args)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 259, in run
super().run(parsed_args)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 132, in run
parts_lifecycle.run(self.name, parsed_args)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 208, in run
_run_command(
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 249, in _run_command
_run_in_provider(project, command_name, parsed_args)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 531, in _run_in_provider
with provider.launched_environment(
  File "/snap/snapcraft/8528/usr/lib/python3.8/contextlib.py", line 113, in __enter__
return next(self.gen)
  File "/snap/snapcraft/8528/lib/python3.8/site-packages/craft_providers/lxd/lxd_provider.py", line 140, in launched_environment
raise LXDError(str(error)) from error
craft_providers.lxd.errors.LXDError: Failed to set the snapd proxy.
* Command that failed: 'lxc --project snapcraft exec local:snapcraft-ros2-talker-listener-on-amd64-for-amd64-5643208 -- env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin SNAPCRAFT_MANAGED_MODE=1 SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 snap unset system proxy.http'
* Command exit code: 127
* Command standard error output: b'env: \xe2\x80\x98snap\xe2\x80\x99: No such file or directory\nError: Command not found\n'

Is lxd correctly installed and configured on your system? Return code 127 suggests that it’s not available, what does lxc list return?

2 Likes

Hello Claudio,

Thanks for your response. Here is what I had for lxc list:

$ lxc list
+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+
$ sudo snap install lxd
[sudo] password for rasid: 
snap "lxd" is already installed, see 'snap help refresh'
$ sudo lxd init --auto
$ lxc list
+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+

I was still getting the same error. Then, I removed lxd and reinstalled it:

$ sudo snap remove lxd
2022-11-12T09:38:18-08:00 INFO Waiting for "snap.lxd.daemon.service" to stop.
lxd removed
$ sudo snap install lxd
lxd 5.7-c62733b from Canonical✓ installed
$ sudo lxd init --auto

Then, the build worked :exploding_head:

$ SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 snapcraft
*EXPERIMENTAL* extension 'ros2-humble' enabled                                                                                 
Launching instance...                                                                                                          
*EXPERIMENTAL* extension 'ros2-humble' enabled                                                                                 
Installed package repositories                                                                                                 
Executed: pull ros-demos                                                                                                       
Executed: pull ros2-humble/ros2-launch                                                                                         
Executed: overlay ros-demos                                                                                                    
Executed: overlay ros2-humble/ros2-launch                                                                                      
Executed: build ros-demos                                                                                                      
Executed: build ros2-humble/ros2-launch                                                                                        
Executed: stage ros-demos                                                                                                      
Executed: stage ros2-humble/ros2-launch                                                                                        
Executed: prime ros-demos                                                                                                      
Executed: prime ros2-humble/ros2-launch                                                                                        
Executed parts lifecycle                                                                                                       
Generated snap metadata                                                                                                        
Unable to determine library dependencies for 'opt/ros/humble/local/lib/python3.10/dist-packages/action_msgs/libaction_msgs__rosidl_generator_py.so'                                                                                                            
Created snap package ros2-talker-listener_0.1_amd64.snap 

Moving onto the next issue (to be discovered :wink:)

1 Like