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

Fix building and running on systems without systemd #59

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

Foxinatel
Copy link
Contributor

Addresses: #51

Currently trying to build without the systemd feature causes compile time errors. The first commit in this PR simply fixes those.

The seconds commit turns tracing-journald into an optional dependency which is only included when building with the systemd feature.

The third commit removes the runtime panic that occurs when journald is not available on a system, falling back to a default and providing a warning instead of a hard crash. This is useful on distros like Artix or Devuan where many features of systemd are available (dbus, logind), such that building with the systemd feature is preferable, but journald is not present.

@jackpot51 jackpot51 requested a review from a team August 9, 2024 21:27
@ids1024
Copy link
Member

ids1024 commented Aug 9, 2024

I suppose if journald isn't present, we should probably try logging to syslog? That isn't a blocker for this though. Whatever we do it should be consistent with cosmic-comp, etc.

I'm interested to see what other parts of Cosmic may have issues without systemd. I know cosmic-comp works on Gentoo OpenRC and (at least when I last tried it) FreeBSD, but I haven't tried running all the Cosmic components on either.

@Foxinatel
Copy link
Contributor Author

Just noticed that the cfg directive applies to the entire if-let-else block in the third commit and therefore no logging will happen at all if building without the systemd feature. I'll update the commit for that tomorrow.

@Calandracas606
Copy link

working on packaging this void linux, which also lacks systemd
void-linux/void-packages#51735

no build errors, but failing at runtime when launching cosmic-session

Error: 
   0: failed to connect to journald
   1: No such file or directory (os error 2)

Location:
   src/main.rs:46

@fulalas
Copy link

fulalas commented Aug 10, 2024

@Calandracas606, I believe you should remove the last 2 lines in Cargo.toml:

systemd = ["dep:zbus_systemd", "dep:tracing-journald"]
default = ["systemd"]

Still, it fails to run due to some no such file or directory:

Screenshot_2024-08-10_17-02-38

Not sure what's going on tbh.

@Foxinatel
Copy link
Contributor Author

I believe you should remove the last 2 lines in Cargo.toml

It would be a better idea to just pass the --no-default-features flag to cargo build to exclude the systemd feature

Still, it fails to run due to some no such file or directory:
Not sure what's going on tbh.

I can't reproduce this on my own system (Artix) with these patches applied. If you're able to get a backtrace with debugging info then I'd be happy to take a look.

@fulalas
Copy link

fulalas commented Aug 10, 2024

@Foxinatel, do you mind explaining the step by step to achieve that? Thanks!

@fulalas
Copy link

fulalas commented Aug 10, 2024

EDIT: Ignore below. We need to call start-cosmic and not cosmic-session. All good now! Thanks :)

Not sure if this helps (COLORBT_SHOW_HIDDEN=1 RUST_BACKTRACE=full cosmic-session):

�[2m2024-08-10T20:50:02.094445Z�[0m �[31mERROR�[0m �[2mpanic�[0m�[2m:�[0m thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }': /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/color-eyre-0.6.2/src/config.rs:284
   0: <backtrace::capture::Backtrace as core::default::Default>::default
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/capture.rs:410:9
   1: log_panics::Config::install_panic_hook::{{closure}}
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/log-panics-2.1.0/src/lib.rs:115:29
   2: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/alloc/src/boxed.rs:2164:9
      std::panicking::rust_panic_with_hook
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panicking.rs:805:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panicking.rs:671:13
   4: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/sys/backtrace.rs:170:18
   5: rust_begin_unwind
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panicking.rs:662:5
   6: core::panicking::panic_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/panicking.rs:74:14
   7: core::result::unwrap_failed
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/result.rs:1679:5
   8: core::result::Result<T,E>::unwrap
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/result.rs:1102:23
      <color_eyre::config::SourceSection as core::fmt::Display>::fmt
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/color-eyre-0.6.2/src/config.rs:284:27
   9: core::fmt::rt::Argument::fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/rt.rs:173:76
      core::fmt::write
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:1178:21
  10: <&mut W as core::fmt::Write::write_fmt::SpecWriteFmt>::spec_write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:226:21
  11: core::fmt::Write::write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:231:9
  12: <color_eyre::config::StyledFrame as core::fmt::Display>::fmt
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/color-eyre-0.6.2/src/config.rs:262:13
  13: core::fmt::rt::Argument::fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/rt.rs:173:76
      core::fmt::write
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:1178:21
  14: <&mut W as core::fmt::Write::write_fmt::SpecWriteFmt>::spec_write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:226:21
  15: core::fmt::Write::write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:231:9
  16: <color_eyre::config::BacktraceFormatter as core::fmt::Display>::fmt
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/color-eyre-0.6.2/src/config.rs:1171:13
  17: core::fmt::rt::Argument::fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/rt.rs:173:76
      core::fmt::write
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:1178:21
  18: <&mut W as core::fmt::Write::write_fmt::SpecWriteFmt>::spec_write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:226:21
  19: core::fmt::Write::write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:231:9
  20: color_eyre::handler::<impl eyre::EyreHandler for color_eyre::Handler>::debug
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/color-eyre-0.6.2/src/handler.rs:119:13
  21: eyre::fmt::<impl eyre::error::ErrorImpl<()>>::debug::{{closure}}
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eyre-0.6.8/src/fmt.rs:15:28
  22: core::option::Option<T>::map
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/option.rs:1107:29
  23: eyre::fmt::<impl eyre::error::ErrorImpl<()>>::debug
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eyre-0.6.8/src/fmt.rs:13:9
  24: eyre::error::<impl core::fmt::Debug for eyre::Report>::fmt
             at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eyre-0.6.8/src/error.rs:490:9
  25: core::fmt::rt::Argument::fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/rt.rs:173:76
      core::fmt::write
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/fmt/mod.rs:1178:21
  26: std::io::Write::write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/io/mod.rs:1823:15
      <&std::io::stdio::Stderr as std::io::Write>::write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/io/stdio.rs:1018:9
  27: <std::io::stdio::Stderr as std::io::Write>::write_fmt
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/io/stdio.rs:992:9
      std::io::stdio::attempt_print_to_stderr
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/io/stdio.rs:1144:13
  28: <core::result::Result<T,E> as std::process::Termination>::report
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/process.rs:2470:17
  29: std::rt::lang_start::{{closure}}
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/rt.rs:164:18
  30: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panicking.rs:554:40
      std::panicking::try
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panicking.rs:518:19
      std::panic::catch_unwind
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panic.rs:345:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/rt.rs:143:48
      std::panicking::try::do_call
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panicking.rs:554:40
      std::panicking::try
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panicking.rs:518:19
      std::panic::catch_unwind
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/panic.rs:345:14
      std::rt::lang_start_internal
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/rt.rs:143:20
  31: std::rt::lang_start
             at /rustc/ca5d25e2c41f5a6b4ce65c681bf2f94c7ead1f14/library/std/src/rt.rs:163:17
  32: main
  33: __libc_start_call_main
  34: __libc_start_main@GLIBC_2.2.5
  35: _start
             at /tmp/glibc-2.40/csu/../sysdeps/x86_64/start.S:115

Why is it looking for /root/.cargo when in the testing machine there's no such thing?

@Foxinatel
Copy link
Contributor Author

Glad you managed to figure it out :)

@Quackdoc
Copy link

I can confirm at least that on artix that this + the PR for cosmic-notifications allows cosmic de to work, so it would be nice if these can be reviewed

Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for working on this!

@Drakulix Drakulix merged commit 65d4ee1 into pop-os:master Aug 29, 2024
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 this pull request may close these issues.

6 participants