Wrap path (#4775)

* Rewrite imports

* Wrap access to path through a global path.Context

* Allow override with zone

* Fix lints

* Add test for imports

* Fixed tests

* Fix path import
diff --git a/lib/src/ascii_tree.dart b/lib/src/ascii_tree.dart
index 0b26869..a32b1b7 100644
--- a/lib/src/ascii_tree.dart
+++ b/lib/src/ascii_tree.dart
@@ -9,9 +9,9 @@
 import 'dart:io';
 
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 
 import 'log.dart' as log;
+import 'path.dart';
 import 'utils.dart';
 
 /// Draws a tree for the given list of files
diff --git a/lib/src/authentication/token_store.dart b/lib/src/authentication/token_store.dart
index d11f63c..4d87b65 100644
--- a/lib/src/authentication/token_store.dart
+++ b/lib/src/authentication/token_store.dart
@@ -5,11 +5,10 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
-
 import '../exceptions.dart';
 import '../io.dart';
 import '../log.dart' as log;
+import '../path.dart';
 import 'credential.dart';
 
 /// Stores and manages authentication credentials.
diff --git a/lib/src/command.dart b/lib/src/command.dart
index 976ce53..89e6628 100644
--- a/lib/src/command.dart
+++ b/lib/src/command.dart
@@ -10,7 +10,6 @@
 import 'package:collection/collection.dart' show IterableExtension;
 import 'package:http/http.dart' as http;
 import 'package:meta/meta.dart';
-import 'package:path/path.dart' as p;
 
 import 'authentication/token_store.dart';
 import 'entrypoint.dart';
@@ -20,6 +19,7 @@
 import 'global_packages.dart';
 import 'http.dart';
 import 'log.dart' as log;
+import 'path.dart';
 import 'pub_embeddable_command.dart';
 import 'sdk.dart';
 import 'solver.dart';
diff --git a/lib/src/command/add.dart b/lib/src/command/add.dart
index 5d0c39c..32a8a06 100644
--- a/lib/src/command/add.dart
+++ b/lib/src/command/add.dart
@@ -7,7 +7,6 @@
 import 'package:args/args.dart';
 import 'package:args/command_runner.dart';
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 import 'package:yaml/yaml.dart';
 import 'package:yaml_edit/yaml_edit.dart';
@@ -19,6 +18,7 @@
 import '../io.dart';
 import '../log.dart' as log;
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../pubspec_utils.dart';
 import '../sdk.dart';
diff --git a/lib/src/command/cache_gc.dart b/lib/src/command/cache_gc.dart
index 0887625..6f876d8 100644
--- a/lib/src/command/cache_gc.dart
+++ b/lib/src/command/cache_gc.dart
@@ -5,13 +5,12 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
-
 import '../command.dart';
 import '../command_runner.dart';
 import '../io.dart';
 import '../log.dart' as log;
 import '../package_config.dart';
+import '../path.dart';
 import '../utils.dart';
 
 class CacheGcCommand extends PubCommand {
diff --git a/lib/src/command/dependency_services.dart b/lib/src/command/dependency_services.dart
index 944bd11..72d4d6d 100644
--- a/lib/src/command/dependency_services.dart
+++ b/lib/src/command/dependency_services.dart
@@ -10,7 +10,6 @@
 import 'dart:io';
 
 import 'package:collection/collection.dart';
-import 'package:path/path.dart';
 import 'package:pub_semver/pub_semver.dart';
 import 'package:yaml/yaml.dart';
 import 'package:yaml_edit/yaml_edit.dart';
@@ -23,6 +22,7 @@
 import '../log.dart' as log;
 import '../package.dart';
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../pubspec_utils.dart';
 import '../sdk.dart';
@@ -481,7 +481,7 @@
         (package) => Pubspec.parse(
           updatedPubspecs[package.dir].toString(),
           cache.sources,
-          location: toUri(package.pubspecPath),
+          location: p.toUri(package.pubspecPath),
           containingDescription: ResolvedRootDescription(
             RootDescription(package.dir),
           ),
diff --git a/lib/src/command/global_run.dart b/lib/src/command/global_run.dart
index 93059d4..61bae17 100644
--- a/lib/src/command/global_run.dart
+++ b/lib/src/command/global_run.dart
@@ -4,11 +4,10 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
-
 import '../command.dart';
 import '../executable.dart';
 import '../log.dart' as log;
+import '../path.dart';
 import '../utils.dart';
 
 /// Handles the `global run` pub command.
diff --git a/lib/src/command/lish.dart b/lib/src/command/lish.dart
index a69fdb3..62836ed 100644
--- a/lib/src/command/lish.dart
+++ b/lib/src/command/lish.dart
@@ -8,7 +8,6 @@
 import 'dart:typed_data';
 
 import 'package:http/http.dart' as http;
-import 'package:path/path.dart' as p;
 
 import '../ascii_tree.dart' as tree;
 import '../authentication/client.dart';
@@ -20,6 +19,7 @@
 import '../io.dart';
 import '../log.dart' as log;
 import '../oauth2.dart' as oauth2;
+import '../path.dart';
 import '../pubspec.dart';
 import '../solver/type.dart';
 import '../source/hosted.dart' show validateAndNormalizeHostedUrl;
diff --git a/lib/src/command/outdated.dart b/lib/src/command/outdated.dart
index 784237c..8d44a30 100644
--- a/lib/src/command/outdated.dart
+++ b/lib/src/command/outdated.dart
@@ -6,7 +6,6 @@
 import 'dart:convert';
 
 import 'package:collection/collection.dart' show IterableExtension;
-import 'package:path/path.dart' as p;
 
 import '../command.dart';
 import '../command_runner.dart';
@@ -17,6 +16,7 @@
 import '../log.dart';
 import '../package.dart';
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../pubspec_utils.dart';
 import '../solver.dart';
diff --git a/lib/src/command/run.dart b/lib/src/command/run.dart
index 55ca865..e7e496a 100644
--- a/lib/src/command/run.dart
+++ b/lib/src/command/run.dart
@@ -4,12 +4,11 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
-
 import '../command.dart';
 import '../entrypoint.dart';
 import '../executable.dart';
 import '../log.dart' as log;
+import '../path.dart';
 import '../utils.dart';
 
 /// Handles the `run` pub command.
diff --git a/lib/src/command/unpack.dart b/lib/src/command/unpack.dart
index f8fe7cb..fcb4193 100644
--- a/lib/src/command/unpack.dart
+++ b/lib/src/command/unpack.dart
@@ -2,7 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 import 'package:yaml/yaml.dart';
 
@@ -12,6 +11,7 @@
 import '../io.dart';
 import '../log.dart' as log;
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../sdk.dart';
 import '../solver/type.dart';
diff --git a/lib/src/command/workspace_list.dart b/lib/src/command/workspace_list.dart
index 7d111e9..174b60f 100644
--- a/lib/src/command/workspace_list.dart
+++ b/lib/src/command/workspace_list.dart
@@ -4,10 +4,9 @@
 
 import 'dart:convert';
 
-import 'package:path/path.dart' as p;
-
 import '../command.dart';
 import '../log.dart';
+import '../path.dart';
 import '../utils.dart';
 
 class WorkspaceListCommand extends PubCommand {
diff --git a/lib/src/command_runner.dart b/lib/src/command_runner.dart
index 9a372f1..35f0823 100644
--- a/lib/src/command_runner.dart
+++ b/lib/src/command_runner.dart
@@ -7,7 +7,6 @@
 
 import 'package:args/args.dart';
 import 'package:args/command_runner.dart';
-import 'package:path/path.dart' as p;
 
 import 'command.dart' show PubTopLevel, lineLength;
 import 'command/add.dart';
@@ -35,6 +34,7 @@
 import 'io.dart';
 import 'log.dart' as log;
 import 'log.dart';
+import 'path.dart';
 import 'sdk.dart';
 import 'utils.dart';
 
diff --git a/lib/src/dart.dart b/lib/src/dart.dart
index 8592781..9a12e8d 100644
--- a/lib/src/dart.dart
+++ b/lib/src/dart.dart
@@ -14,11 +14,11 @@
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:analyzer/diagnostic/diagnostic.dart';
 import 'package:frontend_server_client/frontend_server_client.dart';
-import 'package:path/path.dart' as p;
 
 import 'exceptions.dart';
 import 'io.dart';
 import 'log.dart' as log;
+import 'path.dart';
 
 class AnalysisContextManager {
   static final sessions = <String, AnalysisContextManager>{};
diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart
index 62dfa78..8e52054 100644
--- a/lib/src/entrypoint.dart
+++ b/lib/src/entrypoint.dart
@@ -8,7 +8,6 @@
 import 'dart:math';
 
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 import 'package:pool/pool.dart';
 import 'package:pub_semver/pub_semver.dart';
 import 'package:source_span/source_span.dart';
@@ -27,6 +26,7 @@
 import 'package_config.dart';
 import 'package_graph.dart';
 import 'package_name.dart';
+import 'path.dart';
 import 'pubspec.dart';
 import 'pubspec_utils.dart';
 import 'sdk.dart';
diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index ee096d5..7d7a7dd 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -8,7 +8,6 @@
 
 import 'package:args/args.dart';
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 
 import 'entrypoint.dart';
 import 'exceptions.dart';
@@ -18,6 +17,7 @@
 import 'log.dart' as log;
 import 'log.dart';
 import 'package_config.dart';
+import 'path.dart';
 import 'sdk.dart';
 import 'system_cache.dart';
 import 'utils.dart';
diff --git a/lib/src/git.dart b/lib/src/git.dart
index 09f401a..0d6442d 100644
--- a/lib/src/git.dart
+++ b/lib/src/git.dart
@@ -11,13 +11,13 @@
 import 'dart:typed_data';
 
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import 'command_runner.dart';
 import 'exceptions.dart';
 import 'io.dart';
 import 'log.dart' as log;
+import 'path.dart';
 import 'utils.dart';
 
 /// An exception thrown because a git command failed.
diff --git a/lib/src/global_packages.dart b/lib/src/global_packages.dart
index b0793e0..1db8cc6 100644
--- a/lib/src/global_packages.dart
+++ b/lib/src/global_packages.dart
@@ -6,7 +6,6 @@
 import 'dart:io';
 
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import 'command_runner.dart';
@@ -19,6 +18,7 @@
 import 'log.dart' as log;
 import 'package.dart';
 import 'package_name.dart';
+import 'path.dart';
 import 'pubspec.dart';
 import 'sdk.dart';
 import 'sdk/dart.dart';
diff --git a/lib/src/ignore.dart b/lib/src/ignore.dart
index a7a1adf..ad497bf 100644
--- a/lib/src/ignore.dart
+++ b/lib/src/ignore.dart
@@ -192,7 +192,7 @@
   ///
   /// ```dart
   /// import 'dart:io';
-  /// import 'package:path/path.dart' as p;
+  /// import 'package:pub/src/path.dart';
   /// import 'package:pub/src/ignore.dart';
   ///
   /// void main(List<String> args) {
diff --git a/lib/src/io.dart b/lib/src/io.dart
index 7c11a00..00ad322 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -18,7 +18,6 @@
 import 'package:http/http.dart' show ByteStream;
 import 'package:http_multi_server/http_multi_server.dart';
 import 'package:meta/meta.dart';
-import 'package:path/path.dart' as p;
 import 'package:pool/pool.dart';
 import 'package:stack_trace/stack_trace.dart';
 import 'package:tar/tar.dart';
@@ -28,6 +27,7 @@
 import 'exit_codes.dart' as exit_codes;
 import 'gzip/gzip.dart';
 import 'log.dart' as log;
+import 'path.dart';
 import 'utils.dart';
 
 export 'package:http/http.dart' show ByteStream;
diff --git a/lib/src/lock_file.dart b/lib/src/lock_file.dart
index a374f6d..70d2599 100644
--- a/lib/src/lock_file.dart
+++ b/lib/src/lock_file.dart
@@ -4,13 +4,13 @@
 
 import 'package:collection/collection.dart' hide mapMap;
 import 'package:meta/meta.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 import 'package:source_span/source_span.dart';
 import 'package:yaml/yaml.dart';
 
 import 'io.dart';
 import 'package_name.dart';
+import 'path.dart';
 import 'pubspec.dart';
 import 'system_cache.dart';
 import 'utils.dart';
diff --git a/lib/src/log.dart b/lib/src/log.dart
index ef13dd9..00fad85 100644
--- a/lib/src/log.dart
+++ b/lib/src/log.dart
@@ -11,13 +11,13 @@
 import 'dart:math';
 
 import 'package:args/command_runner.dart';
-import 'package:path/path.dart' as p;
 import 'package:source_span/source_span.dart';
 import 'package:stack_trace/stack_trace.dart';
 
 import 'entrypoint.dart';
 import 'exceptions.dart';
 import 'io.dart';
+import 'path.dart';
 import 'progress.dart';
 import 'sdk.dart';
 import 'transcript.dart';
diff --git a/lib/src/oauth2.dart b/lib/src/oauth2.dart
index cc070b1..0cf841a 100644
--- a/lib/src/oauth2.dart
+++ b/lib/src/oauth2.dart
@@ -12,13 +12,13 @@
 import 'package:http/http.dart' as http;
 import 'package:http/retry.dart';
 import 'package:http_parser/http_parser.dart';
-import 'package:path/path.dart' as p;
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:shelf/shelf_io.dart' as shelf_io;
 
 import 'http.dart';
 import 'io.dart';
 import 'log.dart' as log;
+import 'path.dart';
 import 'utils.dart';
 
 /// The global HTTP client with basic retries. Used instead of retryForHttp for
diff --git a/lib/src/package.dart b/lib/src/package.dart
index 6dc6711..1fc04f4 100644
--- a/lib/src/package.dart
+++ b/lib/src/package.dart
@@ -6,7 +6,6 @@
 
 import 'package:glob/glob.dart';
 import 'package:glob/list_local_fs.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import 'exceptions.dart';
@@ -16,6 +15,7 @@
 import 'language_version.dart';
 import 'log.dart' as log;
 import 'package_name.dart';
+import 'path.dart';
 import 'pubspec.dart';
 import 'utils.dart';
 
@@ -292,7 +292,7 @@
   /// always start with [dir] (thus always be relative to the current working
   /// directory) or absolute id [dir] is absolute.
   ///
-  /// To convert them to paths relative to the package root, use [p.relative].
+  /// To convert them to paths relative to the package root, use `p.relative`.
   List<String> listFiles({
     String? beneath,
     bool recursive = true,
diff --git a/lib/src/package_config.dart b/lib/src/package_config.dart
index ffffe59..4a13777 100644
--- a/lib/src/package_config.dart
+++ b/lib/src/package_config.dart
@@ -4,10 +4,10 @@
 
 import 'dart:convert';
 
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import 'language_version.dart';
+import 'path.dart';
 
 /// Contents of a `.dart_tool/package_config.json` file.
 class PackageConfig {
diff --git a/lib/src/path.dart b/lib/src/path.dart
new file mode 100644
index 0000000..f32135f
--- /dev/null
+++ b/lib/src/path.dart
@@ -0,0 +1,35 @@
+// Copyright (c) 2026, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+import 'package:path/path.dart' as path;
+
+/// A default [path.Context] for use in `pub` code.
+path.Context get p =>
+    Zone.current[_pathContextKey] as path.Context? ?? path.context;
+
+/// The key for the [path.Context] in the current [Zone].
+final _pathContextKey = Object();
+
+/// Runs [callback] in a [Zone] where [p] is overridden by [pathContext].
+Future<T> withPathContext<T>(
+  FutureOr<T> Function() callback, {
+  required path.Context pathContext,
+}) {
+  return runZoned(() async {
+    return await callback();
+  }, zoneValues: {_pathContextKey: pathContext});
+}
+
+extension PathContextExt on path.Context {
+  /// A default context for manipulating POSIX paths.
+  path.Context get posix => path.posix;
+
+  /// A default context for manipulating URLs.
+  ///
+  /// URL path equality is undefined for paths that differ only in their
+  /// percent-encoding or only in the case of their host segment.
+  path.Context get url => path.url;
+}
diff --git a/lib/src/pubspec.dart b/lib/src/pubspec.dart
index 0170c77..a0e2ab2 100644
--- a/lib/src/pubspec.dart
+++ b/lib/src/pubspec.dart
@@ -3,7 +3,6 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:collection/collection.dart' hide mapMap;
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 import 'package:source_span/source_span.dart';
 import 'package:yaml/yaml.dart';
@@ -13,6 +12,7 @@
 import 'language_version.dart';
 import 'package.dart';
 import 'package_name.dart';
+import 'path.dart';
 import 'pubspec_parse.dart';
 import 'sdk.dart';
 import 'source.dart';
diff --git a/lib/src/sdk/dart.dart b/lib/src/sdk/dart.dart
index 4b3e397..a67f751 100644
--- a/lib/src/sdk/dart.dart
+++ b/lib/src/sdk/dart.dart
@@ -4,11 +4,11 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 import 'package:yaml/yaml.dart';
 
 import '../io.dart';
+import '../path.dart';
 import '../sdk.dart';
 import 'sdk_package_config.dart';
 
diff --git a/lib/src/sdk/flutter.dart b/lib/src/sdk/flutter.dart
index 4f17abd..4fb494a 100644
--- a/lib/src/sdk/flutter.dart
+++ b/lib/src/sdk/flutter.dart
@@ -5,11 +5,11 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import '../io.dart';
 import '../log.dart';
+import '../path.dart';
 import '../sdk.dart';
 
 class FlutterSdk extends Sdk {
diff --git a/lib/src/sdk/fuchsia.dart b/lib/src/sdk/fuchsia.dart
index 6a49127..bb3a78d 100644
--- a/lib/src/sdk/fuchsia.dart
+++ b/lib/src/sdk/fuchsia.dart
@@ -4,10 +4,10 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import '../io.dart';
+import '../path.dart';
 import '../sdk.dart';
 
 class FuchsiaSdk extends Sdk {
diff --git a/lib/src/solver/report.dart b/lib/src/solver/report.dart
index bfc426d..60c246a 100644
--- a/lib/src/solver/report.dart
+++ b/lib/src/solver/report.dart
@@ -3,13 +3,13 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import '../command_runner.dart';
 import '../lock_file.dart';
 import '../log.dart' as log;
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../source/hosted.dart';
 import '../source/root.dart';
diff --git a/lib/src/source/cached.dart b/lib/src/source/cached.dart
index 21a4db9..0a69ad2 100644
--- a/lib/src/source/cached.dart
+++ b/lib/src/source/cached.dart
@@ -4,12 +4,12 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import '../io.dart';
 import '../package.dart';
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../source.dart';
 import '../system_cache.dart';
diff --git a/lib/src/source/git.dart b/lib/src/source/git.dart
index 95edf1a..238cd1e 100644
--- a/lib/src/source/git.dart
+++ b/lib/src/source/git.dart
@@ -5,7 +5,6 @@
 import 'dart:async';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pool/pool.dart';
 import 'package:pub_semver/pub_semver.dart';
 
@@ -16,6 +15,7 @@
 import '../log.dart' as log;
 import '../package.dart';
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../source.dart';
 import '../system_cache.dart';
diff --git a/lib/src/source/hosted.dart b/lib/src/source/hosted.dart
index 25fe27f..9f04928 100644
--- a/lib/src/source/hosted.dart
+++ b/lib/src/source/hosted.dart
@@ -12,7 +12,6 @@
 import 'package:crypto/crypto.dart';
 import 'package:http/http.dart' as http;
 import 'package:meta/meta.dart';
-import 'package:path/path.dart' as p;
 import 'package:pool/pool.dart';
 import 'package:pub_semver/pub_semver.dart';
 import 'package:stack_trace/stack_trace.dart';
@@ -26,6 +25,7 @@
 import '../log.dart' as log;
 import '../package.dart';
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../rate_limited_scheduler.dart';
 import '../source.dart';
diff --git a/lib/src/source/path.dart b/lib/src/source/path.dart
index a5939e7..88e0c3f 100644
--- a/lib/src/source/path.dart
+++ b/lib/src/source/path.dart
@@ -4,13 +4,13 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import '../exceptions.dart';
 import '../io.dart';
 import '../language_version.dart';
 import '../package_name.dart';
+import '../path.dart';
 import '../pubspec.dart';
 import '../source.dart';
 import '../system_cache.dart';
diff --git a/lib/src/system_cache.dart b/lib/src/system_cache.dart
index 90735e7..274d495 100644
--- a/lib/src/system_cache.dart
+++ b/lib/src/system_cache.dart
@@ -6,16 +6,16 @@
 import 'dart:io';
 
 import 'package:crypto/crypto.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import 'authentication/token_store.dart';
 import 'exceptions.dart';
-import 'io.dart';
 import 'io.dart' as io show createTempDir;
+import 'io.dart';
 import 'log.dart' as log;
 import 'package.dart';
 import 'package_name.dart';
+import 'path.dart';
 import 'pubspec.dart';
 import 'source.dart';
 import 'source/cached.dart';
diff --git a/lib/src/validator.dart b/lib/src/validator.dart
index 8fa64f9..3dcb02b 100644
--- a/lib/src/validator.dart
+++ b/lib/src/validator.dart
@@ -5,12 +5,12 @@
 import 'dart:async';
 
 import 'package:meta/meta.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub_semver/pub_semver.dart';
 
 import 'entrypoint.dart';
 import 'log.dart' as log;
 import 'package.dart';
+import 'path.dart';
 import 'sdk.dart';
 import 'system_cache.dart';
 import 'validator/analyze.dart';
diff --git a/lib/src/validator/analyze.dart b/lib/src/validator/analyze.dart
index a806cb9..f3e48a8 100644
--- a/lib/src/validator/analyze.dart
+++ b/lib/src/validator/analyze.dart
@@ -5,11 +5,9 @@
 import 'dart:async';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
-
 import '../io.dart';
-
 import '../log.dart';
+import '../path.dart';
 import '../validator.dart';
 
 /// Runs `dart analyze` and gives a warning if it returns non-zero.
diff --git a/lib/src/validator/changelog.dart b/lib/src/validator/changelog.dart
index 21c3753..a8243b5 100644
--- a/lib/src/validator/changelog.dart
+++ b/lib/src/validator/changelog.dart
@@ -6,9 +6,9 @@
 import 'dart:convert';
 
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 
 import '../io.dart';
+import '../path.dart';
 import '../validator.dart';
 
 final _changelogRegexp = RegExp(r'^CHANGELOG($|\.)', caseSensitive: false);
diff --git a/lib/src/validator/compiled_dartdoc.dart b/lib/src/validator/compiled_dartdoc.dart
index 9b031e2..3325f41 100644
--- a/lib/src/validator/compiled_dartdoc.dart
+++ b/lib/src/validator/compiled_dartdoc.dart
@@ -4,9 +4,8 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
-
 import '../io.dart';
+import '../path.dart';
 import '../validator.dart';
 
 /// Validates that a package doesn't contain compiled Dartdoc output.
diff --git a/lib/src/validator/devtools_extension.dart b/lib/src/validator/devtools_extension.dart
index 9d2887c..57f0ba7 100644
--- a/lib/src/validator/devtools_extension.dart
+++ b/lib/src/validator/devtools_extension.dart
@@ -3,9 +3,9 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'dart:async';
-import 'package:path/path.dart' as p;
 
 import '../io.dart';
+import '../path.dart';
 import '../validator.dart';
 
 //   If the `extension/devtools/` directory exists
diff --git a/lib/src/validator/directory.dart b/lib/src/validator/directory.dart
index db254b4..47ce622 100644
--- a/lib/src/validator/directory.dart
+++ b/lib/src/validator/directory.dart
@@ -4,9 +4,8 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
-
 import '../io.dart';
+import '../path.dart';
 import '../validator.dart';
 
 /// A validator that validates a package's top-level directories.
diff --git a/lib/src/validator/executable.dart b/lib/src/validator/executable.dart
index c5d5282..c8c2e5d 100644
--- a/lib/src/validator/executable.dart
+++ b/lib/src/validator/executable.dart
@@ -4,7 +4,7 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
+import '../path.dart';
 
 import '../validator.dart';
 
diff --git a/lib/src/validator/git_status.dart b/lib/src/validator/git_status.dart
index a4d2585..bef542d 100644
--- a/lib/src/validator/git_status.dart
+++ b/lib/src/validator/git_status.dart
@@ -6,10 +6,9 @@
 import 'dart:convert';
 import 'dart:typed_data';
 
-import 'package:path/path.dart' as p;
-
 import '../git.dart' as git;
 import '../log.dart' as log;
+import '../path.dart';
 import '../utils.dart';
 import '../validator.dart';
 
diff --git a/lib/src/validator/gitignore.dart b/lib/src/validator/gitignore.dart
index 4afea11..1d9fe3b 100644
--- a/lib/src/validator/gitignore.dart
+++ b/lib/src/validator/gitignore.dart
@@ -7,12 +7,11 @@
 import 'dart:io';
 import 'dart:typed_data';
 
-import 'package:path/path.dart' as p;
-
 import '../git.dart' as git;
 import '../ignore.dart';
 import '../io.dart';
 import '../log.dart' as log;
+import '../path.dart';
 import '../utils.dart';
 import '../validator.dart';
 
diff --git a/lib/src/validator/leak_detection.dart b/lib/src/validator/leak_detection.dart
index 3da1359..e65000f 100644
--- a/lib/src/validator/leak_detection.dart
+++ b/lib/src/validator/leak_detection.dart
@@ -10,11 +10,11 @@
 import 'dart:math';
 
 import 'package:meta/meta.dart';
-import 'package:path/path.dart' as p;
 import 'package:pool/pool.dart';
 import 'package:source_span/source_span.dart';
 
 import '../ignore.dart';
+import '../path.dart';
 import '../validator.dart';
 
 /// All recognized secrets fit in ASCII (first seven bits). So for speed we
diff --git a/lib/src/validator/license.dart b/lib/src/validator/license.dart
index 41bfe64..6458eff 100644
--- a/lib/src/validator/license.dart
+++ b/lib/src/validator/license.dart
@@ -4,7 +4,7 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
+import '../path.dart';
 
 import '../validator.dart';
 
diff --git a/lib/src/validator/name.dart b/lib/src/validator/name.dart
index 1988f6a..4391c4a 100644
--- a/lib/src/validator/name.dart
+++ b/lib/src/validator/name.dart
@@ -4,7 +4,7 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
+import '../path.dart';
 
 import '../utils.dart';
 import '../validator.dart';
diff --git a/lib/src/validator/pubspec.dart b/lib/src/validator/pubspec.dart
index f04ecaf..0f53b68 100644
--- a/lib/src/validator/pubspec.dart
+++ b/lib/src/validator/pubspec.dart
@@ -4,7 +4,7 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
+import '../path.dart';
 
 import '../validator.dart';
 
diff --git a/lib/src/validator/readme.dart b/lib/src/validator/readme.dart
index 815c96b..d6c8bfa 100644
--- a/lib/src/validator/readme.dart
+++ b/lib/src/validator/readme.dart
@@ -5,9 +5,8 @@
 import 'dart:async';
 import 'dart:convert';
 
-import 'package:path/path.dart' as p;
-
 import '../io.dart';
+import '../path.dart';
 import '../validator.dart';
 
 final _readmeRegexp = RegExp(r'^README($|\.)', caseSensitive: false);
diff --git a/lib/src/validator/strict_dependencies.dart b/lib/src/validator/strict_dependencies.dart
index 966e03e..36f6fc4 100644
--- a/lib/src/validator/strict_dependencies.dart
+++ b/lib/src/validator/strict_dependencies.dart
@@ -6,13 +6,13 @@
 
 import 'package:analyzer/dart/ast/ast.dart';
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
 import 'package:source_span/source_span.dart';
 import 'package:stack_trace/stack_trace.dart';
 
 import '../dart.dart';
 import '../io.dart';
 import '../log.dart' as log;
+import '../path.dart';
 import '../utils.dart';
 import '../validator.dart';
 
diff --git a/test/add/common/add_test.dart b/test/add/common/add_test.dart
index 18e9950..be0c2e8 100644
--- a/test/add/common/add_test.dart
+++ b/test/add/common/add_test.dart
@@ -8,8 +8,8 @@
 import 'dart:convert';
 import 'dart:io' show File;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_descriptor/test_descriptor.dart';
 import 'package:yaml/yaml.dart';
diff --git a/test/add/path/absolute_path_test.dart b/test/add/path/absolute_path_test.dart
index 478fc9e..db00dfe 100644
--- a/test/add/path/absolute_path_test.dart
+++ b/test/add/path/absolute_path_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/add/sdk/sdk_test.dart b/test/add/sdk/sdk_test.dart
index f8b5fd4..519dbe5 100644
--- a/test/add/sdk/sdk_test.dart
+++ b/test/add/sdk/sdk_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/cache/clean_test.dart b/test/cache/clean_test.dart
index 1828a86..98659c1 100644
--- a/test/cache/clean_test.dart
+++ b/test/cache/clean_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/cache/create_readme_test.dart b/test/cache/create_readme_test.dart
index a3ddf9b..5f0bbf9 100644
--- a/test/cache/create_readme_test.dart
+++ b/test/cache/create_readme_test.dart
@@ -3,7 +3,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/cache/detect_deprecated_dir_test.dart b/test/cache/detect_deprecated_dir_test.dart
index c82fadb..26b83d7 100644
--- a/test/cache/detect_deprecated_dir_test.dart
+++ b/test/cache/detect_deprecated_dir_test.dart
@@ -3,7 +3,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_descriptor/test_descriptor.dart';
 
diff --git a/test/cache/gc_test.dart b/test/cache/gc_test.dart
index f7bc2f5..e2db033 100644
--- a/test/cache/gc_test.dart
+++ b/test/cache/gc_test.dart
@@ -5,7 +5,7 @@
 import 'dart:io';
 
 import 'package:crypto/crypto.dart';
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:pub/src/system_cache.dart';
 import 'package:pub/src/utils.dart';
 import 'package:test/test.dart';
diff --git a/test/cache/list_test.dart b/test/cache/list_test.dart
index 962b4fc..567e932 100644
--- a/test/cache/list_test.dart
+++ b/test/cache/list_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/cache/preload_test.dart b/test/cache/preload_test.dart
index e041a9b..a0a4871 100644
--- a/test/cache/preload_test.dart
+++ b/test/cache/preload_test.dart
@@ -8,8 +8,8 @@
 import 'dart:io';
 
 import 'package:http/http.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/cache/repair/git_test.dart b/test/cache/repair/git_test.dart
index 7c91ffd..3df5336 100644
--- a/test/cache/repair/git_test.dart
+++ b/test/cache/repair/git_test.dart
@@ -5,9 +5,9 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/check_resolution_up_to_date_test.dart b/test/check_resolution_up_to_date_test.dart
index 62c7b21..316a11c 100644
--- a/test/check_resolution_up_to_date_test.dart
+++ b/test/check_resolution_up_to_date_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import 'descriptor.dart' as d;
diff --git a/test/content_hash_test.dart b/test/content_hash_test.dart
index e40c0b3..7ba6772 100644
--- a/test/content_hash_test.dart
+++ b/test/content_hash_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:yaml/yaml.dart';
 import 'package:yaml_edit/yaml_edit.dart';
diff --git a/test/dependency_override_test.dart b/test/dependency_override_test.dart
index f22be55..ebe0d80 100644
--- a/test/dependency_override_test.dart
+++ b/test/dependency_override_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 
 import 'package:test/test.dart';
 
diff --git a/test/dependency_services/dependency_services_test.dart b/test/dependency_services/dependency_services_test.dart
index 56277f5..e297070 100644
--- a/test/dependency_services/dependency_services_test.dart
+++ b/test/dependency_services/dependency_services_test.dart
@@ -8,8 +8,8 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub_semver/pub_semver.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:test/test.dart';
diff --git a/test/deps_test.dart b/test/deps_test.dart
index 702260c..3aff815 100644
--- a/test/deps_test.dart
+++ b/test/deps_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import 'descriptor.dart' as d;
diff --git a/test/descriptor.dart b/test/descriptor.dart
index 31d429a..8178b2d 100644
--- a/test/descriptor.dart
+++ b/test/descriptor.dart
@@ -7,10 +7,10 @@
 
 import 'dart:convert';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/language_version.dart';
 import 'package:pub/src/oauth2.dart';
 import 'package:pub/src/package_config.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/sdk/sdk_package_config.dart';
 import 'package:test_descriptor/test_descriptor.dart';
 
diff --git a/test/descriptor/git.dart b/test/descriptor/git.dart
index 0ceb72f..2206c76 100644
--- a/test/descriptor/git.dart
+++ b/test/descriptor/git.dart
@@ -4,8 +4,8 @@
 
 import 'dart:async';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/git.dart' as git;
+import 'package:pub/src/path.dart';
 import 'package:test_descriptor/test_descriptor.dart';
 
 /// Describes a Git repository and its contents.
diff --git a/test/descriptor/link_descriptor.dart b/test/descriptor/link_descriptor.dart
index 9f66aae..d1a37e1 100644
--- a/test/descriptor/link_descriptor.dart
+++ b/test/descriptor/link_descriptor.dart
@@ -4,7 +4,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/descriptor/package_config.dart b/test/descriptor/package_config.dart
index 8aad157..2ebb3c2 100644
--- a/test/descriptor/package_config.dart
+++ b/test/descriptor/package_config.dart
@@ -6,8 +6,8 @@
 import 'dart:convert' show JsonEncoder, json;
 import 'dart:io' show File;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/package_config.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub_semver/pub_semver.dart';
 import 'package:test/test.dart';
 import 'package:test_descriptor/test_descriptor.dart';
diff --git a/test/descriptor/tar.dart b/test/descriptor/tar.dart
index 76e92b8..eb5d298 100644
--- a/test/descriptor/tar.dart
+++ b/test/descriptor/tar.dart
@@ -5,9 +5,9 @@
 import 'dart:async';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
 import 'package:pub/src/log.dart' as log;
+import 'package:pub/src/path.dart';
 import 'package:test_descriptor/test_descriptor.dart';
 
 /// Describes a tar file and its contents.
diff --git a/test/descriptor/yaml.dart b/test/descriptor/yaml.dart
index 424b359..e2d25cf 100644
--- a/test/descriptor/yaml.dart
+++ b/test/descriptor/yaml.dart
@@ -7,7 +7,7 @@
 import 'dart:io';
 
 import 'package:collection/collection.dart';
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_descriptor/test_descriptor.dart';
 import 'package:yaml/yaml.dart';
diff --git a/test/directory_option_test.dart b/test/directory_option_test.dart
index f234932..6c03471 100644
--- a/test/directory_option_test.dart
+++ b/test/directory_option_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:convert';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:test/test.dart';
 
diff --git a/test/downgrade/dry_run_does_not_apply_changes_test.dart b/test/downgrade/dry_run_does_not_apply_changes_test.dart
index 4458257..81ded2b 100644
--- a/test/downgrade/dry_run_does_not_apply_changes_test.dart
+++ b/test/downgrade/dry_run_does_not_apply_changes_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/embedding/embedding_test.dart b/test/embedding/embedding_test.dart
index 0c56a37..c5657a3 100644
--- a/test/embedding/embedding_test.dart
+++ b/test/embedding/embedding_test.dart
@@ -7,9 +7,9 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart';
 import 'package:pub/src/io.dart' show EnvironmentKeys;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_process/test_process.dart';
 
diff --git a/test/embedding/ensure_pubspec_resolved.dart b/test/embedding/ensure_pubspec_resolved.dart
index ebc6599..4808368 100644
--- a/test/embedding/ensure_pubspec_resolved.dart
+++ b/test/embedding/ensure_pubspec_resolved.dart
@@ -9,8 +9,8 @@
 import 'dart:async';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/embedding/get_executable_for_command.dart b/test/embedding/get_executable_for_command.dart
index 4ed54de..7f00d4b 100644
--- a/test/embedding/get_executable_for_command.dart
+++ b/test/embedding/get_executable_for_command.dart
@@ -4,8 +4,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/pub.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/get/enforce_lockfile_test.dart b/test/get/enforce_lockfile_test.dart
index 5e9b9a0..61a5365 100644
--- a/test/get/enforce_lockfile_test.dart
+++ b/test/get/enforce_lockfile_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart';
diff --git a/test/get/get_inside_cache_fails_test.dart b/test/get/get_inside_cache_fails_test.dart
index 2a8d4ad..bed1b73 100644
--- a/test/get/get_inside_cache_fails_test.dart
+++ b/test/get/get_inside_cache_fails_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/get/gets_in_example_folder_test.dart b/test/get/gets_in_example_folder_test.dart
index ad87b8c..4b9acde 100644
--- a/test/get/gets_in_example_folder_test.dart
+++ b/test/get/gets_in_example_folder_test.dart
@@ -7,9 +7,9 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/get/git/check_out_test.dart b/test/get/git/check_out_test.dart
index 85e22e9..a12274d 100644
--- a/test/get/git/check_out_test.dart
+++ b/test/get/git/check_out_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:shelf/shelf_io.dart' as shelf_io;
 import 'package:test/test.dart';
diff --git a/test/get/git/check_out_transitive_test.dart b/test/get/git/check_out_transitive_test.dart
index 1ddc22e..fa6aa00 100644
--- a/test/get/git/check_out_transitive_test.dart
+++ b/test/get/git/check_out_transitive_test.dart
@@ -7,9 +7,9 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:yaml/yaml.dart';
 
diff --git a/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart b/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
index 949b257..1973131 100644
--- a/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
+++ b/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/git/clean_invalid_git_repo_cache_test.dart b/test/get/git/clean_invalid_git_repo_cache_test.dart
index 42c49a6..7a9f316 100644
--- a/test/get/git/clean_invalid_git_repo_cache_test.dart
+++ b/test/get/git/clean_invalid_git_repo_cache_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/git/doesnt_fetch_if_nothing_changes_test.dart b/test/get/git/doesnt_fetch_if_nothing_changes_test.dart
index 8b0cefb..feebcfd 100644
--- a/test/get/git/doesnt_fetch_if_nothing_changes_test.dart
+++ b/test/get/git/doesnt_fetch_if_nothing_changes_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/git/lfs_test.dart b/test/get/git/lfs_test.dart
index 3863dea..bcb5096 100644
--- a/test/get/git/lfs_test.dart
+++ b/test/get/git/lfs_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/git/lock_version_test.dart b/test/get/git/lock_version_test.dart
index e22eef7..39c0088 100644
--- a/test/get/git/lock_version_test.dart
+++ b/test/get/git/lock_version_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/git/locked_revision_without_repo_test.dart b/test/get/git/locked_revision_without_repo_test.dart
index 53b287f..bb9199d 100644
--- a/test/get/git/locked_revision_without_repo_test.dart
+++ b/test/get/git/locked_revision_without_repo_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/git/path_test.dart b/test/get/git/path_test.dart
index 55640dc..4d14dc2 100644
--- a/test/get/git/path_test.dart
+++ b/test/get/git/path_test.dart
@@ -5,10 +5,10 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/io.dart';
 import 'package:pub/src/lock_file.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/source/git.dart';
 import 'package:pub/src/system_cache.dart';
 import 'package:test/test.dart';
diff --git a/test/get/git/tag_pattern_test.dart b/test/get/git/tag_pattern_test.dart
index 665219a..caa8e6b 100644
--- a/test/get/git/tag_pattern_test.dart
+++ b/test/get/git/tag_pattern_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:yaml/yaml.dart';
 
diff --git a/test/get/hosted/advisory_test.dart b/test/get/hosted/advisory_test.dart
index 50c2ef0..e184c90 100644
--- a/test/get/hosted/advisory_test.dart
+++ b/test/get/hosted/advisory_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart';
 import 'package:test/test.dart';
 
diff --git a/test/get/hosted/get_test.dart b/test/get/hosted/get_test.dart
index ee1ad31..899257d 100644
--- a/test/get/hosted/get_test.dart
+++ b/test/get/hosted/get_test.dart
@@ -5,10 +5,10 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/exit_codes.dart';
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart';
 import 'package:test/test.dart';
 import 'package:yaml/yaml.dart';
diff --git a/test/get/hosted/resolve_with_retracted_package_versions_test.dart b/test/get/hosted/resolve_with_retracted_package_versions_test.dart
index 5dc72a8..5a2fe02 100644
--- a/test/get/hosted/resolve_with_retracted_package_versions_test.dart
+++ b/test/get/hosted/resolve_with_retracted_package_versions_test.dart
@@ -5,9 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
-
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/hosted/stay_locked_test.dart b/test/get/hosted/stay_locked_test.dart
index efaaa87..a376947 100644
--- a/test/get/hosted/stay_locked_test.dart
+++ b/test/get/hosted/stay_locked_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/hosted/unlock_if_version_doesnt_exist_test.dart b/test/get/hosted/unlock_if_version_doesnt_exist_test.dart
index bd53c0a..2a43524 100644
--- a/test/get/hosted/unlock_if_version_doesnt_exist_test.dart
+++ b/test/get/hosted/unlock_if_version_doesnt_exist_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/hosted/warn_about_discontinued_test.dart b/test/get/hosted/warn_about_discontinued_test.dart
index 9794ab5..d25ad28 100644
--- a/test/get/hosted/warn_about_discontinued_test.dart
+++ b/test/get/hosted/warn_about_discontinued_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:convert';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:test/test.dart';
 
diff --git a/test/get/hosted/warn_about_retracted_package_test.dart b/test/get/hosted/warn_about_retracted_package_test.dart
index 03ad5c1..ea02392 100644
--- a/test/get/hosted/warn_about_retracted_package_test.dart
+++ b/test/get/hosted/warn_about_retracted_package_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/path/absolute_path_test.dart b/test/get/path/absolute_path_test.dart
index d8ea431..9549b84 100644
--- a/test/get/path/absolute_path_test.dart
+++ b/test/get/path/absolute_path_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/path/absolute_symlink_test.dart b/test/get/path/absolute_symlink_test.dart
index 0c2ae25..8ca8ae7 100644
--- a/test/get/path/absolute_symlink_test.dart
+++ b/test/get/path/absolute_symlink_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/path/empty_pubspec_test.dart b/test/get/path/empty_pubspec_test.dart
index 6ba5e34..81944d6 100644
--- a/test/get/path/empty_pubspec_test.dart
+++ b/test/get/path/empty_pubspec_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/path/no_pubspec_test.dart b/test/get/path/no_pubspec_test.dart
index b8c8be8..20185e9 100644
--- a/test/get/path/no_pubspec_test.dart
+++ b/test/get/path/no_pubspec_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/path/nonexistent_dir_test.dart b/test/get/path/nonexistent_dir_test.dart
index 768b6c7..1957412 100644
--- a/test/get/path/nonexistent_dir_test.dart
+++ b/test/get/path/nonexistent_dir_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/path/path_is_file_test.dart b/test/get/path/path_is_file_test.dart
index 862768c..da76157 100644
--- a/test/get/path/path_is_file_test.dart
+++ b/test/get/path/path_is_file_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/path/relative_path_test.dart b/test/get/path/relative_path_test.dart
index 92e498e..03768a0 100644
--- a/test/get/path/relative_path_test.dart
+++ b/test/get/path/relative_path_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/lock_file.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/source/path.dart';
 import 'package:pub/src/system_cache.dart';
 import 'package:test/test.dart';
diff --git a/test/get/path/relative_symlink_test.dart b/test/get/path/relative_symlink_test.dart
index 736943d..31419ab 100644
--- a/test/get/path/relative_symlink_test.dart
+++ b/test/get/path/relative_symlink_test.dart
@@ -9,7 +9,7 @@
 @TestOn('vm && !windows')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/get/path/shared_dependency_symlink_test.dart b/test/get/path/shared_dependency_symlink_test.dart
index 780af20..fa758a9 100644
--- a/test/get/path/shared_dependency_symlink_test.dart
+++ b/test/get/path/shared_dependency_symlink_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 
 import 'package:test/test.dart';
 
diff --git a/test/get/preserve_lock_file_line_endings_test.dart b/test/get/preserve_lock_file_line_endings_test.dart
index c8abf7a..eabb907 100644
--- a/test/get/preserve_lock_file_line_endings_test.dart
+++ b/test/get/preserve_lock_file_line_endings_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/lock_file.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/global/activate/activate_casing_test.dart b/test/global/activate/activate_casing_test.dart
index 611cb57..96b4713 100644
--- a/test/global/activate/activate_casing_test.dart
+++ b/test/global/activate/activate_casing_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/activate/activate_hosted_after_path_test.dart b/test/global/activate/activate_hosted_after_path_test.dart
index bb66746..04a730d 100644
--- a/test/global/activate/activate_hosted_after_path_test.dart
+++ b/test/global/activate/activate_hosted_after_path_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/activate/activate_package_from_workspace.dart b/test/global/activate/activate_package_from_workspace.dart
index 3ce988a..2628b8c 100644
--- a/test/global/activate/activate_package_from_workspace.dart
+++ b/test/global/activate/activate_package_from_workspace.dart
@@ -2,7 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_process/test_process.dart';
 
diff --git a/test/global/activate/activate_package_with_hooks_test.dart b/test/global/activate/activate_package_with_hooks_test.dart
index ea3d220..70077f6 100644
--- a/test/global/activate/activate_package_with_hooks_test.dart
+++ b/test/global/activate/activate_package_with_hooks_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart';
diff --git a/test/global/activate/activate_path_after_hosted_test.dart b/test/global/activate/activate_path_after_hosted_test.dart
index 18222a4..fb4e058 100644
--- a/test/global/activate/activate_path_after_hosted_test.dart
+++ b/test/global/activate/activate_path_after_hosted_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/activate/fails_when_active_package_is_corrupt_test.dart b/test/global/activate/fails_when_active_package_is_corrupt_test.dart
index 990f994..41ba2be 100644
--- a/test/global/activate/fails_when_active_package_is_corrupt_test.dart
+++ b/test/global/activate/fails_when_active_package_is_corrupt_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/activate/git_package_test.dart b/test/global/activate/git_package_test.dart
index 4b79f40..07b3f82 100644
--- a/test/global/activate/git_package_test.dart
+++ b/test/global/activate/git_package_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/activate/path_package_test.dart b/test/global/activate/path_package_test.dart
index d6d8943..412bc68 100644
--- a/test/global/activate/path_package_test.dart
+++ b/test/global/activate/path_package_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_process/test_process.dart';
 
diff --git a/test/global/binstubs/binstub_runs_executable_test.dart b/test/global/binstubs/binstub_runs_executable_test.dart
index b750d86..1728c53 100644
--- a/test/global/binstubs/binstub_runs_executable_test.dart
+++ b/test/global/binstubs/binstub_runs_executable_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_process/test_process.dart';
 
diff --git a/test/global/binstubs/binstub_runs_global_run_if_no_snapshot_test.dart b/test/global/binstubs/binstub_runs_global_run_if_no_snapshot_test.dart
index ceda785..8a400ee 100644
--- a/test/global/binstubs/binstub_runs_global_run_if_no_snapshot_test.dart
+++ b/test/global/binstubs/binstub_runs_global_run_if_no_snapshot_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/binstubs/does_not_warn_if_on_path_test.dart b/test/global/binstubs/does_not_warn_if_on_path_test.dart
index 91ec596..ff4c139 100644
--- a/test/global/binstubs/does_not_warn_if_on_path_test.dart
+++ b/test/global/binstubs/does_not_warn_if_on_path_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/binstubs/missing_script_test.dart b/test/global/binstubs/missing_script_test.dart
index 99ccc9d..4442e9a 100644
--- a/test/global/binstubs/missing_script_test.dart
+++ b/test/global/binstubs/missing_script_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/binstubs/outdated_binstub_runs_pub_global_test.dart b/test/global/binstubs/outdated_binstub_runs_pub_global_test.dart
index e0673dc..43693bd 100644
--- a/test/global/binstubs/outdated_binstub_runs_pub_global_test.dart
+++ b/test/global/binstubs/outdated_binstub_runs_pub_global_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_process/test_process.dart';
 
diff --git a/test/global/binstubs/outdated_snapshot_test.dart b/test/global/binstubs/outdated_snapshot_test.dart
index fa42d14..9324934 100644
--- a/test/global/binstubs/outdated_snapshot_test.dart
+++ b/test/global/binstubs/outdated_snapshot_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_process/test_process.dart';
 
diff --git a/test/global/binstubs/runs_once_even_when_dart_is_batch_test.dart b/test/global/binstubs/runs_once_even_when_dart_is_batch_test.dart
index 7104335..aa1368c 100644
--- a/test/global/binstubs/runs_once_even_when_dart_is_batch_test.dart
+++ b/test/global/binstubs/runs_once_even_when_dart_is_batch_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/binstubs/utils.dart b/test/global/binstubs/utils.dart
index bbd44a7..26d471c 100644
--- a/test/global/binstubs/utils.dart
+++ b/test/global/binstubs/utils.dart
@@ -4,7 +4,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 
 import '../../test_pub.dart';
 
diff --git a/test/global/deactivate/path_package_test.dart b/test/global/deactivate/path_package_test.dart
index 6a10fba..6b0dfe3 100644
--- a/test/global/deactivate/path_package_test.dart
+++ b/test/global/deactivate/path_package_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/list_test.dart b/test/global/list_test.dart
index 9326daf..97ab699 100644
--- a/test/global/list_test.dart
+++ b/test/global/list_test.dart
@@ -5,9 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
-
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/global/run/missing_path_package_test.dart b/test/global/run/missing_path_package_test.dart
index b5d9a15..49de8aa 100644
--- a/test/global/run/missing_path_package_test.dart
+++ b/test/global/run/missing_path_package_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/run/nonexistent_script_test.dart b/test/global/run/nonexistent_script_test.dart
index bdc803d..5eede61 100644
--- a/test/global/run/nonexistent_script_test.dart
+++ b/test/global/run/nonexistent_script_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../test_pub.dart';
diff --git a/test/global/run/package_api_test.dart b/test/global/run/package_api_test.dart
index 12c2d3b..a5fa706 100644
--- a/test/global/run/package_api_test.dart
+++ b/test/global/run/package_api_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart b/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart
index 3b8957f..ab41752 100644
--- a/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart
+++ b/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart
@@ -7,9 +7,9 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart';
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/sdk/sdk_package_config.dart';
 import 'package:test/test.dart';
 
diff --git a/test/global/run/runs_path_script_test.dart b/test/global/run/runs_path_script_test.dart
index 6b86bc4..0e207c5 100644
--- a/test/global/run/runs_path_script_test.dart
+++ b/test/global/run/runs_path_script_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/golden_file.dart b/test/golden_file.dart
index b04e23b..168eac2 100644
--- a/test/golden_file.dart
+++ b/test/golden_file.dart
@@ -8,9 +8,9 @@
 import 'dart:async';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/ascii_tree.dart' as ascii_tree;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:stack_trace/stack_trace.dart' show Trace;
 import 'package:test/test.dart';
 
diff --git a/test/hosted/short_syntax_test.dart b/test/hosted/short_syntax_test.dart
index 014f46b..55a5cb4 100644
--- a/test/hosted/short_syntax_test.dart
+++ b/test/hosted/short_syntax_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:yaml/yaml.dart';
 
diff --git a/test/io_test.dart b/test/io_test.dart
index e78cfcf..220e95e 100644
--- a/test/io_test.dart
+++ b/test/io_test.dart
@@ -9,9 +9,9 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exceptions.dart';
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:tar/tar.dart';
 import 'package:test/test.dart';
 
diff --git a/test/lish/archive_contents_test.dart b/test/lish/archive_contents_test.dart
index a36abbc..8f60d14 100644
--- a/test/lish/archive_contents_test.dart
+++ b/test/lish/archive_contents_test.dart
@@ -8,8 +8,8 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:tar/tar.dart';
 import 'package:test/test.dart';
diff --git a/test/lish/archives_and_uploads_a_package_test.dart b/test/lish/archives_and_uploads_a_package_test.dart
index cac55c5..e492a23 100644
--- a/test/lish/archives_and_uploads_a_package_test.dart
+++ b/test/lish/archives_and_uploads_a_package_test.dart
@@ -7,9 +7,9 @@
 
 import 'dart:convert';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:test/test.dart';
 
diff --git a/test/lish/force_does_not_publish_if_there_are_errors_test.dart b/test/lish/force_does_not_publish_if_there_are_errors_test.dart
index e5e4eda..abbd470 100644
--- a/test/lish/force_does_not_publish_if_there_are_errors_test.dart
+++ b/test/lish/force_does_not_publish_if_there_are_errors_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/lish/many_files_test.dart b/test/lish/many_files_test.dart
index a2cd187..068f0cc 100644
--- a/test/lish/many_files_test.dart
+++ b/test/lish/many_files_test.dart
@@ -8,8 +8,8 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:test/test.dart';
 
diff --git a/test/lish/package_validation_has_a_warning_and_continues_test.dart b/test/lish/package_validation_has_a_warning_and_continues_test.dart
index 0842597..469877a 100644
--- a/test/lish/package_validation_has_a_warning_and_continues_test.dart
+++ b/test/lish/package_validation_has_a_warning_and_continues_test.dart
@@ -8,8 +8,8 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:test/test.dart';
 
diff --git a/test/lish/publishing_to_and_from_archive_test.dart b/test/lish/publishing_to_and_from_archive_test.dart
index 9cb1d56..85cd6d5 100644
--- a/test/lish/publishing_to_and_from_archive_test.dart
+++ b/test/lish/publishing_to_and_from_archive_test.dart
@@ -8,8 +8,8 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart';
 import 'package:test/test.dart';
 
diff --git a/test/lish/skip_validation_test.dart b/test/lish/skip_validation_test.dart
index e22d2a5..3bd0bba 100644
--- a/test/lish/skip_validation_test.dart
+++ b/test/lish/skip_validation_test.dart
@@ -8,8 +8,8 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:test/test.dart';
 
diff --git a/test/lish/symlinks_test.dart b/test/lish/symlinks_test.dart
index c38640b..16e83f4 100644
--- a/test/lish/symlinks_test.dart
+++ b/test/lish/symlinks_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:tar/tar.dart';
 import 'package:test/test.dart';
 
diff --git a/test/package_config_file_test.dart b/test/package_config_file_test.dart
index b28bfd6..0604578 100644
--- a/test/package_config_file_test.dart
+++ b/test/package_config_file_test.dart
@@ -8,9 +8,9 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/package_config.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 import 'package:test_descriptor/test_descriptor.dart';
 
diff --git a/test/package_graph_file_test.dart b/test/package_graph_file_test.dart
index f065e6c..06d5c1d 100644
--- a/test/package_graph_file_test.dart
+++ b/test/package_graph_file_test.dart
@@ -8,7 +8,7 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import 'descriptor.dart' as d;
diff --git a/test/package_graph_test.dart b/test/package_graph_test.dart
index 9927087..67d8a72 100644
--- a/test/package_graph_test.dart
+++ b/test/package_graph_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/entrypoint.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/system_cache.dart';
 import 'package:test/test.dart';
 
diff --git a/test/package_list_files_test.dart b/test/package_list_files_test.dart
index 94075db..2692c12 100644
--- a/test/package_list_files_test.dart
+++ b/test/package_list_files_test.dart
@@ -7,9 +7,9 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/entrypoint.dart';
 import 'package:pub/src/exceptions.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/system_cache.dart';
 import 'package:test/test.dart';
 
diff --git a/test/package_server.dart b/test/package_server.dart
index 429ea74..c9d57ef 100644
--- a/test/package_server.dart
+++ b/test/package_server.dart
@@ -8,15 +8,15 @@
 import 'dart:typed_data';
 
 import 'package:crypto/crypto.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub/src/crc32c.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/source/hosted.dart';
 import 'package:pub/src/utils.dart' show hexEncode;
 import 'package:pub_semver/pub_semver.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:shelf/shelf_io.dart' as shelf_io;
-import 'package:test/test.dart';
 import 'package:test/test.dart' as test show expect;
+import 'package:test/test.dart';
 
 import 'descriptor.dart' as d;
 import 'test_pub.dart';
diff --git a/test/path_test.dart b/test/path_test.dart
new file mode 100644
index 0000000..40c9099
--- /dev/null
+++ b/test/path_test.dart
@@ -0,0 +1,91 @@
+// Copyright (c) 2026, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+@TestOn('vm')
+library;
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/analysis/utilities.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:path/path.dart' as path;
+import 'package:pub/src/path.dart';
+import 'package:test/test.dart';
+
+void main() {
+  test('withPathContext overrides p', () async {
+    final customContext = path.Context(
+      style: path.Style.posix,
+      current: '/custom',
+    );
+
+    expect(p.current, isNot('/custom'));
+
+    await withPathContext(() {
+      expect(p.current, '/custom');
+      expect(p.style, path.Style.posix);
+      return Future<void>.value();
+    }, pathContext: customContext);
+
+    expect(p.current, isNot('/custom'));
+  });
+
+  test('withPathContext works with nested zones', () async {
+    final context1 = path.Context(style: path.Style.posix, current: '/1');
+    final context2 = path.Context(style: path.Style.posix, current: '/2');
+
+    await withPathContext(() async {
+      expect(p.current, '/1');
+      await withPathContext(() async {
+        expect(p.current, '/2');
+      }, pathContext: context2);
+      expect(p.current, '/1');
+    }, pathContext: context1);
+  });
+
+  test('package:path/path.dart is only imported in lib/src/path.dart', () {
+    final libDir = Directory('lib');
+    final dartFiles = libDir
+        .listSync(recursive: true)
+        .whereType<File>()
+        .where((file) => file.path.endsWith('.dart'));
+
+    final offendingFiles = <String>[];
+
+    for (final file in dartFiles) {
+      if (p.basename(file.path) == 'path.dart' &&
+          p.dirname(file.path).endsWith(p.join('lib', 'src'))) {
+        continue;
+      }
+
+      final result = parseString(
+        content: file.readAsStringSync(),
+        featureSet: FeatureSet.latestLanguageVersion(),
+      );
+
+      final hasPathImport = result.unit.directives
+          .whereType<ImportDirective>()
+          .any(
+            (directive) =>
+                directive.uri.stringValue == 'package:path/path.dart',
+          );
+
+      if (hasPathImport) {
+        offendingFiles.add(file.path);
+      }
+    }
+
+    expect(
+      offendingFiles,
+      isEmpty,
+      reason:
+          'Files in lib/ should use the custom path context p from '
+          'lib/src/path.dart instead of directly importing '
+          'package:path/path.dart. This ensures that the path context can be '
+          'overridden for testing using withPathContext.',
+    );
+  });
+}
diff --git a/test/pinned_dependency_hint_test.dart b/test/pinned_dependency_hint_test.dart
index 24ad6d8..35a292d 100644
--- a/test/pinned_dependency_hint_test.dart
+++ b/test/pinned_dependency_hint_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import 'descriptor.dart' as d;
diff --git a/test/pubspec_overrides_test.dart b/test/pubspec_overrides_test.dart
index d52aef0..183eff5 100644
--- a/test/pubspec_overrides_test.dart
+++ b/test/pubspec_overrides_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import 'descriptor.dart' as d;
diff --git a/test/remove/remove_test.dart b/test/remove/remove_test.dart
index 745609a..c2f364e 100644
--- a/test/remove/remove_test.dart
+++ b/test/remove/remove_test.dart
@@ -7,7 +7,7 @@
 
 import 'dart:io' show File;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/run/includes_parent_directories_of_entrypoint_test.dart b/test/run/includes_parent_directories_of_entrypoint_test.dart
index 5517e4c..b6a479d 100644
--- a/test/run/includes_parent_directories_of_entrypoint_test.dart
+++ b/test/run/includes_parent_directories_of_entrypoint_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/run/nonexistent_script_in_dependency_test.dart b/test/run/nonexistent_script_in_dependency_test.dart
index 4cc4f98..e4545f4 100644
--- a/test/run/nonexistent_script_in_dependency_test.dart
+++ b/test/run/nonexistent_script_in_dependency_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/run/nonexistent_script_test.dart b/test/run/nonexistent_script_test.dart
index 6da99df..f7604ce 100644
--- a/test/run/nonexistent_script_test.dart
+++ b/test/run/nonexistent_script_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/run/package_api_test.dart b/test/run/package_api_test.dart
index faa816e..2f56415 100644
--- a/test/run/package_api_test.dart
+++ b/test/run/package_api_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/run/runs_app_in_directory_in_entrypoint_test.dart b/test/run/runs_app_in_directory_in_entrypoint_test.dart
index 0c01e4d..572c2f1 100644
--- a/test/run/runs_app_in_directory_in_entrypoint_test.dart
+++ b/test/run/runs_app_in_directory_in_entrypoint_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/sdk_test.dart b/test/sdk_test.dart
index f6177dd..fe9f9c4 100644
--- a/test/sdk_test.dart
+++ b/test/sdk_test.dart
@@ -5,9 +5,9 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/sdk/sdk_package_config.dart';
 import 'package:test/test.dart';
 
diff --git a/test/snapshot_test.dart b/test/snapshot_test.dart
index fd55c31..cf119ce 100644
--- a/test/snapshot_test.dart
+++ b/test/snapshot_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import 'descriptor.dart' as d;
diff --git a/test/test_pub.dart b/test/test_pub.dart
index cca6ece..7698901 100644
--- a/test/test_pub.dart
+++ b/test/test_pub.dart
@@ -18,7 +18,6 @@
 
 import 'package:async/async.dart';
 import 'package:http/testing.dart';
-import 'package:path/path.dart' as p;
 import 'package:pub/src/entrypoint.dart';
 import 'package:pub/src/exit_codes.dart' as exit_codes;
 import 'package:pub/src/git.dart' as git;
@@ -27,14 +26,15 @@
 import 'package:pub/src/lock_file.dart';
 import 'package:pub/src/log.dart' as log;
 import 'package:pub/src/package_name.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/source/hosted.dart';
 import 'package:pub/src/system_cache.dart';
 import 'package:pub/src/utils.dart';
 import 'package:pub/src/validator.dart';
 import 'package:pub_semver/pub_semver.dart';
 import 'package:tar/tar.dart';
-import 'package:test/test.dart' hide fail;
 import 'package:test/test.dart' as test show fail;
+import 'package:test/test.dart' hide fail;
 import 'package:test_process/test_process.dart';
 
 import 'descriptor.dart' as d;
diff --git a/test/unpack_test.dart b/test/unpack_test.dart
index 787fcaa..83ba8e4 100644
--- a/test/unpack_test.dart
+++ b/test/unpack_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import 'descriptor.dart' as d;
diff --git a/test/upgrade/dry_run_does_not_apply_changes_test.dart b/test/upgrade/dry_run_does_not_apply_changes_test.dart
index 93cfb13..0f16938 100644
--- a/test/upgrade/dry_run_does_not_apply_changes_test.dart
+++ b/test/upgrade/dry_run_does_not_apply_changes_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/upgrade/git/do_not_upgrade_if_unneeded_test.dart b/test/upgrade/git/do_not_upgrade_if_unneeded_test.dart
index ae0dc8b..f29ec41 100644
--- a/test/upgrade/git/do_not_upgrade_if_unneeded_test.dart
+++ b/test/upgrade/git/do_not_upgrade_if_unneeded_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../../descriptor.dart' as d;
diff --git a/test/validator/dependency_override_test.dart b/test/validator/dependency_override_test.dart
index f52cffb..b8dc7f8 100644
--- a/test/validator/dependency_override_test.dart
+++ b/test/validator/dependency_override_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/validator/dependency_test.dart b/test/validator/dependency_test.dart
index f4dd1fe..b842d28 100644
--- a/test/validator/dependency_test.dart
+++ b/test/validator/dependency_test.dart
@@ -8,9 +8,8 @@
 import 'dart:async';
 import 'dart:convert';
 
-import 'package:path/path.dart' as p;
-
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/validator/git_status_test.dart b/test/validator/git_status_test.dart
index 7d1db4c..7bfe654 100644
--- a/test/validator/git_status_test.dart
+++ b/test/validator/git_status_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/validator/gitignore_test.dart b/test/validator/gitignore_test.dart
index ce42313..5a8e4bf 100644
--- a/test/validator/gitignore_test.dart
+++ b/test/validator/gitignore_test.dart
@@ -7,8 +7,8 @@
 
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart' as exit_codes;
+import 'package:pub/src/path.dart';
 import 'package:test/test.dart';
 
 import '../descriptor.dart' as d;
diff --git a/test/validator/license_test.dart b/test/validator/license_test.dart
index 7f1655e..ac45fc9 100644
--- a/test/validator/license_test.dart
+++ b/test/validator/license_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/validator.dart';
 import 'package:pub/src/validator/license.dart';
 import 'package:test/test.dart';
diff --git a/test/validator/name_test.dart b/test/validator/name_test.dart
index 32f469a..2567a09 100644
--- a/test/validator/name_test.dart
+++ b/test/validator/name_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/validator.dart';
 import 'package:pub/src/validator/name.dart';
 import 'package:test/test.dart';
diff --git a/test/validator/readme_test.dart b/test/validator/readme_test.dart
index 0e5b24d..85d3b13 100644
--- a/test/validator/readme_test.dart
+++ b/test/validator/readme_test.dart
@@ -5,8 +5,8 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/io.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/validator.dart';
 import 'package:pub/src/validator/readme.dart';
 import 'package:test/test.dart';
diff --git a/test/validator/strict_dependencies_test.dart b/test/validator/strict_dependencies_test.dart
index 733a5e9..8504fc9 100644
--- a/test/validator/strict_dependencies_test.dart
+++ b/test/validator/strict_dependencies_test.dart
@@ -5,7 +5,7 @@
 @TestOn('vm')
 library;
 
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:pub/src/validator.dart';
 import 'package:pub/src/validator/strict_dependencies.dart';
 import 'package:test/test.dart';
diff --git a/test/version_solver_test.dart b/test/version_solver_test.dart
index 4bf6de8..52e321e 100644
--- a/test/version_solver_test.dart
+++ b/test/version_solver_test.dart
@@ -8,8 +8,8 @@
 import 'dart:async';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/lock_file.dart';
+import 'package:pub/src/path.dart';
 import 'package:pub/src/pubspec.dart';
 import 'package:pub/src/source/hosted.dart';
 import 'package:pub/src/source/root.dart';
diff --git a/test/workspace_test.dart b/test/workspace_test.dart
index d13d9cb..4df7a91 100644
--- a/test/workspace_test.dart
+++ b/test/workspace_test.dart
@@ -8,8 +8,8 @@
 import 'dart:convert';
 import 'dart:io';
 
-import 'package:path/path.dart' as p;
 import 'package:pub/src/exit_codes.dart';
+import 'package:pub/src/path.dart';
 import 'package:shelf/shelf.dart' as shelf;
 import 'package:test/test.dart';
 import 'package:yaml/yaml.dart';
diff --git a/tool/create_version_tags_from_sdk.dart b/tool/create_version_tags_from_sdk.dart
index 3c67f33..d1d3a54 100644
--- a/tool/create_version_tags_from_sdk.dart
+++ b/tool/create_version_tags_from_sdk.dart
@@ -8,7 +8,7 @@
 import 'dart:io';
 
 import 'package:args/args.dart';
-import 'package:path/path.dart' as p;
+import 'package:pub/src/path.dart';
 import 'package:pub_semver/pub_semver.dart';
 
 Future<void> main(List<String> args) async {
diff --git a/tool/test.dart b/tool/test.dart
index 732c82a..f767263 100755
--- a/tool/test.dart
+++ b/tool/test.dart
@@ -13,10 +13,10 @@
 library;
 
 import 'dart:io';
-import 'package:path/path.dart' as p;
 
 import 'package:pub/src/dart.dart';
 import 'package:pub/src/exceptions.dart';
+import 'package:pub/src/path.dart';
 
 Future<void> main(List<String> args) async {
   if (Platform.environment['FLUTTER_ROOT'] != null) {