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

clone-path fails to update $PATH #201

Open
1 task done
Darcness opened this issue Sep 11, 2021 · 12 comments
Open
1 task done

clone-path fails to update $PATH #201

Darcness opened this issue Sep 11, 2021 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@Darcness
Copy link

Windows version (build number):
Version 20H2 OS Build 19042.1165

Linux distribution:
Ubuntu-20.04

Genie version:
1.44

Describe the bug
genie -s does not clone my path, despite clone-path set to true

Confirm that you are running inside the bottle:
inside

To Reproduce
Steps to reproduce the behavior:

  1. Set 'Command line' in Windows Terminal to wsl.exe genie -s
  2. Open the terminal
  3. echo $PATH
  4. See directories from 'secure-path' in '/etc/genie.ini', and a few paths specified in .bashrc, but none of my Windows paths.

Expected behavior
See a full list of directories, including Windows paths.

Screenshots

Additional context
/run/genie.path is populated correctly, as in, I see my full Windows Path as well as other paths I would normally expect to see in my WSL Distro.

I confirm that I have read the ENTIRE supplied readme file and checked for relevant information on the repository wiki before raising this issue, and that if the solution to this issue is found in either location, it will be closed without further comment:

  • Yes.
@Darcness Darcness added the bug Something isn't working label Sep 11, 2021
@Darcness
Copy link
Author

I was able to drop the following into my .bashrc as a workaround:

if [ -f /run/genie.path ]; then
    export PATH=$PATH:$(cat /run/genie.path)
fi

@cerebrate
Copy link
Member

This is probably a variant of #137 . Try the diagnosis/fix described here? #137 (comment)

@daegalus
Copy link

daegalus commented Sep 16, 2021

Im having the same problem, and the #137 solution didnt help.

❯ cat /run/genie.env
INSIDE_GENIE=true
WSL_DISTRO_NAME=Ubuntu
WSL_INTEROP=/run/WSL/9_interop
WSLENV=WT_SESSION::WT_PROFILE_ID

❯ cat /run/genie.path
/mnt/c/Windows/System32%

❯ ls /usr/lib/systemd/system-environment-generators
80-genie-envar.sh

❯ echo $PATH
/home/yulian/.bin:/home/yulian/.cargo/bin:/home/yulian/.poetry/bin:/home/yulian/.local/bin:/home/yulian/.yarn/bin:/home/yulian/.nvm/versions/node/v14.17.0/bin:/home/yulian/.npmlocal/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/home/yulian/tools/dotnet:/usr/lib/dart/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/yulian/.rbenv/bin

Adn this is my path outside of genie:

PATH=/home/yulian/.bin:/home/yulian/.cargo/bin:/home/yulian/.poetry/bin:/home/yulian/.local/bin:/home/yulian/.yarn/bin:/home/yulian/.nvm/versions/node/v14.17.0/bin:/home/yulian/.npmlocal/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/home/yulian/tools/dotnet:/usr/lib/dart/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/VMware/VMware Player/bin/:/mnt/c/Program Files/AdoptOpenJDK/jdk-11.0.11.9-hotspot/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/PowerShell/7/:/mnt/c/opscode/chef/bin/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Android:/mnt/c/Windows/System32:/mnt/c/Program Files (x86)/Tailscale IPN:/mnt/c/Users/yulian/scoop/apps/python/current/Scripts:/mnt/c/Users/yulian/scoop/apps/python/current:/mnt/c/Users/yulian/scoop/shims:/mnt/c/Users/yulian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/yulian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/JetBrains/IntelliJ IDEA Community Edition 2020.3.2/bin:/mnt/c/Users/yulian/AppData/Local/Programs/Rancher Desktop/resources/resources/win32/bin:/mnt/c/Users/yulian/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin:/home/yulian/.rbenv/bin

@trallnag
Copy link

trallnag commented Sep 19, 2021

Same with Ubuntu-21.04. But in my case #201 (comment) solves the issue. I adapted it slightly to my usecase

# This is a temporary hack until the following bug is fixed:
# https://github.com/arkane-systems/genie/issues/201
if \
    [[ -v INSIDE_GENIE ]] \
    && cat /etc/genie.ini | grep --quiet '^clone-path=true' \
    && ! echo "$PATH" | grep --quiet '/WINDOWS/system32' \
    && [ -f /run/genie.path ]
then
    echo "[DEBUG] Add content of '/run/genie.path' to PATH."
    PATH="$PATH:$(cat /run/genie.path)"
fi

@github-actions
Copy link

There has been no activity on this issue for over 60 days. If there is no further activity within 7 days from this message, it will be automatically closed.

@cerebrate
Copy link
Member

What do you see if you run /usr/lib/systemd/system-environment-generators/80-genie-envar.sh manually?

@daegalus
Copy link

daegalus commented Nov 22, 2021

Weirdly my path in the bottle is incorrect, but both the 80-genie-envvar.sh and /run/genie.path are correct, mostly. the Genie one ones are missing snap/bin which i dont care but its weird its not including certain things. though, that just might be another generator that runs elsewhere

❯ genie -b
inside

❯ echo $PATH
/home/yulian/.bin:/home/yulian/.cargo/bin:/home/yulian/.poetry/bin:/home/yulian/.local/bin:/home/yulian/.yarn/bin:/home/yulian/.nvm/versions/node/v14.17.0/bin:/home/yulian/.npmlocal/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/home/yulian/tools/dotnet:/usr/lib/dart/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/yulian/.rbenv/bin

