Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charm version compatibility output is unfortunately not compatible with charmcraft 2.0 #636

Closed
fnordahl opened this issue Sep 29, 2022 · 0 comments · Fixed by #637
Closed

Comments

@fnordahl
Copy link
Collaborator

The code in charmcraft 2.0 looks like this:

            output = self._execute("charm version").strip()
            _, tools_version = output.split("\n")

And our current compatibility code look like this:

# ensure compatibility with anyone parsing this output expecting the
# charm-tools version on the second line ref:
# https://github.com/canonical/charmcraft/blob/dbf82a0fb/charmcraft/reactive_plugin.py#L65
print("")
print("charm-tools {}".format(
format_version(cached_charm_tools_version(), args.format)))

Due to charmcraft's use of strip as opposed to rstrip, this does not work.

Example:

>>> s = subprocess.run(["/bin/bash", "-c", "charm version"], check=True, capture_output=True, universal_newlines=True)
>>> s
CompletedProcess(args=['/bin/bash', '-c', 'charm version'], returncode=0, stdout='\ncharm-tools 3.0.0+snap-661+git-1-b7025b2\n', stderr='')
>>> s.stdout.strip()
'charm-tools 3.0.0+snap-661+git-1-b7025b2'

Now if we fudge the output by adding something on the first line:

>>> s = subprocess.run(["/bin/bash", "-c", "charm version"], check=True, capture_output=True, universal_newlines=True)
>>> s
CompletedProcess(args=['/bin/bash', '-c', 'charm version'], returncode=0, stdout='-\ncharm-tools 3.0.0+snap-x1+git-3-e1c7ee0\n', stderr='')
>>> s.stdout.strip()
'-\ncharm-tools 3.0.0+snap-x1+git-3-e1c7ee0'
>>> _, tools_version = s.stdout.strip().split('\n')
>>> tools_version
'charm-tools 3.0.0+snap-x1+git-3-e1c7ee0'
fnordahl added a commit to fnordahl/charm-tools that referenced this issue Sep 29, 2022
Due to how some other projects parse our version string the
current format may break people.

Fixes juju#636
fnordahl added a commit that referenced this issue Sep 29, 2022
Due to how some other projects parse our version string the
current format may break people.

Fixes #636
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant