Revert to previous snapcraft version from source

I have an issue with the latest version of snapcraft 3.9.8 and would like to revert to version 3.9.5 to test this. Unfortunately, with snap revert I don’t have any revision to revert to. Therefore, I downloaded the release 3.9.5 from Github and tried to snap it: https://github.com/snapcore/snapcraft/releases/tag/3.9.5

However, snapping stops and I end up with this not very clear error:

Staging bash-completion 
Skipping stage snapcraft-libs (already ran)
Staging legacy-snapcraft 
Staging patchelf 
Staging snapcraft 
Priming bash-completion 
Priming snapcraft-libs 
Priming legacy-snapcraft 
Priming patchelf 
Priming snapcraft 
Compiling pyc files...
'version'
We would appreciate it if you anonymously reported this issue.
No other data than the traceback and the version of snapcraft in use will be sent.
Would you like to send this error data? (Yes/No/Always/View) [no]: yes

And the traceback:

Traceback (most recent call last):
  File "/snap/snapcraft/3970/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==3.9.1', 'console_scripts', 'snapcraft')()
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/snapcraft/cli/_command.py", line 87, in invoke
    return super().invoke(ctx)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 261, in snap
    _execute(steps.PRIME, parts=[], pack_project=True, output=output, **kwargs)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 66, in _execute
    lifecycle.execute(step, project_config, parts)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 132, in execute
    executor.run(step, part_names)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 188, in run
    self._create_meta(step, processed_part_names)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 346, in _create_meta
    create_snap_packaging(self.config)
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/snapcraft/internal/meta/_snap_packaging.py", line 87, in create_snap_packaging
    packaging.finalize_snap_meta_version()
  File "/snap/snapcraft/3970/lib/python3.6/site-packages/snapcraft/internal/meta/_snap_packaging.py", line 378, in finalize_snap_meta_version
    version = self._config_data["version"]
KeyError: 'version'

What does this mean?

I agree that’s not a very helpful error message :smiley:

Are you by chance using adopt-info with an empty parse-info, or parsing something a metadata file that does not contain a version?

If you don’t intend to get version information using parse-info, feel free to use version to specify it directly.

You may need to actually git clone it instead of downloading the zip/tarfile on the tag, if that’s by any chance what you did.

1 Like

FWIW on my laptop I cloned snapcraft and reverted to the tag you specified, and it builds fine.

-rw-r--r-- 1 alan alan 62414848 Mar 2 12:34 snapcraft_3.9.5_amd64.snap

2 Likes

When I read this, I confused this with the context of another thread/project, not snapcraft itself. Sorry :man_facepalming:

As @popey suggested, you need to build from git with the snapcraft.yaml as-is. Or replace ‘adopt-info’ with ‘version: 3.9.5’, and remove the snapcraft set-version from override-pull.

1 Like

Indeed, cloning and checking out the tag and then building worked. Now I’m really curious about the difference to downloading the .zip of the corresponding tag.

1 Like

the snapcraft.yaml includes an override script that tries to access the git metadata. When you download the zip file that metadata doesn’t exist so it fails.

2 Likes

Specifically, note that when you git clone the directory contains a .git/ directory. When you download the zip/tarball it doesn’t, so snapcraft can’t run commands like git describe and get sensible results.

3 Likes