❯ /usr/lib/systemd/system-environment-generators/80-genie-envar.sh
INSIDE_GENIE=true
WSL_INTEROP=/run/WSL/1986_interop
WSL_DISTRO_NAME=Ubuntu
WSLENV=WT_SESSION::WT_PROFILE_ID
PATH=/home/yulian/.bin:/home/yulian/.cargo/bin:/home/yulian/.poetry/bin:/home/yulian/.local/bin:/home/yulian/.yarn/bin:/home/yulian/.nvm/versions/node/v14.17.0/bin:/home/yulian/.npmlocal/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/home/yulian/tools/dotnet:/usr/lib/dart/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/yulian/.rbenv/bin:/usr/lib/wsl/lib:/mnt/c/Program Files (x86)/VMware/VMware Player/bin/:/mnt/c/Program Files/AdoptOpenJDK/jdk-11.0.11.9-hotspot/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/PowerShell/7/:/mnt/c/opscode/chef/bin/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Android:/mnt/c/Windows/System32:/mnt/c/Program Files (x86)/Tailscale IPN:/mnt/c/Users/yulian/scoop/apps/python/current/Scripts:/mnt/c/Users/yulian/scoop/apps/python/current:/mnt/c/Users/yulian/scoop/shims:/mnt/c/Users/yulian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/yulian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/JetBrains/IntelliJ IDEA Community Edition 2020.3.2/bin:/mnt/c/Users/yulian/AppData/Local/Programs/Rancher Desktop/resources/resources/win32/bin:/mnt/c/Users/yulian/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin:/home/yulian/.rbenv/bin

❯ cat /run/genie.path
/home/yulian/.bin:/home/yulian/.cargo/bin:/home/yulian/.poetry/bin:/home/yulian/.local/bin:/home/yulian/.yarn/bin:/home/yulian/.nvm/versions/node/v14.17.0/bin:/home/yulian/.npmlocal/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/home/yulian/tools/dotnet:/usr/lib/dart/bin:/home/yulian/.go/bin:/home/yulian/.go/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files (x86)/VMware/VMware Player/bin/:/mnt/c/Program Files/AdoptOpenJDK/jdk-11.0.11.9-hotspot/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/PowerShell/7/:/mnt/c/opscode/chef/bin/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Android:/mnt/c/Windows/System32:/mnt/c/Program Files (x86)/Tailscale IPN:/mnt/c/Users/yulian/scoop/apps/python/current/Scripts:/mnt/c/Users/yulian/scoop/apps/python/current:/mnt/c/Users/yulian/scoop/shims:/mnt/c/Users/yulian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/yulian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/JetBrains/IntelliJ IDEA Community Edition 2020.3.2/bin:/mnt/c/Users/yulian/AppData/Local/Programs/Rancher Desktop/resources/resources/win32/bin:/mnt/c/Users/yulian/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin:/home/yulian/.rbenv/bin
❯ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

On Windows 10.

Edit: If I add source /usr/lib/systemd/system-environment-generators/80-genie-envar.sh to my /etc/zsh/zshrc everything works, minus the snaps path missing.

@github-actions
Copy link

There has been no activity on this issue for over 60 days. If there is no further activity within 7 days from this message, it will be automatically closed.

@dave-fl
Copy link

dave-fl commented Jan 30, 2022

Followed the above for checking if /run/genie.path exists, but had to save my original path to a file before restoring. Otherwise things like code do not work. This was on Fedora 35.

@jbaribeault
Copy link

Same as above - sourcing the results of /usr/lib/systemd/system-environment-generators/80-genie-envar.sh works for me manually - which is strange considering the systemd --user stuff is working fine otherwise - and genie/path has the right contents too....hmm. Custom ARCH here though....so could be me ;)

@cerebrate
Copy link
Member

The general cause for this problem, unfortunately, is variable.

The path (and other environment variables) you end up with in the user session is the result of first, all the environment generators from /usr/lib/systemd/user-environment-generators run in asciibetical order from first to last. (Most of these have numbers proxied to them to set the order they run in; genie's is 80, so it should run after anything that's not explicitly trying to be last.)

Also, they should append to the existing path (as 80-genie-envar.sh) does, but they can overwrite them, so that's something you need to check for.

These files produce the environment block you can see when you run

systemctl --user show-environment

If your path looks correct in the results from running that , you don't need to worry about the environment generators, 'cause they're working fine.

This block should be inherited as-is by your shell when it starts up. While there may be other things that try and fiddle with your environment block, the odds are about 95% good that one of your shell profiles (see your shell's documentation for details of these) is overwriting the existing PATH.

These are the only means I have found to repro this behavior. Unfortunately, there are multiple places either could be done, so I'm going to have to leave finding the specific places on your systems where PATH gets overwritten to y'all.

@cerebrate cerebrate pinned this issue Mar 8, 2022
@falloutphil
Copy link

falloutphil commented Aug 11, 2022

I have a weirder edge-case.

For every other command the sourcing of /usr/lib/systemd/system-environment-generators/80-genie-envar.sh works fine, but specifically for netsh.exe I find the only way I can run it once a bottle is initialized (either from inside or outside the bottle) is to do this:

PATH="/mnt/c/Windows/system32:$PATH" cmd.exe /C "netsh.exe interface ipv4 show subinterfaces"

Any other incantation I have tried doesn't work (and I've tried lots!) - can anyone else confirm this oddity, or even better explain the underlying cause?

Note if system32 is on the PATH then you can get away with just using the cmd.exe and passing netsh.exe into that, but for some reason I cannot call netsh.exe directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants