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

Podman cannot start on Linux due to faulty homebrew.podman.service file #18802

Open
4 tasks done
radicaled opened this issue Nov 21, 2024 · 5 comments · May be fixed by #18865
Open
4 tasks done

Podman cannot start on Linux due to faulty homebrew.podman.service file #18802

radicaled opened this issue Nov 21, 2024 · 5 comments · May be fixed by #18865
Assignees
Labels
bug Reproducible Homebrew/brew bug help wanted We want help addressing this

Comments

@radicaled
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

brew config:

HOMEBREW_VERSION: 4.4.6
ORIGIN: https://github.com/Homebrew/brew
HEAD: cc0b5d6d05d1f3af5b2f53e9fbb1e7bfa0c332ab
Last commit: 4 days ago
Core tap JSON: 21 Nov 00:46 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :1
HOMEBREW_MAKE_JOBS: 16
Homebrew Ruby: 3.3.6 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: 16-core 64-bit zen5
Clang: N/A
Git: 2.34.1 => /bin/git
Curl: 7.81.0 => /bin/curl
Kernel: Linux 6.9.3-76060903-generic x86_64 GNU/Linux
OS: Pop!_OS 22.04 LTS (jammy)
Host glibc: 2.35
/usr/bin/gcc: 11.4.0
/usr/bin/ruby: N/A
glibc: N/A
gcc@11: N/A
gcc: 14.2.0_1
xorg: N/A

brew doctor:

Your system is ready to brew.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Installed podman and tried to start the service via brew services start podman.

What happened (include all command output)?

==> Successfully started podman (label: homebrew.podman)

Despite the message, podman did not start.

These loglines were present in systemd logs when using journalctl --user -u homebrew.podman

Nov 20 17:49:22 pop-os systemd[1687]: Started Homebrew generated unit for podman.
Nov 20 17:49:22 pop-os podman[113259]: Error: unknown flag: --time\
Nov 20 17:49:22 pop-os podman[113259]: See 'podman system service --help'
Nov 20 17:49:22 pop-os systemd[1687]: homebrew.podman.service: Main process exited, code=exited, status=125/n/a
Nov 20 17:49:22 pop-os systemd[1687]: homebrew.podman.service: Failed with result 'exit-code'.

Inspecting the Homebrew generated homebrew.podman.service reveals a problem with this particular line:

ExecStart=/home/linuxbrew/.linuxbrew/opt/podman/bin/podman system service --time\=0.

The backslash here prevents the systemd from starting the service.

What did you expect to happen?

Podman to start.

Step-by-step reproduction instructions (by running brew commands)

- `brew install podman`
- `brew services start podman`
@radicaled radicaled added the bug Reproducible Homebrew/brew bug label Nov 21, 2024
@SMillerDev SMillerDev transferred this issue from Homebrew/homebrew-core Nov 21, 2024
@MikeMcQuaid MikeMcQuaid transferred this issue from Homebrew/homebrew-services Nov 22, 2024
@ZhongRuoyu ZhongRuoyu transferred this issue from Homebrew/homebrew-core Nov 22, 2024
@ZhongRuoyu
Copy link
Member

ZhongRuoyu commented Nov 22, 2024

This seems to rather be an issue regarding how we handle shell quoting when generating systemd service files. The \= escape in the ExecStart line, generated by Utils::Shell#shell_quote 1, is not a valid escape in systemd 2 so it is instead treated as two characters.

So, I think we may need to "drop back to the original approach" as mentioned in #15880 (comment) (i.e., use the initial approach in #15875). EDIT: That doesn't handle the case where there is single quote in the argument. Escapes are hard to handle :(

EDIT 2: Perhaps we could implement a systemd_quote method that does the same as quote_command_line in systemd 3?

Footnotes

  1. service: handle quoting in service file, too. #15880

  2. https://www.freedesktop.org/software/systemd/man/latest/systemd.syntax.html#Quoting

  3. https://github.com/systemd/systemd/blob/v256.8/src/basic/escape.c#L592

@ZhongRuoyu ZhongRuoyu added the help wanted We want help addressing this label Nov 22, 2024
ZhongRuoyu added a commit to Homebrew/homebrew-core that referenced this issue Nov 22, 2024
@ZhongRuoyu
Copy link
Member

ZhongRuoyu commented Nov 22, 2024

@radicaled, the podman service file has been fixed by Homebrew/homebrew-core#198617. Please do brew update, followed by brew reinstall podman.

As for the broader issue regarding how escapes like this are handled, do you mind if we continue to use this issue to track that? If you prefer it to be done elsewhere, please feel free to close this and I'll open another issue.

@radicaled
Copy link
Author

As for the broader issue regarding how escapes like this are handled, do you mind if we continue to use this issue to track that? If you prefer it to be done elsewhere, please feel free to close this and I'll open another issue.

By all means, do whatever makes your life easier.

Thank you for fixing the bug, by the way!

@tomasdziovenas
Copy link

tomasdziovenas commented Nov 27, 2024

@radicaled, the podman service file has been fixed by Homebrew/homebrew-core#198617. Please do brew update, followed by brew reinstall podman.

As for the broader issue regarding how escapes like this are handled, do you mind if we continue to use this issue to track that? If you prefer it to be done elsewhere, please feel free to close this and I'll open another issue.

@ZhongRuoyu
Hello, I just tried install nginx using the homebrew, the same thing happens with those escapes:

[Unit]
Description=Homebrew generated unit for nginx

[Install]
WantedBy=default.target

[Service]
Type=simple
ExecStart=/home/linuxbrew/.linuxbrew/opt/nginx/bin/nginx -g daemon\ off\;
WorkingDirectory=/home/linuxbrew/.linuxbrew

as you can see execstart has wrong escapes

should be:
/home/linuxbrew/.linuxbrew/opt/nginx/bin/nginx -g 'daemon off;'

therefore service never starts:

nginx (homebrew.nginx)
Running: ✘
Loaded: ✘
Schedulable: ✘

logs( /home/linuxbrew/.linuxbrew/var/log/nginx/error.log)

2024/11/27 17:39:38 [emerg] 24058#0: unexpected end of parameter, expecting ";" in command line

but if I start it manually, it works:
/home/linuxbrew/.linuxbrew/opt/nginx/bin/nginx -g 'daemon off;'

@cho-m
Copy link
Member

cho-m commented Nov 27, 2024

Other reports of same issue:


Wrapping with quotes is possible if following rules of systemd quoting -https://www.freedesktop.org/software/systemd/man/latest/systemd.syntax.html#Quoting

double quotes ("…") and single quotes ('…') may be used to wrap a whole item (the opening quote may appear only at the beginning or after whitespace that is not quoted, and the closing quote must be followed by whitespace or the end of line), in which case everything until the next matching quote becomes part of the same item. Quotes themselves are removed. C-style escapes are supported. The table below contains the list of known escape patterns. Only escape patterns which match the syntax in the table are allowed; other patterns may be added in the future and unknown patterns will result in a warning. In particular, any backslashes should be doubled

I believe some old versions of systemd also have a bug when quoting the command itself.


Environment variables are often mentioned as workaround using the rules of ${ ... } handling - https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Command%20lines

Use "${FOO}" as part of a word, or as a word of its own, on the command line, in which case it will be erased and replaced by the exact value of the environment variable (if any) including all whitespace it contains, always resulting in exactly a single argument.

@ZhongRuoyu ZhongRuoyu self-assigned this Dec 3, 2024
ZhongRuoyu added a commit that referenced this issue Dec 3, 2024
Fixes #18802 (affected formulae still need rebuilding).
ZhongRuoyu added a commit that referenced this issue Dec 3, 2024
Fixes #18802 (affected formulae still need rebuilding).
@ZhongRuoyu ZhongRuoyu linked a pull request Dec 3, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible Homebrew/brew bug help wanted We want help addressing this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants