Skip to content

Commit bf5ed6d

Browse files
authored
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.
1 parent bb5cfe1 commit bf5ed6d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/remote/src/ssh_session.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl SshSocket {
445445
}
446446

447447
async fn platform(&self) -> Result<SshPlatform> {
448-
let uname = self.run_command("sh", &["-c", "uname -sm"]).await?;
448+
let uname = self.run_command("sh", &["-lc", "uname -sm"]).await?;
449449
let Some((os, arch)) = uname.split_once(" ") else {
450450
anyhow::bail!("unknown uname: {uname:?}")
451451
};
@@ -476,7 +476,7 @@ impl SshSocket {
476476
}
477477

478478
async fn shell(&self) -> String {
479-
match self.run_command("sh", &["-c", "echo $SHELL"]).await {
479+
match self.run_command("sh", &["-lc", "echo $SHELL"]).await {
480480
Ok(shell) => shell.trim().to_owned(),
481481
Err(e) => {
482482
log::error!("Failed to get shell: {e}");
@@ -1533,7 +1533,7 @@ impl RemoteConnection for SshRemoteConnection {
15331533

15341534
let ssh_proxy_process = match self
15351535
.socket
1536-
.ssh_command("sh", &["-c", &start_proxy_command])
1536+
.ssh_command("sh", &["-lc", &start_proxy_command])
15371537
// IMPORTANT: we kill this process when we drop the task that uses it.
15381538
.kill_on_drop(true)
15391539
.spawn()
@@ -1910,7 +1910,7 @@ impl SshRemoteConnection {
19101910
.run_command(
19111911
"sh",
19121912
&[
1913-
"-c",
1913+
"-lc",
19141914
&shell_script!("mkdir -p {parent}", parent = parent.to_string().as_ref()),
19151915
],
19161916
)
@@ -1988,7 +1988,7 @@ impl SshRemoteConnection {
19881988
.run_command(
19891989
"sh",
19901990
&[
1991-
"-c",
1991+
"-lc",
19921992
&shell_script!("mkdir -p {parent}", parent = parent.to_string().as_ref()),
19931993
],
19941994
)
@@ -2036,7 +2036,7 @@ impl SshRemoteConnection {
20362036
dst_path = &dst_path.to_string()
20372037
)
20382038
};
2039-
self.socket.run_command("sh", &["-c", &script]).await?;
2039+
self.socket.run_command("sh", &["-lc", &script]).await?;
20402040
Ok(())
20412041
}
20422042

0 commit comments

Comments
 (0)