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

Emacs creates native-lisp directories unconditionally #247804

Closed
tmuehlbacher opened this issue Aug 7, 2023 · 5 comments · Fixed by #251529
Closed

Emacs creates native-lisp directories unconditionally #247804

tmuehlbacher opened this issue Aug 7, 2023 · 5 comments · Fixed by #251529

Comments

@tmuehlbacher
Copy link
Contributor

Describe the bug

Emacs will try to create a directory structure like
share/emacs/native-lisp/29.1-ef7c54ae/ for every path in
$NIX_PROFILES. This seems to be because of the code in
pkgs/applications/editors/emacs/site-start.el.

On NixOS, the NIX_PROFILES environment variable may contain invalid
paths, for example ~/.nix-profile may not exist. This causes Emacs to
create the full directory structure for that path. This also causes
issues if Nix afterwards wants to create ~/.nix-profile as a symlink
but it already exists as a directory.

Steps To Reproduce

$ for i in $NIX_PROFILES; do file $i; done
/run/current-system/sw: symbolic link to /nix/store/d2p2vm19a44pf51c4pcjcw8p9hliv6x4-system-path
/nix/var/nix/profiles/default: symbolic link to /nix/var/nix/profiles/per-user/root/profile
/etc/profiles/per-user/tom: symbolic link to /etc/static/profiles/per-user/tom
/home/tom/.nix-profile: cannot open `/home/tom/.nix-profile' (No such file or directory)

$ emacs
C-x C-e

$ for i in $NIX_PROFILES; do file $i; done
/run/current-system/sw: symbolic link to /nix/store/d2p2vm19a44pf51c4pcjcw8p9hliv6x4-system-path
/nix/var/nix/profiles/default: symbolic link to /nix/var/nix/profiles/per-user/root/profile
/etc/profiles/per-user/tom: symbolic link to /etc/static/profiles/per-user/tom
/home/tom/.nix-profile: directory

Expected behavior

The code in site-start.el should filter NIX_PROFILES down to only
paths that already exist.

Additional context

Ideally, NIX_PROFILES would only include paths that exist in the first
place, but this is not the case. #241518 also seems related.

Notify maintainers

@AndersonTorres
@adisbladis
@Atemu
@jwiegley
@lovek323
@matthewbauer

Metadata

  • system: "x86_64-linux"
  • host os: Linux 6.4.8, NixOS, 23.11 (Tapir), 23.11.20230807.5a8e924
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.17.0
  • nixpkgs: /etc/nix/inputs/nixpkgs
@Gerg-L
Copy link
Contributor

Gerg-L commented Aug 7, 2023

Ideally, NIX_PROFILES would only include paths that exist in the first
place, but this is not the case. #241518 also seems related.

This isn't really possible with the current handling of NIX_PROFILES see this comment: #241518 (comment)

@tmuehlbacher
Copy link
Contributor Author

This isn't really possible with the current handling of NIX_PROFILES see this comment: #241518 (comment)

👍 yes, I hope it didn't sound like I feel antagonistic to your PR, I really hope that it lands because I do enjoy a clean $HOME. 😄 I more wanted to show that my proposed solution is necessary because invalid paths in NIX_PROFILES are pretty much inevitable.

@jian-lin
Copy link
Contributor

I cannot reproduce it.

Steps:

> echo $NIX_PROFILES
/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/me /home/me/.nix-profile

> rm -f ~/.nix-profile

> nix run github:NixOS/nixpkgs/ce5e4a6ef2e59d89a971bc434ca8ca222b9c7f5e#emacs29 -- -q --init-directory=/tmp/init-dir

> # exit Emacs

> file ~/.nix-profile
/home/me/.nix-profile: cannot open `/home/me/.nix-profile' (No such file or directory)

BTW, the value of native-comp-eln-load-path is ("/tmp/init-dir/eln-cache/" "/nix/store/hash-emacs-29.1-rc1/lib/emacs/29.1/native-lisp/"), which indicates another bug: adding NIX_PROFILES to native-comp-eln-load-path in site-start.el does not take effect.

@jian-lin
Copy link
Contributor

BTW, the value of native-comp-eln-load-path is ("/tmp/init-dir/eln-cache/" "/nix/store/hash-emacs-29.1-rc1/lib/emacs/29.1/native-lisp/"), which indicates another bug: adding NIX_PROFILES to native-comp-eln-load-path in site-start.el does not take effect.

The bug I mention only happens in Emacs 29.

I can reproduce your issue in Emacs 28.

#251529 fixes this issue.

jian-lin added a commit to linj-fork/nixpkgs that referenced this issue Aug 26, 2023
@tmuehlbacher
Copy link
Contributor Author

I cannot reproduce it.

I'm sorry, I should have done more testing to isolate the issue. I tested out which of my packages is the culprit and the issue goes away if i remove this from my init.el:

(use-package ido-completing-read+
  :config
  (ido-ubiquitous-mode))

Maybe it has something to do with the ido-completing-read+ dependency memoize? (I am unfortunately not proficient enough with elisp to really be able to figure it out.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants