PopperJuan
PopperJuan

Reputation: 195

Pulling dependencies from an internal repository via pubspec.yaml

I'm in a corporate firewall which blocks me from pulling packages from pub.dev. However, I was given the option to use an internal repository where I can pull the packages from as tar.gz files.

However, after reading https://dart.dev/tools/pub/dependencies#hosted-packages, I attempted to add this to mypubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter

  http:
    hosted:
      name: http
      url: http://repository.internal-repo.com/repository/googleapis-storage/packages/
    version: ^0.12.0+4

If I were to hit the link directly via Chrome (this url is in an internal network) http://repository.internal-repo.com/repository/googleapis-storage/packages/http-0.12.0+4.tar.gz the package downloads as a tar.gz file

But when I run a pub get:

502 notresolvable trying to find package http-0.12.0+4.tar.gz at http://repository.internal-repo.com/repository/googleapis-storage/packages/.
pub get failed (server unavailable) -- attempting retry 1 in 1 second...

I see that you can pull from public Github directly however that is also blocked by our proxy.

Am I doing something wrong here or is this feature not available?

Upvotes: 2

Views: 477

Answers (1)

Richard Heap
Richard Heap

Reputation: 51722

The doc you link says:

or another HTTP server that speaks the same API

I.E. your internal server must implement the pub API. It seems that if you put

  http:
    hosted:
      name: http
      url: http://repository.internal-repo.com/foo/
    version: ^0.12.0+4

then pub make a request to http://repository.internal-repo.com/foo/api/packages/http It's not clear what it expects to find there.

You may want to unzip your tar file onto a shared drive somewhere and use the path syntax instead, for example (assuming you've unzipped into the http_12_0_4 folder of the pub share and mounted that):

  http:
    path: /Volumes/pub/http_12_0_4

No version is needed because you've hard-coded that into the folder name.

Upvotes: 1

Related Questions