fix(compile): handle when DENO_DIR is readonly (#19257)

Closes #19253
This commit is contained in:
David Sherret 2023-05-25 14:27:45 -04:00 committed by GitHub
parent 76400149a4
commit 2ebd61ee1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 134 additions and 72 deletions

View file

@ -582,9 +582,7 @@ fn create_npm_resolver_and_resolution(
impl Inner {
fn new(client: Client) -> Self {
let maybe_custom_root = env::var("DENO_DIR").map(String::into).ok();
let dir =
DenoDir::new(maybe_custom_root).expect("could not access DENO_DIR");
let dir = DenoDir::new(None).expect("could not access DENO_DIR");
let module_registries_location = dir.registries_folder_path();
let http_client = Arc::new(HttpClient::new(None, None));
let module_registries =
@ -904,7 +902,7 @@ impl Inner {
&mut self,
new_cache_path: Option<PathBuf>,
) -> Result<(), AnyError> {
let dir = self.deno_dir_from_maybe_cache_path(new_cache_path.clone())?;
let dir = DenoDir::new(new_cache_path.clone())?;
let workspace_settings = self.config.workspace_settings();
let maybe_root_path = self
.config
@ -938,19 +936,8 @@ impl Inner {
Ok(())
}
fn deno_dir_from_maybe_cache_path(
&self,
cache_path: Option<PathBuf>,
) -> std::io::Result<DenoDir> {
let maybe_custom_root =
cache_path.or_else(|| env::var("DENO_DIR").map(String::into).ok());
DenoDir::new(maybe_custom_root)
}
async fn recreate_npm_services_if_necessary(&mut self) {
let deno_dir = match self
.deno_dir_from_maybe_cache_path(self.maybe_cache_path.clone())
{
let deno_dir = match DenoDir::new(self.maybe_cache_path.clone()) {
Ok(deno_dir) => deno_dir,
Err(err) => {
lsp_warn!("Error getting deno dir: {}", err);