snapcraft snap with an unexisting dir shows a traceback

Bug #1717413 reported by Leo Arias
This bug affects 2 people
Affects Status Importance Assigned to Milestone
In Progress
Sergio Schvezov

Bug Description

To reproduce, run:

⟫ snapcraft snap idontexist
Traceback (most recent call last):
  File "/snap/snapcraft/501/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.34', 'console_scripts', 'snapcraft')()
  File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/", line 2631, in load_entry_point
    return ep.load()
  File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/", line 2291, in load
    return self.resolve()
  File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/cli/", line 19, in <module>
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/", line 697, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/", line 535, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/cli/", line 132, in snap
    project_options, directory=directory, output=output)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/internal/", line 345, in snap
    snap = _snap_data_from_dir(prime_dir)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/internal/", line 330, in _snap_data_from_dir
    with open(os.path.join(directory, 'meta', 'snap.yaml')) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/elopio/tmp/idontexist/meta/snap.yaml'

This should show a nicer message.

Tags: bitesize ui
Changed in snapcraft:
status: New → Confirmed
Revision history for this message
Christian Dywan (kalikiana) wrote :

I'd suggest raising SnapcraftEnvironmentError("The directory idontexist doesn't contain a file meta/snap.yaml. If you meant to build a snap in the given folder, cd into the folder instead and re-run Snapcraft."

and ideally also checking the existence of the folder separately for most clarity.

Leo Arias (elopio)
Changed in snapcraft:
status: Confirmed → Triaged
Changed in snapcraft:
importance: Undecided → Medium
status: Triaged → In Progress
assignee: nobody → Sergio Schvezov (sergiusens)
milestone: none → 2.35
Changed in snapcraft:
milestone: 2.35 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers