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

ImportError: cannot import name 'RoundTripDumper' with image #10

Open
vortex852456 opened this issue Oct 10, 2019 · 6 comments
Open

ImportError: cannot import name 'RoundTripDumper' with image #10

vortex852456 opened this issue Oct 10, 2019 · 6 comments

Comments

@vortex852456
Copy link

I tried the image but it doesn't work. See following history (shell from host-system):

root@localhost: cat docker-compose.yml | docker run -i funkwerk/compose_format
Traceback (most recent call last):
  File "/bin/compose_format", line 2, in <module>
    from compose_format import ComposeFormat
  File "/usr/lib/python3.5/site-packages/compose_format/__init__.py", line 1, in <module>
    from ruamel.yaml import RoundTripDumper, RoundTripLoader, dump, load
ImportError: cannot import name 'RoundTripDumper'
root@localhost:/var/docker/source/main# docker --version
Docker version 19.03.2, build 6a30dfc

@jessequinn
Copy link

same.

@jessequinn
Copy link

added PR #12 to fix this.

@jessequinn
Copy link

for temp use - https://hub.docker.com/repository/docker/damasu/compose_format

@Smasherr
Copy link

I faced the same issue. Thanks @jessequinn for fixing!

@tchia04
Copy link

tchia04 commented Jan 24, 2024

it doesn't work with "include"

❯ cat compose-git-include.yml  | docker run -i --platform linux/amd64 damasu/compose_format
Traceback (most recent call last):
  File "/bin/compose_format", line 27, in <module>
    formatted = formatter.format_string(data, strict=not args.non_strict)
  File "/usr/lib/python3.8/site-packages/compose_format/__init__.py", line 83, in format_string
    data = self.reorder(load(data, RoundTripLoader), strict=strict)
  File "/usr/lib/python3.8/site-packages/compose_format/__init__.py", line 94, in reorder
    while ComposeFormat.sorted_by_order(keys, order, strict) != keys:
  File "/usr/lib/python3.8/site-packages/compose_format/__init__.py", line 144, in sorted_by_order
    return sorted(keys, key=order_function)
  File "/usr/lib/python3.8/site-packages/compose_format/__init__.py", line 138, in order_function
    assert key in order, 'key: {0} not known'.format(key)
AssertionError: key: include not known

@zavoloklom
Copy link

I faced the same issue even with https://hub.docker.com/repository/docker/damasu/compose_format when I using long syntax for depends_on.

And because this task is still open after 5 years, I wrote my own linter/formatter
https://github.com/zavoloklom/docker-compose-linter/

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

No branches or pull requests

5 participants