environments: Don't load shell environments in non-local worktrees (#23138)

This fixes an error message that has shown up for me when joining collab
projects: "Unable to load shell environment in /<path on another
machine/"

Release Notes:

- Fixed error message about shell environment failing to load when
joining projects in collaboration.
This commit is contained in:
Thorsten Ball 2025-01-14 18:13:55 +01:00 committed by GitHub
parent 39ac6e4a75
commit 91b36c31e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,6 +13,7 @@ use crate::{
};
pub struct ProjectEnvironment {
worktree_store: Model<WorktreeStore>,
cli_environment: Option<HashMap<String, String>>,
environments: HashMap<WorktreeId, Shared<Task<Option<HashMap<String, String>>>>>,
environment_error_messages: HashMap<WorktreeId, EnvironmentErrorMessage>,
@ -33,6 +34,7 @@ impl ProjectEnvironment {
.detach();
Self {
worktree_store: worktree_store.clone(),
cli_environment,
environments: Default::default(),
environment_error_messages: Default::default(),
@ -102,6 +104,16 @@ impl ProjectEnvironment {
return Task::ready(None).shared();
};
if self
.worktree_store
.read(cx)
.worktree_for_id(worktree_id, cx)
.map(|w| !w.read(cx).is_local())
.unwrap_or(true)
{
return Task::ready(None).shared();
}
if let Some(task) = self.environments.get(&worktree_id) {
task.clone()
} else {