nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.18k stars 1.85k forks source link

bug: Linux Mint 21.3 w/Home-Manager Crashes to Fallback & systemd-coredump #5102

Open davidjmeier opened 8 months ago

davidjmeier commented 8 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

New to Nix. Installed Nix via Determinate systems, made no changes. Went directly to installing Home-Manager stand-alone via the Flakes instructions. Upon logout / login or reboot immediately after enabling the default Home-Manager configuration (no changes) Cinnamon now crashes and goes to fallback mode.

If I force a Cinnamon refresh (Ctrl-Alt-ESC) I get this line immediately in /var/log/dmesg: syslog:Mar 7 11:00:16 myhost systemd-coredump[8997]: Process 8941 (cinnamon) of user 1000 dumped core.

TIA!

Maintainer CC

No response

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.5.0-21-generic, Linux Mint, 21.3 (Virginia), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.20.3`
 - nixpkgs: `/home/username/.nix-defexpr/channels/nixpkgs`
rycee commented 8 months ago

Sorry to hear about the crashing. I'm not exactly certain what Cinnamon is but the default HM configuration doesn't do very much at all. It is more or less limited to installing the man tool and a few basic symlinks like ~/.cache/.keep. Does it work OK if you don't use Home Manager? For example, just installing some package using nix profile install?

Also, any other hint in the systemd journal or something? Just knowing that it crashes unfortunately isn't very actionable.

davidjmeier commented 8 months ago

Thanks for the response @rycee!

Yeah, I really wasn't sure exactly where to start. Just installing Nix and tossing a few packages into the system works fine. I removed everything and basically made one change at a time and then rebooted until the desktop environment (Cinnamon) started crashing again. It's immediately after HM is installed with the default configuration - which, agreed, doesn't have much to it. I was wondering if there was chance HM was taking over something specific that Cinnamon no longer had access to, was removed or moved.

Is there anything specific I can look for in logs that could help pinpoint this?

Thanks much!

DanSM-5 commented 8 months ago

I am having the same issue. I recently did a clean install in my laptop and decided to use home-manager (standalone install) this time (I used to do nix-env for installs). It took me a while but I also concluded that it happens after install home-manger and logout and login or just doing a restart.

I have compiled a couple of information in a reddit post https://www.reddit.com/r/Nix/comments/1bnwzxa/install_homemanager_in_linux_mint_makes_cinnamon

I found in some forums that they suggest looking into ~/.xsession-errors for clues. This is mine:

dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting XAUTHORITY=/home/foo/.Xauthority
/etc/X11/Xsession.d/30x11-common_xresources: line 16: has_option: command not found
/etc/X11/Xsession.d/75dbus_dbus-launch: line 9: has_option: command not found
dbus-update-activation-environment: setting GTK_MODULES=gail:atk-bridge
dbus-update-activation-environment: setting QT_ACCESSIBILITY=1
/etc/X11/Xsession.d/90x11-common_ssh-agent: line 9: has_option: command not found
dbus-update-activation-environment: setting SHELL=/usr/bin/zsh
dbus-update-activation-environment: setting QT_ACCESSIBILITY=1
dbus-update-activation-environment: setting XDG_CONFIG_DIRS=/etc/xdg/xdg-cinnamon:/etc/xdg
dbus-update-activation-environment: setting XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session2
dbus-update-activation-environment: setting LANGUAGE=en_US
dbus-update-activation-environment: setting DESKTOP_SESSION=cinnamon
dbus-update-activation-environment: setting GTK_MODULES=gail:atk-bridge
dbus-update-activation-environment: setting PWD=/home/foo
dbus-update-activation-environment: setting NIX_PROFILES=/nix/var/nix/profiles/default /home/foo/.nix-profile
dbus-update-activation-environment: setting XDG_SESSION_DESKTOP=cinnamon
dbus-update-activation-environment: setting LOGNAME=foo
dbus-update-activation-environment: setting XDG_SESSION_TYPE=x11
dbus-update-activation-environment: setting GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
dbus-update-activation-environment: setting XAUTHORITY=/home/foo/.Xauthority
dbus-update-activation-environment: setting XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/foo
dbus-update-activation-environment: setting GDM_LANG=en_US
dbus-update-activation-environment: setting HOME=/home/foo
dbus-update-activation-environment: setting IM_CONFIG_PHASE=1
dbus-update-activation-environment: setting LANG=en_US.UTF-8
dbus-update-activation-environment: setting NIX_SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
dbus-update-activation-environment: setting XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
dbus-update-activation-environment: setting XDG_SESSION_CLASS=user
dbus-update-activation-environment: setting USER=foo
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting SHLVL=1
dbus-update-activation-environment: setting XDG_RUNTIME_DIR=/run/user/1000
dbus-update-activation-environment: setting GTK3_MODULES=xapp-gtk3-module
dbus-update-activation-environment: setting XDG_DATA_DIRS=/usr/share/cinnamon:/usr/share/gnome:/home/foo/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/home/foo/.nix-profile/share:/nix/var/nix/profiles/default/share
dbus-update-activation-environment: setting PATH=/home/foo/.local/bin:/home/foo/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
dbus-update-activation-environment: setting GDMSESSION=cinnamon
dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting _=/usr/bin/dbus-update-activation-environment
[cinnamon-settings-daemon-smartcard] Failed to start: no suitable smartcard driver could be found
dbus-daemon[114979]: Activating service name='org.a11y.atspi.Registry' requested by ':1.2' (uid=1000 pid=114965 comm="csd-keyboard " label="unconfined")
[cinnamon-settings-daemon-smartcard] Failed to start: no suitable smartcard driver could be found
dbus-daemon[114979]: Successfully activated service 'org.a11y.atspi.Registry'
Gjs-Message: 22:20:37.553: Profiler is disabled. Not setting up signals.
Gjs-Message: 22:20:37.695: JS LOG: About to start Cinnamon (X11 backend)
Gjs-Message: 22:20:37.791: JS LOG: [LookingGlass/info] Cinnamon.AppSystem.get_default() started in 93 ms
Gjs-Message: 22:20:37.796: JS LOG: [LookingGlass/info] loading user theme: /usr/share/themes/Mint-Y-Dark-Blue/cinnamon/cinnamon.css
Gjs-Message: 22:20:37.823: JS LOG: [LookingGlass/info] added icon directory: /usr/share/themes/Mint-Y-Dark-Blue/cinnamon
Gjs-Message: 22:20:37.921: JS LOG: [LookingGlass/info] loaded at Wed Mar 27 2024 22:20:37 GMT-0400 (Eastern Daylight Time)
Gjs-Message: 22:20:37.921: JS LOG: Cinnamon started at Wed Mar 27 2024 22:20:37 GMT-0400 (Eastern Daylight Time)
Gjs-Message: 22:20:37.928: JS LOG: [LookingGlass/info] ExtensionSystem started in 1 ms
Gjs-Message: 22:20:37.928: JS LOG: [LookingGlass/info] DeskletManager started in 0 ms
Gjs-Message: 22:20:37.928: JS LOG: [LookingGlass/info] SearchProviderManager started in 0 ms

** (at-spi2-registryd:115010): WARNING **: 22:20:38.074: Failed to register client: GDBus.Error:org.gnome.SessionManager.AlreadyRegistered: Unable to register client

** (at-spi2-registryd:115010): WARNING **: 22:20:38.074: Unable to register client with session manager
** Message: 22:20:38.557: nemo-desktop: session is cinnamon, establishing proxy

ERROR: NVIDIA driver is not loaded

blueman-applet 22.20.39 WARNING  PluginManager:151 __load_plugin: Not loading PPPSupport because its conflict has higher priority
blueman-applet 22.20.39 WARNING  PluginManager:151 __load_plugin: Not loading DhcpClient because its conflict has higher priority

(nm-applet:115136): libnotify-WARNING **: 22:20:39.500: Failed to connect to proxy

(nm-applet:115136): nm-applet-WARNING **: 22:20:39.502: Failed to show notification: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Notifications was not provided by any .service files
cinnamon-session[114734]: WARNING: t+4.98662s: Detected that screensaver has appeared on the bus
Unable to open desktop file /usr/share/applications/mate-terminal.desktop for panel launcher: No such file or directory
Unable to open desktop file /usr/share/applications/caja-browser.desktop for panel launcher: No such file or directory

(ulauncher:115143): Gdk-CRITICAL **: 22:20:39.945: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed

(blueman-tray:115471): Gdk-CRITICAL **: 22:20:39.945: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed

(ulauncher:115143): Gdk-CRITICAL **: 22:20:40.041: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed

(metacity:115488): metacity-WARNING **: 22:20:44.538: Buggy client sent a _NET_ACTIVE_WINDOW message with a timestamp of 0 for 0x4c00011 (mintMenu.py)

** (nemo-desktop:115130): WARNING **: 22:20:45.011: nemo-desktop: Desktop failsafe timeout reached, applying fallback behavior

(metacity:115488): metacity-WARNING **: 22:20:45.084: last_user_time (1403678055) is greater than comparison timestamp (107537013). This most likely represents a buggy client sending inaccurate timestamps in messages such as _NET_ACTIVE_WINDOW. Trying to work around...

(metacity:115488): metacity-WARNING **: 22:20:45.084: 0x1e00003 (Bottom Panel) appears to be one of the offending windows with a timestamp of 1403678055. Working around...
/usr/lib/linuxmint/mintUpdate/mintUpdate.py:1379: DeprecationWarning: Gdk.threads_init is deprecated
  Gdk.threads_init()
/usr/lib/linuxmint/mintUpdate/mintUpdate.py:1764: DeprecationWarning: Gdk.threads_enter is deprecated
  Gdk.threads_enter()
/usr/lib/linuxmint/mintUpdate/mintUpdate.py:803: DeprecationWarning: Gdk.threads_leave is deprecated
  Gdk.threads_leave()
cinnamon-session[114734]: WARNING: t+34.99266s: Detected that screensaver has left the bus

I think you can ignore the ERROR: NVIDIA driver is not loaded as I confirmed it was before installing home-manager and it shows still after removing home-manager with everything else working.

Installing nix itself and software through nix-env or nix profile doesn't cause any issue.

For the record I tried installing home-manger in my steam deck and everything works fine. I understand steam deck uses kde plasma, so this seems to be more related to Cinnamon desktop environment.

DanSM-5 commented 8 months ago

I got a comment in my reddit post by mister_drgn

I had this issue a while back and fixed it by changing home-manager and nixpkgs from unstable to 23.11

Maybe checking what is different in the installation for unstable and 23.11 could help to understand this issue.

RossBrunton commented 8 months ago

Hello. Was trying out home manager today and encountered this issue. Did a bit of digging and it seems to be caused by a mime types database being created in ~/.nix-profile/share/mime, which exists in $XDG_DATA_DIRS. Apparently something in there cinnamon (and a few other apps) find disagreeable. Don't know much more than that beyond that removing that folder fixes the issue, at least temporarily.

For me, the issue wasn't fixed by downgrading to 23.11, but I'm not that skilled with nix yet, so I might have been using a newer channel somewhere.

mister-drgn commented 7 months ago

UPDATE: The most direct cause for the crash that I've found is having the following in .profile: export XDG_DATA_DIRS=$HOME/.nix-profile/share:$XDG_DATA_DIRS

SECOND UPDATE: More specifically, the crash can be linked to $HOME/.nix-profiles/share/mime/mime.cache. But I just reread the post above this by @RossBrunton and realized I could have saved myself some time.

Hi, I'm the person who suggested downgrading to 23.11 on reddit. Although this fix worked in the past, it no longer does, likely because whatever was causing the issue on unstable has now made its way into 23.11. After messing around with my configuration, I determined that I'm getting this Cinnamon crash when I have both of the following:

targets.genericLinux.enable = true;
programs.bash.enable = true;

The second line matters because it puts the following in .profile, which presumably causes the crash to occur at login: . "/home/andrew/.nix-profile/etc/profile.d/hm-session-vars.sh"

So I think the real culprit is targets.genericLinux.enable = true; I have never been particularly clear on what this does, I only know that it's recommended when you're using hm off of NixOS. For now, I'm leaving it disabled to see how things go. EDIT: The main issue is that I lose access to the .desktop files for all my installed software. I can get them back by adding the following line to my .profile, only this results in the crash coming back. export XDG_DATA_DIRS=$HOME/.nix-profile/share:$XDG_DATA_DIRS

kukovecz commented 7 months ago

Just to add a little more info / summary: It is really easy to reproduce with fresh linux mint and flake-based home manager.

  1. Fresh install a linux mint (tried with 21.3 and with 20.3 as well, I encountered this problem using any of them).
  2. Install nix (I used only the multi-user installation): sh <(curl -L https://nixos.org/nix/install) --daemon
  3. mkdir ~/.config/nix && echo "experimental-features = nix-command flakes" > ~/.config/nix/nix.conf
  4. Install home-manager with the standalone flake based setup: nix run home-manager/master -- init --switch

As others pointed it out above: At this point (and every time when home-manager switch installs a new generation), the following file will be there:

If you restart the computer while having the above file, the crash and core dump appears. If you delete the above file (I just hope it is safe to delete as it is being a cache, but I don't really have knowledge about it) and do a restart, everything is fine.

Hope this helps investigating.

RafaelKr commented 6 months ago

I found a very simple solution to make Cinnamon start, but I don't really understand what the underlying cause is.

TLDR:

  1. Open /usr/share/cinnamon/js/ui/extension.js with root privileges
  2. Find function findExtensionSubdirectory
  3. Change the first parameter of the function call dir.enumerate_children_async from standard::* to standard::name,type
  4. Restart Cinnamon

It all boils down to this function: https://github.com/linuxmint/cinnamon/blob/b6661f62a42958b80425c63b34ad789bfa7eb3f2/js/ui/extension.js#L708

While tracking down why Cinnamon goes to fallback mode I found that the function findExtensionSubdirectory in the file /usr/share/cinnamon/js/ui/extension.js never resolves, although resolve is called. I also could make it work when calling return resolve(dir) directly before dir.enumerate_children_async( on line 710.

I then started to play around with the first parameter to dir.enumerate_children_async. I found all available parameters here: https://docs.gtk.org/gio/const.FILE_ATTRIBUTE_STANDARD_NAME.html?q=FILE_ATTRIBUTE_STANDARD When adding all of them with standard::icon,name,size,type,copy-name,edit-name,is-backup,is-hidden,is-symlink,is-virtual,sort-order,target-uri,description,is-volatile,content-type,display-name,symbolic-icon,allocated-size,symlink-target,fast-content-type, which is equivalent to standard::*, Cinnamon crashes. But as soon as icon is removed it starts to work.

So somehow the logic to load an icon for each file fails silently as soon as Home Manager is enabled. This is where my expertise ends and hopefully it helps the developers more involved in Home Manager to track down what actually causes this.

nixos-discourse commented 6 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nix-home-manager-on-linux-mint-cinnamon-crash-on-login/40933/4

RafaelKr commented 6 months ago
* `~/.nix-profile/share/mime/mime.cache`

If you restart the computer while having the above file, the crash and core dump appears. If you delete the above file (I just hope it is safe to delete as it is being a cache, but I don't really have knowledge about it) and do a restart, everything is fine.

One important thing I forgot to mention in my last comment is, that the crash into fallback mode also disappeared when setting xdg.mime.enable = false; in my home.nix.

I don't know which implications disabling XDG mime has. But maybe knowing it has something to do with XDG mime and that icons is enough to figure out the root cause.

dyfrgi commented 6 months ago

I am seeing a similar crash related to mime.cache, albeit in a different program - Firefox. I have a backtrace, minus arguments, which can be seen at https://crash-stats.mozilla.org/report/index/ac6dbca9-a495-4b78-a72f-8102b0240528#tab-details. Note that we appear to have infinite recursion in __gio_xdg_cache_mime_type_subclass. This matches up somewhat with the one described in https://gitlab.gnome.org/GNOME/glib/-/issues/2833, in which it turned out that there was some malformed mime type data. I confirmed that removing ~/.nix-profile/share/mime/mime.cache eliminates the crash. I've also confirmed that setting xdg.mime.enable = false eliminates the crash, unsurprisingly since it stops generation or placement of this file.

Unfortunately, I'm not sure which type it is which is broken, so I can't test it with the Nix mime tools (e.g. xdg-mime) to see if it's also broken for Nix-built tools or if there's some version incompatibility between the Debian (or Mint, in OP's case) libraries and the Nix ones. It may also be that xdg-mime doesn't call the libraries in the same way anyway. mime.cache format is part of the Freedesktop standard, so I would hope that it's the same between Nix and LHS systems - it's supposed to be the same across architectures and work with portable home directories.

I am on nixpkgs and home-manager 23.11.

RafaelKr commented 6 months ago

Also nemo (the Linux Mint file manager) is sometimes crashing.

Sometimes it happens as soon as I open a specific folder, I couldn't figure out what exactly is causing it. But I can reproduce it reliably by selecting any file with a .json extension. As soon as I click the file once nemo crashes with [1] 113672 segmentation fault (core dumped) nemo .

The stack trace also points at libgio, so also related to what I could workaround in Cinnamon described in https://github.com/nix-community/home-manager/issues/5102#issuecomment-2100756890

nemo_segfault_coredump.txt

a-torgovitsky commented 3 months ago

Is there a recommended workaround for this? There have been a few suggestions

  1. Add xdg.mime.enable = false
  2. Delete ~/.nix-profile/share/mime/mime.cache
  3. Edit /usr/share/cinnamon/js/ui/extension.js

The first seems like the safest/easiest, but what are the side effects, if any?