Subject: Re: bug#56661: EMACSLOADPATH not set when using Guix System + Guix Home + SLIM + Mate

From: Andrew Tropin <[email-masked]>
Date: Wed, 20 Jul 2022 15:08:22 +0300

On 2022-07-20 12:45, Maxime Devos wrote:

> Hi,
>
> (the SLIM + Mate might be irrelevant, untested)
>
> I am using Guix System and Guix Home. In Guix Home, I've added the 
> "emacs" and "emacs-magit" packages (and some others):
>
>> (home-environment
>>   (packages
>>     (specifications->packages
>>       (list "git" "irssi" "evolution" "openssh" "gnupg" "htop"
>>             "bash" "coreutils" "bash-completion"
>>             "emacs" "emacs-magit" "emacs-paredit"
>>             "icedove" "gnunet" "seahorse" #;"icedove-wayland")))
>>   (services
>>     (list (service
>>             home-bash-service-type
>>             (home-bash-configuration
>>               (aliases
>>                 '(("grep" . "grep --color=auto")
>>                   ("ll" . "ls -l")
>>                   ("ls" . "ls -p --color=auto")))
>>               (bashrc
>>                 (list (local-file ".bashrc" "bashrc")))
>>               (bash-profile
>>                 (list (local-file
>>                         ".bash_profile"
>>                         "bash_profile"))))))))
>
> For completeness, here is the .bash_profile and .bashrc (unmodified from 
> base installation, except for removing a redundant alias):
>
>> # Honor per-interactive-shell startup file
>> if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

Hi Maxime,

According to the documentation to get all the environment variables set
correctly you either need to manage your login shell with Guix Home or
do additional configuration of your shell:
https://guix.gnu.org/manual/devel/en/html_node/Configuring-the-Shell.html

From what I see you manage bash with Guix Home, so according to the
source code your bash_profile should look differently from what you've
posted and must contain `source ~/.profile` in it:
https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/home/services/shells.scm#n440

This line makes your login shell source .profile, which sources
setup-environment, which sources ~/.guix-home/profile/etc/profile, which
sets EMACSLOADPATH.

Additionally, I've built the home environment you provided and it
contains the code I mentioned above.

Make sure that ~/.bash_profile and ~/.guix-home/files/.bash_profile
point to the same file in the store.

>
> and
>
>> # Bash initialization for interactive non-login shells and
>> # for remote shells (info "(bash) Bash Startup Files").
>>
>> # Export 'SHELL' to child processes.  Programs such as 'screen'
>> # honor it and otherwise use /bin/sh.
>> export SHELL
>>
>> if [[ $- != *i* ]]
>> then
>>     # We are being invoked from a non-interactive shell.  If this
>>     # is an SSH session (as in "ssh host command"), source
>>     # /etc/profile so we get PATH and other essential variables.
>>     [[ -n "$SSH_CLIENT" ]] && source /etc/profile
>>
>>     # Don't do anything else.
>>     return
>> fi
>>
>> # Source the system-wide file.
>> source /etc/bashrc
>>
>> # Adjust the prompt depending on whether we're in 'guix environment'.
>> if [ -n "$GUIX_ENVIRONMENT" ]
>> then
>>     PS1='\u@\h \w [env]\$ '
>> else
>>     PS1='\u@\h \w\$ '
>> fi
>
> After a "guix home reconfigure" and after a few reboots, I tried out 
> emacs-magit, but there was no match for the "M-x magit-status".  It 
> turned out that $EMACSLOADPATH was unset. However, it is set in 
> ~/.guix-home/profile/etc/profile:
>
>> # Source this file to define all the relevant environment variables in 
>> Bash
>> # for this profile.  You may want to define the 'GUIX_PROFILE' environment
>> # variable to point to the "visible" name of the profile, like this:
>> #
>> #  GUIX_PROFILE=/path/to/profile ; \
>> #  source /path/to/profile/etc/profile
>> #
>> # When GUIX_PROFILE is undefined, the various environment variables refer
>> # to this specific profile generation.
>>
>> export 
>> PATH="${GUIX_PROFILE:-/gnu/store/ll0p9k6yp5070svjhwry8dxdm98ipk7d-profile}/bin:${GUIX_PROFILE:-/gnu/store/ll0p9k6yp5070svjhwry>
>> export 
>> GIT_EXEC_PATH="${GUIX_PROFILE:-/gnu/store/ll0p9k6yp5070svjhwry8dxdm98ipk7d-profile}/libexec/git-core"
>> export 
>> BASH_LOADABLES_PATH="${GUIX_PROFILE:-/gnu/store/ll0p9k6yp5070svjhwry8dxdm98ipk7d-profile}/lib/bash${BASH_LOADABLES_PATH:+:}$BA>
>> export 
>> INFOPATH="${GUIX_PROFILE:-/gnu/store/ll0p9k6yp5070svjhwry8dxdm98ipk7d-profile}/share/info${INFOPATH:+:}$INFOPATH"
>> export 
>> EMACSLOADPATH="${GUIX_PROFILE:-/gnu/store/ll0p9k6yp5070svjhwry8dxdm98ipk7d-profile}/share/emacs/site-lisp${EMACSLOADPATH:+:}$E>
>> export 
>> XDG_DATA_DIRS="${GUIX_PROFILE:-/gnu/store/ll0p9k6yp5070svjhwry8dxdm98ipk7d-profile}/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"
>
> (nevermind the >, that's just me not making the terminal wide enough 
> before copying)
>
> Weirdly, EMACSLOADPATH is not set (tested in a terminal), but PATH, 
> GIT_EXEC_PATH, BASH_LOADABLES_PATH, INFOPATH and XDG_DATA_DIRS are set.  
> Also, inside a login shell (bash --login) (started inside the graphical 
> environment), EMACSLOADPATH is not set.
>
> Also, if I do "source ~/.guix-home/setup-environment", then 
> $EMACSLOADPATH" is set.
>
> TBI ...
>
> Greetings,
> Maxime.
>
>
> -----BEGIN PGP PUBLIC KEY BLOCK-----
>
> xjMEX4ch6BYJKwYBBAHaRw8BAQdANPb/d6MrGnGi5HyvODCkBUJPRjiFQcRU5V+m
> xvMaAa/NL01heGltZSBEZXZvcyA8bWF4aW1lLmRldm9zQHN0dWRlbnQua3VsZXV2
> ZW4uYmU+wpAEExYIADgWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCX4ch6AIbAwUL
> CQgHAwUVCgkICwUWAgMBAAIeAQIXgAAKCRBJ4+4iGRcl7japAQC3opZ2KGWzWmRc
> /gIWSu0AAcfMwyinFEEPa/QhUt2CogD/e2RdF4CYAgaRHJJmZ9WU7piKbLZ7llB4
> LzgezVDHggzNJU1heGltZSBEZXZvcyA8bWF4aW1lZGV2b3NAdGVsZW5ldC5iZT7C
> kAQTFggAOBYhBMHzPuIMUo/bfdcBH0nj7iIZFyXuBQJf56ycAhsDBQsJCAcDBRUK
> CQgLBRYCAwEAAh4BAheAAAoJEEnj7iIZFyXujpQBAKV1SwDDl4f24rXciDlB9L8W
> ycZt30CgbewMSRQk4mvbAP9dFMbVVixYBd6C8cfhR+NsOBGiOJnQABlUmgNuqGFJ
> Dc44BF+HIegSCisGAQQBl1UBBQEBB0BOlzIWiJzgobMF6/cqwLaLk7jIcFSZ++c0
> k9cCNT6YXwMBCAfCeAQYFggAIBYhBMHzPuIMUo/bfdcBH0nj7iIZFyXuBQJfhyHo
> AhsMAAoJEEnj7iIZFyXuMr0BAJc8cl5PGvVmVuSQVKjleNl4DK1/XAaPAYPe34AE
> fZJPAP9IqLCQhH/FeJanHqBP8gNdGNI2qn8RnnLVfRJgUjZ1BA==
> =OVqp
> -----END PGP PUBLIC KEY BLOCK-----

-- 
Best regards,
Andrew Tropin