Operation not permitted: 'snap/snapcraft.yaml'

When i generated a snap according to “IoT Graphics with Ubuntu Frame” document. I got a error when i used “snapcraft” command.

Traceback (most recent call last): File “/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/cli/legacy.py”, line 27, in legacy_run run() File “/snap/snapcraft/8619/lib/python3.8/site-packages/click/core.py”, line 1130, in call return self.main(*args, **kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/click/core.py”, line 1055, in main rv = self.invoke(ctx) File “/snap/snapcraft/8619/lib/python3.8/site-packages/click/core.py”, line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File “/snap/snapcraft/8619/lib/python3.8/site-packages/click/core.py”, line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File “/snap/snapcraft/8619/lib/python3.8/site-packages/click/core.py”, line 760, in invoke return __callback(*args, **kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/cli/lifecycle.py”, line 406, in snap _execute(steps.PRIME, parts=tuple(), pack_project=True, output=output, **kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/cli/lifecycle.py”, line 95, in _execute project = get_project(is_managed_host=is_managed_host, **kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/cli/_options.py”, line 400, in get_project project = Project( File “/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/project/_project.py”, line 58, in init self.info = ProjectInfo(snapcraft_yaml_file_path=snapcraft_yaml_file_path) File “/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/project/_project_info.py”, line 30, in init self.__raw_snapcraft = yaml_utils.load_yaml_file(snapcraft_yaml_file_path) File “/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/yaml_utils/init.py”, line 45, in load_yaml_file with open(yaml_file_path, “rb”) as fp: PermissionError: [Errno 1] Operation not permitted: ‘snap/snapcraft.yaml’ During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/connection.py”, line 174, in _new_conn conn = connection.create_connection( File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/util/connection.py”, line 95, in create_connection raise err File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/util/connection.py”, line 85, in create_connection sock.connect(sa) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 703, in urlopen httplib_response = self._make_request( File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 386, in _make_request self._validate_conn(conn) File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 1042, in _validate_conn conn.connect() File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/connection.py”, line 358, in connect self.sock = conn = self._new_conn() File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/connection.py”, line 179, in _new_conn raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f4f0c4042e0>, ‘Connection to sentry.io timed out. (connect timeout=5)’) During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/snap/snapcraft/8619/lib/python3.8/site-packages/requests/adapters.py”, line 489, in send resp = conn.urlopen( File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/connectionpool.py”, line 787, in urlopen retries = retries.increment( File “/snap/snapcraft/8619/lib/python3.8/site-packages/urllib3/util/retry.py”, line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘sentry.io’, port=443): Max retries exceeded with url: /api/277754/store/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f4f0c4042e0>, ‘Connection to sentry.io timed out. (connect timeout=5)’)) During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/snap/snapcraft/8619/lib/python3.8/site-packages/raven/base.py”, line 737, in send_remote transport.send(url, data, headers) File “/snap/snapcraft/8619/lib/python3.8/site-packages/raven/transport/requests.py”, line 34, in send requests.post(url, data=data, headers=headers, File “/snap/snapcraft/8619/lib/python3.8/site-packages/requests_unixsocket/init.py”, line 60, in post return request(‘post’, url, data=data, json=json, **kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/requests_unixsocket/init.py”, line 46, in request return session.request(method=method, url=url, **kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/requests/sessions.py”, line 587, in request resp = self.send(prep, **send_kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/raven/breadcrumbs.py”, line 341, in send resp = real_send(self, request, *args, **kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/requests/sessions.py”, line 701, in send r = adapter.send(request, **kwargs) File “/snap/snapcraft/8619/lib/python3.8/site-packages/requests/adapters.py”, line 553, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host=‘sentry.io’, port=443): Max retries exceeded with url: /api/277754/store/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f4f0c4042e0>, ‘Connection to sentry.io timed out. (connect timeout=5)’)) [“PermissionError: [Errno 1] Operation not permitted: ‘snap/snapcraft.yaml’”, ’ File “snapcraft_legacy/cli/legacy.py”, line 27, in legacy_run’, ’ File “click/core.py”, line 1130, in call’, ’ File “click/core.py”, line 1055, in main’, ’ File “click/core.py”, line 1657, in invoke’, ’ File “click/core.py”, line 1404, in invoke’, ’ File “click/core.py”, line 760, in invoke’, ’ File “snapcraft_legacy/cli/lifecycle.py”, line 406, in snap’, ’ File “snapcraft_legacy/cli/lifecycle.py”, line 95, in _execute’, ’ File “snapcraft_legacy/cli/_options.py”, line 400, in get_project’, ’ File “snapcraft_legacy/project/_project.py”, line 58, in init’, ’ File “snapcraft_legacy/project/_project_info.py”, line 30, in init’, ’ File “snapcraft_legacy/yaml_utils/init.py”, line 45, in load_yaml_file’]

How do i solve the problem?

there seems to be an outage reported on status.snapcraft.io … try again a bit later …

This is an interesting error, are the yaml file permissions correct? And what version of Snapcraft are you using? If I try to reproduce the problem on 7.2.x using bad permissions, I get this:

$ snapcraft
Permission denied: 'snap/snapcraft.yaml'.
Full execution log: '/home/claudio/.local/state/snapcraft/log/snapcraft-20230215-095245.055746.log'

I tried it just. But it still not work correctly.

Hi, the snapcraft version is 7.2.9. it’s diffrent with my message.

Would you please share the file permissions for ‘snap/snapcraft.yaml’.

Is this the document you are following?

Would it be possible for you to share your yaml file, or a similar file that also causes the problem so we can reproduce it locally?

(please use triple-backquotes (```) to post formatted data to keep the original formatting)

name: iot-example-graphical-snap
version: git
summary: IoT example using Qt
description: IoT example using Qt
confinement: strict
compression: lzo
grade: stable
base: core20
apps:
iot-example-graphical-snap:
command-chain: &_command-chain
- bin/wayland-launch
command: &_command usr/games/bomber
plugs: &_plugs
- opengl
- wayland
- audio-playback
- network-bind
environment: &_environment
QT_QPA_PLATFORM: wayland
QT_PLUGIN_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5/plugins/
QT_QPA_PLATFORM_PLUGIN_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5/plugins/platforms/
QML2_IMPORT_PATH: ${SNAP}/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/qt5/qml
daemon:
daemon: simple
restart-delay: 3s
restart-condition: always
command-chain: *_command-chain
command: *_command
plugs: *_plugs
environment: *_environment
plugs:
graphics-core20:
interface: content
target: $SNAP/graphics
default-provider: mesa-core20
environment:
LD_LIBRARY_PATH: $SNAP/graphics/lib
LIBGL_DRIVERS_PATH: $SNAP/graphics/dri\

[details=“Summary”]
This text will be hidden
[/details]
LIBVA_DRIVERS_PATH: $SNAP/graphics/dri
__EGL_VENDOR_LIBRARY_DIRS: $SNAP/graphics/glvnd/egl_vendor.d
XDG_CACHE_HOME: $SNAP_USER_COMMON/.cache
XDG_CONFIG_HOME: $SNAP_USER_DATA/.config
XDG_CONFIG_DIRS: $SNAP/etc/xdg
XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb
layout:
/usr/share/libdrm:
bind: $SNAP/graphics/libdrm
/usr/share/drirc.d:
bind: $SNAP/graphics/drirc.d
/usr/share/fonts:
bind: $SNAP/usr/share/fonts
/usr/share/icons:
bind: $SNAP/usr/share/icons
/usr/share/sounds:
bind: $SNAP/usr/share/sounds
/etc/fonts:
bind: $SNAP/etc/fonts
/usr/share/bomber:
bind: $SNAP/usr/share/bomber

parts:
bomber:
plugin: nil
stage-packages:
- bomber
- qtwayland5
wayland-launch:
plugin: dump
source: wayland-launch
override-build: |
# The plugs needed to run Wayland. (wayland-launch checks them, setup.sh connects them)
# You may add further plugs here if you want these options
PLUGS=“opengl wayland graphics-core20”
sed --in-place “s/%PLUGS%/$PLUGS/g” $SNAPCRAFT_PART_BUILD/bin/wayland-launch
sed --in-place “s/%PLUGS%/$PLUGS/g” $SNAPCRAFT_PART_BUILD/bin/setup.sh
snapcraftctl build
stage-packages:
- inotify-tools
cleanup:
after:
- bomber
- wayland-launch
plugin: nil
build-snaps: [ mesa-core20 ]
override-prime: |
set -eux
cd /snap/mesa-core20/current/egl/lib
find . -type f,l -exec rm -f $SNAPCRAFT_PRIME/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/{} ;
rm -fr “$SNAPCRAFT_PRIME/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/dri”
for CRUFT in bug drirc.d glvnd libdrm lintian man; do
rm -rf “$SNAPCRAFT_PRIME/usr/share/$CRUFT”
done
for CRUFT in alsa bash-completion dbus-1 help kconf_update kservices5 libinput locale openal pkgconfig
applications doc kf5 kservicetypes5 libthai metainfo perl qlogging-categories5 thumbnailers xml
apport config.kcfg doc-base GConf gnupg info knotifications5 kxmlgui5 libwacom themes sounds ; do
rm -rf “$SNAPCRAFT_PRIME/usr/share/$CRUFT”
done
architectures:

  • build-on: amd64
  • build-on: armhf
  • build-on: arm64

See comment above regarding the snapcraft.yaml: please use triple-backquotes (```) to post formatted data to keep the original formatting

  • The first issue is thought to be a connectivity issue. Can you confirm that that part is now working?
  • What snapcraft backend are you using (Multipass / Lxd) and what version?

Thanks for your reponse.

1、how can i confirm the connect working? 2、I used Multipass and it’s 1.11.0

Where is your snapcraft.yaml located?

Multipass is a confined snap and may not have access to files outside your home directory. For example, if your snapcraft.yaml is in a mounted directory, you will get an error. I believe the error is about the source path not existing, not a snapcraft.yaml permission error. Still, I thought I would ask!

Ah interesting, this could explain what happened. But if this is the case, the error could be handled in a better way, ideally telling that the project could not be mounted in the build instance (or at least reporting a non-existing file instead of bad permissions).