`guix home container` has expected packages but the actual home shell does not

I have previously installed some packages with guix install, and wanted to manage my home environment with guix home. I generated a home environment using guix home import which looked like this:

(use-modules (gnu home)
             (gnu packages)
             (gnu services)
             (guix gexp)
             (gnu home services shells))

(home-environment
  ;; Below is the list of packages that will show up in your
  ;; Home profile, under ~/.guix-home/profile.
  (packages (specifications->packages (list "font-iosevka"
                                            "fontconfig"
                                            "glibc-locales"
                                            "gcc-toolchain@14"
                                            "emacs"
                                            "openjdk@25")))


  (services
   (append (list (service home-bash-service-type
                          (home-bash-configuration
                           (aliases '())
                           (bashrc
			                 (list (local-file
				                     "/home/andrii/.config/guix-home/.bashrc"
				                     "bashrc")))
                           (bash-logout
			                 (list (local-file
				                     "/home/andrii/.config/guix-home/.bash_logout"
				                     "bash_logout"))))))
           %base-home-services)))

I had a minimal bashrc which just set some prompt colors, and my Guix-managed dotfiles are as follows

.profile:

HOME_ENVIRONMENT=$HOME/.guix-home
. $HOME_ENVIRONMENT/setup-environment
$HOME_ENVIRONMENT/on-first-login
unset HOME_ENVIRONMENT

.bash_profile:

# Set up the system, user profile, and related variables.
# /etc/profile will be sourced by bash automatically
# Set up the home environment profile.
if [ -f ~/.profile ]; then source ~/.profile; fi

# Honor per-interactive-shell startup file
if [ -f ~/.bashrc ]; then source ~/.bashrc; fi

So just the standard ones.

Running emacs --version or java -version inside guix home container reports the correct versions, however, when I try to switch to that environment with guix home reconfigure my programs are no longer available. On logging out and back in, and after running guix home switch-generation on the generation number shown by guix home describe, my PATH is just

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

but in the container it is

/home/andrii/.guix-home/profile/bin:/home/andrii/.guix-home/profile/sbin:/gnu/store/mqyizk92llwp2fw579fljwzskswwkipa-home-system-profile/bin

which looks much more appropriate. What is going on here? How do I actually enter the home environment properly, and preferably do it on a login shell so that my packages are always available?

After some messing around I fixed this by deleting ~/.guix-profile (since I installed packages before with plain guix install and that may have caused profile confusion) and making sure that my terminal executes a login shell (in MATE terminal settings: Profile Preferences → Title and Command → Run command in login shell). I also added the following to my profile’s bashrc:

if [ -f ~/.guix-home/setup-environment ]; then
      . ~/.guix-home/setup-environment
fi

just for good measure, and now the PATH actually contains my profile’s bin directory.

You probably don’t want to fix that part of your .profile issues using .bashrc. It should be in the profile. I’m currently having issues on foreign distributions because the wrong guix is available when running guix copy over SSH.

Troubleshooting the login shell issues is tricky, since you need to login/logout. That’s one reason why i had set up a console-specific emacs profile: so i could fix this from one TTY and test in another.

I listed some useful aliases for diffing profile paths in this post here: How do I get Guix to have flatpak application show up in the applications menu whenever I install a flatpak application? - #11 by aionfork