Invoke user's login shell to load proper WSL $PATH

In Linux, custom changes to the $PATH are usually defined in ~/.profile,
~/.bash_profile, ~/.zprofile, etc.  These files are only loaded by a
'login shell', which can be explicitly invoked with the -l flag.  Most
shells (bash, dash, zsh, fish) support this -l flag.  This commit uses
the $SHELL env var to invoke the user's default shell with the -l flag to
force a login shell. This should properly load any custom $PATH settings
defined by the WSL user.  This is a potential fix for #693
macos-click-through
rsynnest 3 years ago committed by Keith Simmons
parent 55179e43c3
commit 3be5de6874

@ -36,7 +36,7 @@ fn platform_build_nvim_cmd(bin: &str) -> Option<Command> {
cmd.args(&[
bin.trim(),
"-c",
"let \\$PATH=system(\"bash -ic 'echo \\$PATH' 2>/dev/null\")",
"let \\$PATH=system(\"\\$SHELL -lic 'echo \\$PATH' 2>/dev/null\")",
]);
Some(cmd)
} else if Path::new(&bin).exists() {
@ -66,7 +66,7 @@ fn build_nvim_cmd() -> Command {
#[cfg(windows)]
if SETTINGS.get::<CmdLineSettings>().wsl {
if let Ok(output) = std::process::Command::new("wsl")
.args(&["bash", "-ic", "which nvim"])
.args(&["$SHELL", "-lic", "which nvim"])
.output()
{
if output.status.success() {
@ -75,7 +75,7 @@ fn build_nvim_cmd() -> Command {
cmd.args(&[
path.trim(),
"-c",
"let \\$PATH=system(\"bash -ic 'echo \\$PATH' 2>/dev/null\")",
"let \\$PATH=system(\"\\$SHELL -lic 'echo \\$PATH' 2>/dev/null\")",
]);
return cmd;
} else {

Loading…
Cancel
Save