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

fix(garden-sea): resolve symlinks for GARDEN_SEA_EXECUTABLE_PATH #5353

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion garden-sea/src/extract.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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