home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

bug: option `home.sessionPath` is not being applied

Open DavSanchez opened this issue 3 years ago • 10 comments
trafficstars

Are you following the right branch?

  • [X] My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • [X] I have searched the existing issues

Issue description

Hello,

I have noticed that the home.sessionPath has apparently stopped working. For context, I have some binaries in $HOME/.local/bin that I could pick up without issues until yesterday (checked last week and was working fine) by setting home.sessionPath somewhere in my config (a top-level home.nix for example). I don't think I have made any changes that could have impacted this, but it has stopped applying (or is somehow being overwritten) on subsequent config switches and I do not know why.

I see in the module definition that sessionPath writes the paths to ~/.nix-profile/etc/profile.d/hm-session-vars.sh or /etc/profile.d/hm-session-vars.sh, but I do not have these locations in my computer (anymore?)

Could you help me troubleshoot this? Has anything changed recently? Than you very much.

Best regards

Maintainer CC

No response

System information

- system: `"aarch64-linux"` # Happens in "x86_64-linux" as well
 - host os: `Linux 5.15.77, NixOS, 22.11 (Raccoon), 22.11.20221110.5f588eb`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.0`
 - nixpkgs: `/nix/store/4mb05a4b7jwf6spviss2mfcdf16s9nwd-source`

DavSanchez avatar Nov 15 '22 08:11 DavSanchez

I noticed this too. What shell do you use, and how did you install h-m? I use fish and installed h-m standalone because i prefer to keep the user config separate from the system config. I also noticed that I do have ~/.nix-profile/etc/profile.d/hm-session-vars.sh and that it DOES have 'export PATH="$PATH${PATH:+:}$HOME/.local/bin"' at the end, but it doesnt get applied for some reason.

ghost avatar Nov 28 '22 13:11 ghost

as a workaround i have added environment.localBinInPath in my configuration.nix

ghost avatar Nov 28 '22 13:11 ghost

I use zsh and installed HM as a NixOS module. I located the hm-session-vars.sh in /etc/profiles/per-user/<user> if I recall correctly, but yeah it's not being applied. My workaround is just adding the export (along with other functions) to a particular shell script that is sourced in initExtra option.

DavSanchez avatar Nov 29 '22 23:11 DavSanchez

Not sure if this was a recent change, but looking at the docs again (https://github.com/nix-community/home-manager/blob/master/docs/installation.adoc#nixos-module), if home-manager.useUserPackages = true is set, the profile is in /etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh.

Flakebi avatar Dec 18 '22 14:12 Flakebi

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar May 08 '23 16:05 stale[bot]

For me the path variable is only updated in ZSH that is managed by HM but for other apps like bemenu launched without ZSH use the old PATH

Amanse avatar Sep 04 '23 05:09 Amanse

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Dec 03 '23 05:12 stale[bot]

I still have this issue in fish!

DaniD3v avatar May 13 '24 21:05 DaniD3v

~Is this still an issue?~ edit 2024-07-31: was able to reproduce it in my setup with simply logging out and logging in again into gnome-shell ... echo $PATH before:

/run/wrappers/bin /home/user/.nix-profile/bin /home/user/.local/state/nix/profile/bin /home/user/.local/state/nix/profile/bin /etc/profiles/per-user/user/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin /home/user/.local/bin

and after:

/run/wrappers/bin /home/user/.nix-profile/bin /home/user/.local/state/nix/profile/bin /home/user/.local/state/nix/profile/bin /etc/profiles/per-user/user/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin

File .nix-profile/etc/profile.d/hm-session-vars.sh stayed the same. ... old part of comment: I came here because this bug was suddenly appearing in rev 635563f245309ef5320f80c7ebcb89b2398d2949 for me and disappeared with rev 4fcd54df7cbb1d79cbe81209909ee8514d6b17a4. I have home-manager installed as standalone using flakes, the shell is as well fish. The configuration looks as follows:

  xdg.enable = true;
  home.sessionVariables = {
    XDG_BIN_HOME    = "${config.home.homeDirectory}/.local/bin";
  };
  home.sessionPath = [ "$XDG_BIN_HOME" ];

That results in ~/.nix-profile/etc/profile.d/hm-session-vars.sh (this file stayed the same in both revisions, only path temporarily wasn't exported as expected).

export XDG_BIN_HOME="/home/user/.local/bin"
export XDG_CACHE_HOME="/home/user/.cache"
export XDG_CONFIG_HOME="/home/user/.config"
export XDG_DATA_HOME="/home/user/.local/share"
export XDG_STATE_HOME="/home/user/.local/state"
export PATH="$PATH${PATH:+:}$XDG_BIN_HOME"

gaerfield avatar Jul 30 '24 07:07 gaerfield

I am working around this by adding all files in my wanted folder:

  home.packages = with pkgs; let
    bin = "${./bin}";
    scriptsToBins = dir:
      let
        scripts = builtins.attrNames (builtins.readDir dir);
      in
      builtins.map (script: pkgs.writeScriptBin (script) (builtins.readFile ("${dir}/${script}"))) scripts;
  in
  (scriptsToBins bin)
  ++ [
  
   otherPackages
   
   ];
   

quite hacky, as it requires rebuild every time a file changes, but maybe useful for you

jamesmstone avatar Aug 23 '24 18:08 jamesmstone

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Jan 03 '25 07:01 stale[bot]

I'm still seeing this issue with 25.05 (both nixos and home-manager).

I'm using zsh and wrote a small script to look up the env of the process and all its parents.

I see that both __HM_ZSH_SESS_VARS_SOURCED and __HM_SESS_VARS_SOURCED are set, but I don't see the elmeents from sessionPath being set in any of the processes, despite the file being sourced in ~/.profile having the correct declarations.

If I unse __HM_ZSH_SESS_VARS_SOURCED and source the file manually in a shell, the PATH is correctly updated, so it looks like something is losing or overriding the PATH declaration somewhere else?

albertodonato avatar Oct 02 '25 11:10 albertodonato

I just tested the same script from a terminal session outside of the gnome env, and there the PATH is correctly set. This seems to be somewhat related to the gnome session configuration.

I've tested with both gnome-terminal and xterm and both show the issue.

albertodonato avatar Oct 02 '25 11:10 albertodonato

I'm not sure if relevant, but ~/.config/environment.d/10-home-manager.confdoesn't set PATH

albertodonato avatar Oct 03 '25 16:10 albertodonato