Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions crates/pet-telemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,21 @@ pub fn report_inaccuracies_identified_after_resolving(
executable_not_in_symlinks = false;
}

let mut invalid_prefix = env.prefix.clone().unwrap_or_default() != resolved.prefix.clone()?;
if env.prefix.clone().is_none() {
invalid_prefix = false;
}
let invalid_prefix = if let Some(ref env_prefix) = env.prefix {
let resolved_prefix = resolved.prefix.clone()?;
// Canonicalize both paths to handle symlinks — a venv prefix like
// /usr/local/venvs/myvenv may be a symlink to /usr/local/venvs/versioned/myvenv-1.0.51,
// and sys.prefix returns the resolved target. Without this, the comparison
// produces a false positive "Prefix is incorrect" warning. (See #358)
// Wrap in norm_case to handle Windows UNC prefix (`\\?\`) from canonicalize.
let env_canonical =
norm_case(std::fs::canonicalize(env_prefix).unwrap_or(env_prefix.clone()));
let resolved_canonical =
norm_case(std::fs::canonicalize(&resolved_prefix).unwrap_or(resolved_prefix));
env_canonical != resolved_canonical
} else {
false
};
Comment thread
karthiknadig marked this conversation as resolved.

let mut invalid_arch = env.arch.clone() != resolved.arch.clone();
if env.arch.clone().is_none() {
Expand Down
28 changes: 22 additions & 6 deletions crates/pet/src/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,35 @@ pub fn handle_configure(context: Arc<Context>, id: u32, params: Value) {
Ok(configure_options) => {
// Start in a new thread, we can have multiple requests.
thread::spawn(move || {
let mut cfg = context.configuration.write().unwrap();
// Expand glob patterns in workspace_directories
cfg.workspace_directories = configure_options.workspace_directories.map(|dirs| {
info!("Received configure request");
let now = SystemTime::now();

// Expand glob patterns before acquiring the write lock so we
// don't block readers/writers while traversing the filesystem.
let workspace_directories = configure_options.workspace_directories.map(|dirs| {
trace!("Expanding workspace directory patterns: {:?}", dirs);
expand_glob_patterns(&dirs)
.into_iter()
.filter(|p| p.is_dir())
.collect()
});
cfg.conda_executable = configure_options.conda_executable;
// Expand glob patterns in environment_directories
cfg.environment_directories =
let environment_directories =
configure_options.environment_directories.map(|dirs| {
trace!("Expanding environment directory patterns: {:?}", dirs);
expand_glob_patterns(&dirs)
.into_iter()
.filter(|p| p.is_dir())
.collect()
});
trace!(
"Glob expansion completed in {:?}",
now.elapsed().unwrap_or_default()
);

let mut cfg = context.configuration.write().unwrap();
cfg.workspace_directories = workspace_directories;
cfg.conda_executable = configure_options.conda_executable;
cfg.environment_directories = environment_directories;
cfg.pipenv_executable = configure_options.pipenv_executable;
cfg.poetry_executable = configure_options.poetry_executable;
// We will not support changing the cache directories once set.
Expand All @@ -146,6 +158,10 @@ pub fn handle_configure(context: Arc<Context>, id: u32, params: Value) {
for locator in context.locators.iter() {
locator.configure(&config);
}
info!(
"Configure completed in {:?}",
now.elapsed().unwrap_or_default()
);
send_reply(id, None::<()>);
});
}
Expand Down
Loading