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

Version 1.2.0 encounters an error when using the -f parameter #1059

Open
Mgrsc opened this issue Oct 14, 2024 · 6 comments
Open

Version 1.2.0 encounters an error when using the -f parameter #1059

Mgrsc opened this issue Oct 14, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@Mgrsc
Copy link

Mgrsc commented Oct 14, 2024

Describe the bug
In version 1.2.0, I encountered an error while using 'podman-compose -f lobe/compose.yaml pull', but it worked fine in version 1.1.0. Using the absolute path works normally, but using the relative path results in an error.

Traceback (most recent call last):
  File "/usr/local/bin/podman-compose", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/podman_compose.py", line 3526, in main
    asyncio.run(async_main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/podman_compose.py", line 3522, in async_main
    await podman_compose.run()
  File "/usr/local/lib/python3.11/dist-packages/podman_compose.py", line 1753, in run
    self._parse_compose_file()
  File "/usr/local/lib/python3.11/dist-packages/podman_compose.py", line 1848, in _parse_compose_file
    with open(filename, "r", encoding="utf-8") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'lobe/compose.yaml'

To Reproduce

  1. There is a compose.yaml file for lobe-chat in the lobe directory.
  2. Go back to the parent directory and run: podman-compose -f lobe/compose.yaml pull.

Expected behavior
nomal pull

Actual behavior
What is the behavior you actually got and that should not happen.

Output

$ podman-compose version
podman-compose version 1.2.0
podman version 5.2.2


$ podman-compose -f lobe/compose.yaml pull
Traceback (most recent call last):
  File "/usr/local/bin/podman-compose", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/podman_compose.py", line 3526, in main
    asyncio.run(async_main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/podman_compose.py", line 3522, in async_main
    await podman_compose.run()
  File "/usr/local/lib/python3.11/dist-packages/podman_compose.py", line 1753, in run
    self._parse_compose_file()
  File "/usr/local/lib/python3.11/dist-packages/podman_compose.py", line 1848, in _parse_compose_file
    with open(filename, "r", encoding="utf-8") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'lobe/compose.yaml'


**Environment:**
 - OS: Linux
 - podman version:  5.2.2
 - podman compose version: 1.2.0


@Mgrsc Mgrsc added the bug Something isn't working label Oct 14, 2024
@UgnilJoZ
Copy link

UgnilJoZ commented Oct 14, 2024

Seems like the relative path is used after the working directory is changed. Interestingly, there is a "TODO Remove" comment above the directory change in line 1815.

An alternative to deleting the line (maybe there is a reason why it wasn't removed) is making the filenames absolute:

@@ -1790,6 +1790,7 @@ class PodmanCompose:
             sys.exit(1)
         # make absolute
         relative_files = files
+        files = [os.path.realpath(filename) for filename in files]
         filename = files[0]
         project_name = args.project_name
         # no_ansi = args.no_ansi

This works on my machine™.

@midlan
Copy link

midlan commented Oct 15, 2024

run into same bug today

steps to reproduce:

echo -e "services:\n  a:\n    image: hello-world" > c.yml
podman-compose -f c.yml up #works
mkdir subdir
mv c.yml subdir/
podman-compose -f subdir/c.yml up #fails

removing https://github.com/containers/podman-compose/blob/main/podman_compose.py#L1818 fixes the issue

@midlan
Copy link

midlan commented Oct 15, 2024

I can confirm that with v1.1.0 it works, and the line is present there
https://github.com/containers/podman-compose/blob/v1.1.0/podman_compose.py#L1685
and has been there long time before

so it seems to be introduced by something else between v1.1.0 and v1.2.0

@JavierAntonYuste
Copy link

The same issue happened with the v1.3.0 update:

$ podman-compose -f devops_scripts/docker-compose.yaml up
Traceback (most recent call last):
  File "/home/user/anaconda3/envs/python3.10/bin/podman-compose", line 8, in <module>
    sys.exit(main())
  File "/home/user/anaconda3/envs/python3.10/lib/python3.10/site-packages/podman_compose.py", line 3711, in main
    asyncio.run(async_main())
  File "/home/user/anaconda3/envs/python3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/home/user/anaconda3/envs/python3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/user/anaconda3/envs/python3.10/lib/python3.10/site-packages/podman_compose.py", line 3707, in async_main
    await podman_compose.run()
  File "/home/user/anaconda3/envs/python3.10/lib/python3.10/site-packages/podman_compose.py", line 1859, in run
    self._parse_compose_file()
  File "/home/user/anaconda3/envs/python3.10/lib/python3.10/site-packages/podman_compose.py", line 1954, in _parse_compose_file
    with open(filename, "r", encoding="utf-8") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'devops_scripts/docker-compose.yaml'

When running podman-compose docker-compose.yml in the same folder, it works. The issue is completely related with the comments before. Removing the following lines in _parse_compose_file function fixes the issue:

# TODO: remove next line
os.chdir(dirname)

That change seems to be introduced in 10th of April 2023 but I was unable to reproduce it with podman-compose v1.2.0: 91bc6eb

abbra added a commit to abbra/freeipa-local-tests that referenced this issue Jan 9, 2025
abbra added a commit to abbra/freeipa-local-tests that referenced this issue Jan 9, 2025
abbra added a commit to abbra/FreeIPA-Cluster-Test that referenced this issue Jan 10, 2025
rjeffman pushed a commit to rjeffman/FreeIPA-Cluster-Test that referenced this issue Jan 10, 2025
@jonwiggins
Copy link

Looks like the old versions have been removed from brew.

I was able to install version 1.1.0 with:

brew uninstall podman-compose
rm '/opt/homebrew/bin/podman-compose'
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/07d7ff2920c03efa1765d856d66dc71e66d95b5b/Formula/p/podman-compose.rb
HOMEBREW_NO_AUTO_UPDATE=1 brew install -s podman-compose.rb
brew link podman-compose

This works until a fix is released.

@starnight
Copy link

starnight commented Jan 14, 2025

This issue can be reproduced in v1.3.0, too.

$ python --version
Python 3.13.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants