Open charmoniumQ opened 6 months ago
My workaround, which I don't like, is to add this to my rc.xsh
:
# https://github.com/NixOS/nixpkgs/issues/276326
$PATH = [
path for path in $PATH
if not ((p"" / path / "xonsh").exists() and (p"" / path).parts[1] == "nix")
]
See also #248978
Describe the bug
Adding a package to the Xonsh environment using the above method seems to work initially, but it does not work for nested xonsh sessions (calling xonsh in xonsh).
This is especially salient for users who want to use xontribs and want to use xonsh as their nix shell (i.e., they type
nix develop --command xonsh
). The inner xonsh won't be able to use any of their xontribs, giving them a totally different experience than their native shell.Steps To Reproduce
Steps to reproduce the behavior:
Exporting path once, on the outside shell, is basically what home-manager does when you include xonsh in
home.packages
.Expected behavior
Nested xonsh session should also be able to import psutil.
Additional context
result/bin/xonsh
is a symlink to/nix/store/zdx...-python3-3.11.6-env/bin/xonsh
which is amakeCWrapper
around/nix/store/ri5...-xonsh-0.14.0/bin/xonsh
, which is amakeWrapper
around/nix/store/ri5...-xonsh-0.14.0/bin/.xonsh-wrapped
.The first, wrapper,
/nix/store/zdx...-python3-3.11.6-env/bin/xonsh
setsNIX_PYTHONPATH=/nix/store/zdx...-python3-3.11.6-env/lib/python3.11/site-package', in which
psutil/*.py` lives.The second wrapper,
/nix/store/ri5...-xonsh-0.14.0/bin/xonsh
prepends its containing directory to thePATH
.If the user addes
result/bin
to theirPATH
and typesxonsh
,/nix/store/zdx.../xonsh
is invoked,psutil
will be importable. But it will prepend to the path/nix/store/ri5...-xonsh-0.14.0/bin/xonsh
to thePATH
. In this shell, if they typexonsh
again,/nix/store/ri5.../xonsh
will be invoked andpsutil
will not be importable.I am pretty sure the
/nix/store/zdx.../xonsh
wrapper should be the one to add itself to thePATH
, which would fix this bug. It would also make invoking xonsh faster (fewer wrappers). OR none of the wrappers should add theirselves to the path, and it's the job of home-manager or the user to add xonsh to theirPATH
.Notify maintainers
@vrthra @adisbladis (because adisbladis wrote the xonsh wrapper).
Metadata
Add a :+1: reaction to issues you find important.