Remote: Change "sh -c" to "sh -lc" to make config in $HOME/.profile effective (#36760)
Closes #ISSUE Release Notes: - The environment of original remote dev cannot be changed without sudo because of the behavior of "sh -c". This PR changes "sh -c" to "sh -lc" to let the shell source $HOME/.profile and support customized environment like customized $PATH variable.
This commit is contained in:
parent
bb5cfe118f
commit
bf5ed6d1c9
1 changed files with 6 additions and 6 deletions
|
@ -445,7 +445,7 @@ impl SshSocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn platform(&self) -> Result<SshPlatform> {
|
async fn platform(&self) -> Result<SshPlatform> {
|
||||||
let uname = self.run_command("sh", &["-c", "uname -sm"]).await?;
|
let uname = self.run_command("sh", &["-lc", "uname -sm"]).await?;
|
||||||
let Some((os, arch)) = uname.split_once(" ") else {
|
let Some((os, arch)) = uname.split_once(" ") else {
|
||||||
anyhow::bail!("unknown uname: {uname:?}")
|
anyhow::bail!("unknown uname: {uname:?}")
|
||||||
};
|
};
|
||||||
|
@ -476,7 +476,7 @@ impl SshSocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn shell(&self) -> String {
|
async fn shell(&self) -> String {
|
||||||
match self.run_command("sh", &["-c", "echo $SHELL"]).await {
|
match self.run_command("sh", &["-lc", "echo $SHELL"]).await {
|
||||||
Ok(shell) => shell.trim().to_owned(),
|
Ok(shell) => shell.trim().to_owned(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to get shell: {e}");
|
log::error!("Failed to get shell: {e}");
|
||||||
|
@ -1533,7 +1533,7 @@ impl RemoteConnection for SshRemoteConnection {
|
||||||
|
|
||||||
let ssh_proxy_process = match self
|
let ssh_proxy_process = match self
|
||||||
.socket
|
.socket
|
||||||
.ssh_command("sh", &["-c", &start_proxy_command])
|
.ssh_command("sh", &["-lc", &start_proxy_command])
|
||||||
// IMPORTANT: we kill this process when we drop the task that uses it.
|
// IMPORTANT: we kill this process when we drop the task that uses it.
|
||||||
.kill_on_drop(true)
|
.kill_on_drop(true)
|
||||||
.spawn()
|
.spawn()
|
||||||
|
@ -1910,7 +1910,7 @@ impl SshRemoteConnection {
|
||||||
.run_command(
|
.run_command(
|
||||||
"sh",
|
"sh",
|
||||||
&[
|
&[
|
||||||
"-c",
|
"-lc",
|
||||||
&shell_script!("mkdir -p {parent}", parent = parent.to_string().as_ref()),
|
&shell_script!("mkdir -p {parent}", parent = parent.to_string().as_ref()),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -1988,7 +1988,7 @@ impl SshRemoteConnection {
|
||||||
.run_command(
|
.run_command(
|
||||||
"sh",
|
"sh",
|
||||||
&[
|
&[
|
||||||
"-c",
|
"-lc",
|
||||||
&shell_script!("mkdir -p {parent}", parent = parent.to_string().as_ref()),
|
&shell_script!("mkdir -p {parent}", parent = parent.to_string().as_ref()),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -2036,7 +2036,7 @@ impl SshRemoteConnection {
|
||||||
dst_path = &dst_path.to_string()
|
dst_path = &dst_path.to_string()
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
self.socket.run_command("sh", &["-c", &script]).await?;
|
self.socket.run_command("sh", &["-lc", &script]).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue