dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.05k stars 230 forks source link

Illegal scheme character when depending on git dependency #3497

Closed EstebanCardenas closed 2 years ago

EstebanCardenas commented 2 years ago

Illegal scheme character error thrown when including a git dependency in the pubspec.yaml file.

Pubspec.yaml file:

name: app
description: app.
publish_to: 'none'
version: 1.0.0+1

environment:
  sdk: ">=2.17.6 <3.0.0"

dependencies:
  authentication:
    git:
      url: git@gitlab.com:app/ifp/modules/authentication.git
      ref: main
  dashboard: 
    git:
      url: git@gitlab.com:app/ifp/modules/dashboard.git
      ref: main

Error:

flutter pub get
Running "flutter pub get" in app...                         
Illegal scheme character (at character 4)
git@gitlab.com:app/ifp/modules/dashboard.git

Stack trace:

dart:core                                           Uri.parse
package:path/src/context.dart 1077:33               _parseUri
package:path/src/context.dart 1052:22               Context.prettyUri
package:path/path.dart 461:34                       prettyUri
package:pub/src/source/git.dart 276:16              GitSource._describeUncached
===== asynchronous gap ===========================
package:pub/src/source/git.dart 224:11              GitSource.doGetVersions.<fn>
===== asynchronous gap ===========================
package:pool/pool.dart 127:14                       Pool.withResource
===== asynchronous gap ===========================
package:pub/src/source/git.dart 218:12              GitSource.doGetVersions
===== asynchronous gap ===========================
package:pub/src/system_cache.dart 186:20            SystemCache.getVersions
===== asynchronous gap ===========================
package:pub/src/solver/package_lister.dart 82:31    PackageLister._versions.<fn>
===== asynchronous gap ===========================
package:pub/src/solver/package_lister.dart 126:15   PackageLister.countVersions
===== asynchronous gap ===========================
package:pub/src/solver/version_solver.dart 336:14   VersionSolver._choosePackageVersion.<fn>
===== asynchronous gap ===========================
package:pub/src/utils.dart 281:26                   minByAsync
===== asynchronous gap ===========================
package:pub/src/solver/version_solver.dart 335:19   VersionSolver._choosePackageVersion
===== asynchronous gap ===========================
package:pub/src/solver/version_solver.dart 97:18    VersionSolver.solve.<fn>
===== asynchronous gap ===========================
package:pub/src/source/hosted.dart 954:14           HostedSource.withPrefetching.<fn>
===== asynchronous gap ===========================
package:pub/src/rate_limited_scheduler.dart 110:14  RateLimitedScheduler.withPrescheduling
===== asynchronous gap ===========================
package:pub/src/source/hosted.dart 953:12           HostedSource.withPrefetching
===== asynchronous gap ===========================
package:pub/src/solver/version_solver.dart 93:14    VersionSolver.solve
===== asynchronous gap ===========================
package:pub/src/entrypoint.dart 280:16              Entrypoint.acquireDependencies
===== asynchronous gap ===========================
package:pub/src/command/get.dart 52:5               GetCommand.runProtected
ujway commented 2 years ago

It would seem to be duplicated of https://github.com/dart-lang/pub/issues/3390

a1ssat commented 2 years ago

have same issue

[✓] Flutter (Channel stable, 3.0.5, on Linux 5.18.14-arch1-1, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
zmoshansky commented 2 years ago

Background: Same issue: Tried on both Flutter 3.0.4 & 3.0.5; Looks like https://github.com/dart-lang/pub/issues/3390. Trying to use the same mono_repo structure as https://github.com/dart-lang/build, but with a private repo.

Oddly, this did not recreate entirely consistently, at some points, git references seem to work? Perhaps worth mentioning that we also use globally installed package Melos, like (https://github.com/dart-lang/pub/issues/3520), The original bug had mentioned issues with dependency overrides, which we also use.....

Reproduction: I noticed the issue while using git ref's in a parent pubspec.yml's dependency_overrides: to a separate private git mono repo of internal packages. We see this error when running pub get in the parent app, and also when running it for packages in the mono repo that depend on sibling packages (by git reference to the mono repo).

ex.)

Parent - Repo - A
App -> lib_a, lib_b

Common - Mono Repo - B
lib_a -> git@common...., path: /lib_b
lib_b

Investigation:

https://github.com/dart-lang/pub/blob/bc32a30ea5c86653e2a1899613c0a19d91b9a21c/lib/src/source/git.dart#L127

  // Relative paths coming from pubspecs that are not on the local file
  // system aren't allowed. This can happen if a hosted or git dependency
  // has a git dependency.

This comment has me feeling like I've broken some invariant assumption; Having done exactly that. Can I not reference a repo by git url, that internally also references itself by git url? If so, how I do dependencies within a private git mono-repo?

[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-x64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] HTTP Host Availability