From 0a75dc70aad9dc7cb51cef9a149a50e340c2eed0 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 1 Oct 2024 15:05:55 +0530 Subject: [PATCH 01/45] fix: update patchver to 0.2 (#25952) Fixes https://github.com/denoland/deno/issues/25940 Forgot to update patchver scripts to latest sui. Ref #25942 --- tools/release/promote_to_release.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 tools/release/promote_to_release.ts diff --git a/tools/release/promote_to_release.ts b/tools/release/promote_to_release.ts old mode 100644 new mode 100755 index c14b590cab..046f4d33a8 --- a/tools/release/promote_to_release.ts +++ b/tools/release/promote_to_release.ts @@ -5,7 +5,7 @@ import { $ } from "jsr:@david/dax@0.41.0"; import { gray } from "jsr:@std/fmt@1/colors"; -import { patchver } from "jsr:@deno/patchver@0.1.0"; +import { patchver } from "jsr:@deno/patchver@0.2.0"; const SUPPORTED_TARGETS = [ "aarch64-apple-darwin", From aafe771b55f769d32145489c57fa33eb823716cb Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 1 Oct 2024 16:18:24 +0530 Subject: [PATCH 02/45] v2.0.0-rc.9 (#25957) --- Cargo.lock | 2 +- cli/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14ef184180..c55b9f97ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1146,7 +1146,7 @@ dependencies = [ [[package]] name = "deno" -version = "2.0.0-rc.8" +version = "2.0.0-rc.9" dependencies = [ "anstream", "async-trait", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index fc786babcf..5b08e82bc5 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno" -version = "2.0.0-rc.8" +version = "2.0.0-rc.9" authors.workspace = true default-run = "deno" edition.workspace = true From c487a86b04dc1b638d204fa4f528fb0b832859ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 1 Oct 2024 14:05:21 +0100 Subject: [PATCH 03/45] fix: Hide 'deno cache' from help output (#25960) `deno cache` was soft-deprecated in favor of `deno install`. It should not show up in the help output. --- cli/args/flags.rs | 1 - tests/integration/flags_tests.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/cli/args/flags.rs b/cli/args/flags.rs index b4f566810c..25634f3844 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -1176,7 +1176,6 @@ static DENO_HELP: &str = cstr!( Tooling: bench Run benchmarks deno bench bench.ts - cache Cache the dependencies check Type-check the dependencies clean Remove the cache directory compile Compile the script into a self contained executable diff --git a/tests/integration/flags_tests.rs b/tests/integration/flags_tests.rs index 160de3ec1d..455507b9fa 100644 --- a/tests/integration/flags_tests.rs +++ b/tests/integration/flags_tests.rs @@ -21,7 +21,6 @@ fn help_output() { "Install script as an executable", "Uninstall a script previously installed with deno install", "Run benchmarks", - "Cache the dependencies", "Type-check the dependencies", "Compile the script into a self contained executable", "Print coverage reports", From 29104384c4cb5aab082749382802560907ebec42 Mon Sep 17 00:00:00 2001 From: MujahedSafaa <168719085+MujahedSafaa@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:24:12 +0300 Subject: [PATCH 04/45] fix: remove the typo in the help message (#25962) This PR fixes: https://github.com/denoland/deno/issues/25274 Remove the extra shorthand -S that attached to the --deny-sys. --- cli/args/flags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/args/flags.rs b/cli/args/flags.rs index 25634f3844..6caef29d9f 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -3273,7 +3273,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command { --deny-net | --deny-net="localhost:8080,deno.land" --deny-env[=<...] Deny access to environment variables. Optionally specify inacessible environment variables. --deny-env | --deny-env="PORT,HOME,PATH" - -S, --deny-sys[=<...] Deny access to OS information. Optionally deny specific APIs by function name. + --deny-sys[=<...] Deny access to OS information. Optionally deny specific APIs by function name. --deny-sys | --deny-sys="systemMemoryInfo,osRelease" --deny-run[=<...] Deny running subprocesses. Optionally specify denied runnable program names. --deny-run | --deny-run="whoami,ps" From 4c8d57db03bac12d2a13566b3cc7454cfbd67314 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 1 Oct 2024 14:05:40 -0400 Subject: [PATCH 05/45] BREAKING: rename "deps" remote cache folder to "remote" (#25969) Closes https://github.com/denoland/deno/issues/25967 Closes #25968 --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- cli/cache/deno_dir.rs | 6 +++--- cli/cache/mod.rs | 11 ----------- cli/factory.rs | 2 +- cli/file_fetcher.rs | 12 ++++++------ cli/lsp/cache.rs | 2 +- tests/integration/jsr_tests.rs | 2 +- tests/specs/info/flag/041_info_flag.out | 2 +- .../info/flag_location/041_info_flag_location.out | 2 +- tests/specs/info/json/info_json.out | 2 +- .../specs/info/json_location/info_json_location.out | 2 +- 12 files changed, 20 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c55b9f97ca..b55e2aeb39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1348,12 +1348,13 @@ dependencies = [ [[package]] name = "deno_cache_dir" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87900cfcd07bdbf3597bc36b77da0c0e7b6c2e65213faa2ed43d9a1ec12bd31d" +checksum = "186a102b13b4512841f5f40784cd25822042d22954afe3b5b070d406d15eb4f2" dependencies = [ "base32", "deno_media_type", + "deno_path_util", "indexmap", "log", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index ce333c728b..b15c1241b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,7 +110,7 @@ console_static_text = "=0.8.1" dashmap = "5.5.3" data-encoding = "2.3.3" data-url = "=0.3.0" -deno_cache_dir = "=0.12.0" +deno_cache_dir = "=0.13.0" deno_package_json = { version = "=0.1.1", default-features = false } dlopen2 = "0.6.1" ecb = "=0.1.2" diff --git a/cli/cache/deno_dir.rs b/cli/cache/deno_dir.rs index 88d8a31c04..7b7059c224 100644 --- a/cli/cache/deno_dir.rs +++ b/cli/cache/deno_dir.rs @@ -126,9 +126,9 @@ impl DenoDir { self.root.join("registries") } - /// Path to the dependencies cache folder. - pub fn deps_folder_path(&self) -> PathBuf { - self.root.join("deps") + /// Path to the remote cache folder. + pub fn remote_folder_path(&self) -> PathBuf { + self.root.join("remote") } /// Path to the origin data cache folder. diff --git a/cli/cache/mod.rs b/cli/cache/mod.rs index 2296bce010..628502c506 100644 --- a/cli/cache/mod.rs +++ b/cli/cache/mod.rs @@ -87,10 +87,6 @@ impl deno_cache_dir::DenoCacheEnv for RealDenoCacheEnv { std::fs::create_dir_all(path) } - fn remove_file(&self, path: &Path) -> std::io::Result<()> { - std::fs::remove_file(path) - } - fn modified(&self, path: &Path) -> std::io::Result> { match std::fs::metadata(path) { Ok(metadata) => Ok(Some( @@ -149,13 +145,6 @@ impl<'a> deno_cache_dir::DenoCacheEnv for DenoCacheEnvFsAdapter<'a> { .map_err(|e| e.into_io_error()) } - fn remove_file(&self, path: &Path) -> std::io::Result<()> { - self - .0 - .remove_sync(path, false) - .map_err(|e| e.into_io_error()) - } - fn modified(&self, path: &Path) -> std::io::Result> { self .0 diff --git a/cli/factory.rs b/cli/factory.rs index 2cef875999..b96a133e98 100644 --- a/cli/factory.rs +++ b/cli/factory.rs @@ -301,7 +301,7 @@ impl CliFactory { pub fn global_http_cache(&self) -> Result<&Arc, AnyError> { self.services.global_http_cache.get_or_try_init(|| { Ok(Arc::new(GlobalHttpCache::new( - self.deno_dir()?.deps_folder_path(), + self.deno_dir()?.remote_folder_path(), crate::cache::RealDenoCacheEnv, ))) }) diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 1bf7635949..69daf14954 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -726,7 +726,7 @@ mod tests { maybe_temp_dir: Option, ) -> (FileFetcher, TempDir, Arc) { let temp_dir = maybe_temp_dir.unwrap_or_default(); - let location = temp_dir.path().join("deps").to_path_buf(); + let location = temp_dir.path().join("remote").to_path_buf(); let blob_store: Arc = Default::default(); let file_fetcher = FileFetcher::new( Arc::new(GlobalHttpCache::new(location, RealDenoCacheEnv)), @@ -964,7 +964,7 @@ mod tests { // This creates a totally new instance, simulating another Deno process // invocation and indicates to "cache bust". - let location = temp_dir.path().join("deps").to_path_buf(); + let location = temp_dir.path().join("remote").to_path_buf(); let file_fetcher = FileFetcher::new( Arc::new(GlobalHttpCache::new( location, @@ -990,7 +990,7 @@ mod tests { async fn test_fetch_uses_cache() { let _http_server_guard = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("deps").to_path_buf(); + let location = temp_dir.path().join("remote").to_path_buf(); let specifier = resolve_url("http://localhost:4545/subdir/mismatch_ext.ts").unwrap(); @@ -1156,7 +1156,7 @@ mod tests { async fn test_fetch_uses_cache_with_redirects() { let _http_server_guard = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("deps").to_path_buf(); + let location = temp_dir.path().join("remote").to_path_buf(); let specifier = resolve_url("http://localhost:4548/subdir/mismatch_ext.ts").unwrap(); let redirected_specifier = @@ -1324,7 +1324,7 @@ mod tests { async fn test_fetch_no_remote() { let _http_server_guard = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("deps").to_path_buf(); + let location = temp_dir.path().join("remote").to_path_buf(); let file_fetcher = FileFetcher::new( Arc::new(GlobalHttpCache::new( location, @@ -1350,7 +1350,7 @@ mod tests { async fn test_fetch_cache_only() { let _http_server_guard = test_util::http_server(); let temp_dir = TempDir::new(); - let location = temp_dir.path().join("deps").to_path_buf(); + let location = temp_dir.path().join("remote").to_path_buf(); let file_fetcher_01 = FileFetcher::new( Arc::new(GlobalHttpCache::new(location.clone(), RealDenoCacheEnv)), CacheSetting::Only, diff --git a/cli/lsp/cache.rs b/cli/lsp/cache.rs index db10dc9677..fbf9ea6f1b 100644 --- a/cli/lsp/cache.rs +++ b/cli/lsp/cache.rs @@ -94,7 +94,7 @@ impl LspCache { let deno_dir = DenoDir::new(global_cache_path) .expect("should be infallible with absolute custom root"); let global = Arc::new(GlobalHttpCache::new( - deno_dir.deps_folder_path(), + deno_dir.remote_folder_path(), crate::cache::RealDenoCacheEnv, )); Self { diff --git a/tests/integration/jsr_tests.rs b/tests/integration/jsr_tests.rs index af5b24fe41..c4812e6bfb 100644 --- a/tests/integration/jsr_tests.rs +++ b/tests/integration/jsr_tests.rs @@ -191,7 +191,7 @@ fn reload_info_not_found_cache_but_exists_remote() { Url::parse(&format!("http://127.0.0.1:4250/{}/meta.json", package)) .unwrap(); let cache = deno_cache_dir::GlobalHttpCache::new( - deno_dir.path().join("deps").to_path_buf(), + deno_dir.path().join("remote").to_path_buf(), deno_cache_dir::TestRealDenoCacheEnv, ); let entry = cache diff --git a/tests/specs/info/flag/041_info_flag.out b/tests/specs/info/flag/041_info_flag.out index 3506a29e48..72a00be303 100644 --- a/tests/specs/info/flag/041_info_flag.out +++ b/tests/specs/info/flag/041_info_flag.out @@ -1,5 +1,5 @@ DENO_DIR location: [WILDCARD] -Remote modules cache: [WILDCARD]deps +Remote modules cache: [WILDCARD]remote npm modules cache: [WILDCARD]npm Emitted modules cache: [WILDCARD]gen Language server registries cache: [WILDCARD]registries diff --git a/tests/specs/info/flag_location/041_info_flag_location.out b/tests/specs/info/flag_location/041_info_flag_location.out index b9e72f6590..684db2eec5 100644 --- a/tests/specs/info/flag_location/041_info_flag_location.out +++ b/tests/specs/info/flag_location/041_info_flag_location.out @@ -1,5 +1,5 @@ DENO_DIR location: [WILDCARD] -Remote modules cache: [WILDCARD]deps +Remote modules cache: [WILDCARD]remote npm modules cache: [WILDCARD]npm Emitted modules cache: [WILDCARD]gen Language server registries cache: [WILDCARD]registries diff --git a/tests/specs/info/json/info_json.out b/tests/specs/info/json/info_json.out index 607489ca39..551f61026d 100644 --- a/tests/specs/info/json/info_json.out +++ b/tests/specs/info/json/info_json.out @@ -1,7 +1,7 @@ { "version": 1, "denoDir": "[WILDCARD]", - "modulesCache": "[WILDCARD]deps", + "modulesCache": "[WILDCARD]remote", "npmCache": "[WILDCARD]npm", "typescriptCache": "[WILDCARD]gen", "registryCache": "[WILDCARD]registries", diff --git a/tests/specs/info/json_location/info_json_location.out b/tests/specs/info/json_location/info_json_location.out index 004bf03db1..6d01ba451d 100644 --- a/tests/specs/info/json_location/info_json_location.out +++ b/tests/specs/info/json_location/info_json_location.out @@ -1,7 +1,7 @@ { "version": 1, "denoDir": "[WILDCARD]", - "modulesCache": "[WILDCARD]deps", + "modulesCache": "[WILDCARD]remote", "npmCache": "[WILDCARD]npm", "typescriptCache": "[WILDCARD]gen", "registryCache": "[WILDCARD]registries", From 41a70898adfc61b9020dfdfec17d374aac70d935 Mon Sep 17 00:00:00 2001 From: Ian Bull Date: Tue, 1 Oct 2024 11:26:06 -0700 Subject: [PATCH 06/45] refactor(ext): align error messages (#25914) Aligns the error messages in the ext folder to be in-line with the Deno style guide. https://github.com/denoland/deno/issues/25269 --- ext/net/02_tls.js | 8 +++++--- ext/url/00_url.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/net/02_tls.js b/ext/net/02_tls.js index 11d19440f7..6dad965590 100644 --- a/ext/net/02_tls.js +++ b/ext/net/02_tls.js @@ -124,17 +124,19 @@ function loadTlsKeyPair(api, { // Check for "pem" format if (keyFormat !== undefined && keyFormat !== "pem") { - throw new TypeError('If `keyFormat` is specified, it must be "pem"'); + throw new TypeError( + `If "keyFormat" is specified, it must be "pem": received "${keyFormat}"`, + ); } if (cert !== undefined && key === undefined) { throw new TypeError( - `If \`cert\` is specified, \`key\` must be specified as well for \`${api}\`.`, + `If \`cert\` is specified, \`key\` must be specified as well for \`${api}\``, ); } if (cert === undefined && key !== undefined) { throw new TypeError( - `If \`key\` is specified, \`cert\` must be specified as well for \`${api}\`.`, + `If \`key\` is specified, \`cert\` must be specified as well for \`${api}\``, ); } diff --git a/ext/url/00_url.js b/ext/url/00_url.js index 577caba902..ec875da768 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -139,7 +139,7 @@ class URLSearchParams { throw new TypeError( `${prefix}: Item ${ i + 0 - } in the parameter list does have length 2 exactly.`, + } in the parameter list does have length 2 exactly`, ); } return [pair[0], pair[1]]; From f9300004152ba4b3d091beb04d74f37b3b8ec281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 1 Oct 2024 22:49:32 +0100 Subject: [PATCH 07/45] feat: Add suggestion for packages using Node-API addons (#25975) This commit adds a suggestion with information and hint how to resolve situation when user tries to run an npm package with Node-API addons using global cache (which is currently not supported). Closes https://github.com/denoland/deno/issues/25974 --- cli/main.rs | 25 +++++++++++++++++++++++++ runtime/fmt_errors.rs | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/cli/main.rs b/cli/main.rs index c0eccab5df..31bebc882f 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -392,6 +392,31 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec { "Run again with `--unstable-webgpu` flag to enable this API.", ), ]; + // Try to capture errors like: + // ``` + // Uncaught Error: Cannot find module '../build/Release/canvas.node' + // Require stack: + // - /.../deno/npm/registry.npmjs.org/canvas/2.11.2/lib/bindings.js + // - /.../.cache/deno/npm/registry.npmjs.org/canvas/2.11.2/lib/canvas.js + // ``` + } else if msg.contains("Cannot find module") + && msg.contains("Require stack") + && msg.contains(".node'") + { + return vec![ + FixSuggestion::info_multiline( + &[ + "Trying to execute an npm package using Node-API addons,", + "these packages require local `node_modules` directory to be present." + ] + ), + FixSuggestion::hint_multiline( + &[ + "Add `\"nodeModulesDir\": \"auto\" option to `deno.json`, and then run", + "`deno install --allow-scripts=npm: --entrypoint