Skip to content

Commit

Permalink
fix(garden-sea): resolve symlinks for GARDEN_SEA_EXECUTABLE_PATH (#5353)
Browse files Browse the repository at this point in the history
This is to double down on making sure that self-update updates the
correct path (See also #5352)
  • Loading branch information
stefreak committed Nov 6, 2023
1 parent 5fdf85e commit aba79f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion garden-sea/src/extract.rs
Expand Up @@ -164,7 +164,7 @@ fn unpack(path: &Path, archive: &[u8]) -> Result<(), std::io::Error> {

#[cfg(test)]
mod tests {
use std::{path::PathBuf, fs};
use std::{fs, path::PathBuf};

use super::extract_archives_if_needed;

Expand Down
10 changes: 6 additions & 4 deletions garden-sea/src/node.rs
@@ -1,6 +1,7 @@
use std::{
env,
ffi::OsString,
fs,
path::Path,
process::{Child, Command},
thread::JoinHandle,
Expand All @@ -23,11 +24,12 @@ where
// Some users depend on this, e.g. for NODE_EXTRA_CA_CERTS.
let mut command = Command::new(path.join(node));

command.env("GARDEN_SEA_EXTRACTED_ROOT", OsString::from(path));
command.env(
"GARDEN_SEA_EXECUTABLE_PATH",
// Canonicalize resolves symlinks, which is important so self-update updates in the correct directory.
let executable_path = fs::canonicalize(
process_path::get_executable_path().expect("Failed to get executable path"),
);
)?;
command.env("GARDEN_SEA_EXTRACTED_ROOT", OsString::from(path));
command.env("GARDEN_SEA_EXECUTABLE_PATH", executable_path);

// Allow users to override the heap size if needed.
let max_old_space_size = env::var("GARDEN_MAX_OLD_SPACE_SIZE").unwrap_or("4096".into());
Expand Down

0 comments on commit aba79f5

Please sign in to comment.