snapcraft snap with an unexisting dir shows a traceback

Bug #1717413 reported by Leo Arias
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
In Progress
Medium
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/__init__.py", 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/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/snap/snapcraft/501/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/cli/__main__.py", line 19, in <module>
    run(prog_name='snapcraft')
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 132, in snap
    project_options, directory=directory, output=output)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/internal/lifecycle.py", line 345, in snap
    snap = _snap_data_from_dir(prime_dir)
  File "/snap/snapcraft/501/lib/python3.6/site-packages/snapcraft/internal/lifecycle.py", 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
Cris Dywan (kalikiana)
Changed in snapcraft:
status: New → Confirmed
Revision history for this message
Cris 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

Remote bug watches

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