Sdk: pub get failed on windows 10 linux subsystem

Created on 10 Oct 2016  路  24Comments  路  Source: dart-lang/sdk

I think this is an sdk bug, not a pub bug, because this issue seems to be that dart:io can't correctly handle the 'tar' process to unzip the package.

this happens on almost any project, there is a little chance that pub get works the second time you run it, once it works you will need to delete the .pub-cache folder to reproduce it again.
but the first time you run pub get it always fail

test case:

cd ~
curl -O -J -L https://storage.googleapis.com/dart-archive/channels/dev/release/latest/linux_packages/debian_wheezy/dart_1.20.0-dev.10.1-1_amd64.deb
sudo dpkg -i --force-all dart_1.20.0-dev.10.1-1_amd64.deb
git clone https://github.com/rinick/neural-style-server.git
cd neural-style-server
/usr/lib/dart/bin/pub get -v

output

FINE: Pub 1.20.0-dev.10.1
MSG : Resolving dependencies...
SLVR: Solving dependencies:
    | - http_server ^0.9.6 from hosted (http_server)
    | - browser ^0.10.0 from hosted (browser)
    | - mime ^0.9.3 from hosted (mime)
IO  : Get versions from https://pub.dartlang.org/api/packages/http_server.
FINE: HTTP GET https://pub.dartlang.org/api/packages/http_server
    | Accept: application/vnd.pub.v2+json
    | user-agent: Dart pub 1.20.0-dev.10.1
FINE: HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/http_server
    | took 0:00:00.299582
    | x-cloud-trace-context: b197fc040093d196e6c34148ce025598
    | date: Sun, 09 Oct 2016 21:59:52 GMT
    | content-length: 21511
    | content-type: application/json
    | x-frame-options: SAMEORIGIN
    | via: iwhj70:14102
    | x-xss-protection: 1; mode=block
    | x-content-type-options: nosniff
    | server: Google Frontend
IO  : Get versions from https://pub.dartlang.org/api/packages/browser.
FINE: HTTP GET https://pub.dartlang.org/api/packages/browser
    | Accept: application/vnd.pub.v2+json
    | user-agent: Dart pub 1.20.0-dev.10.1
FINE: HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/browser
    | took 0:00:00.094916
    | x-cloud-trace-context: 2eac255629e7b56b47385e6f56a8d307
    | date: Sun, 09 Oct 2016 21:59:52 GMT
    | content-length: 26414
    | content-type: application/json
    | x-frame-options: SAMEORIGIN
    | via: iwgq126:25897
    | x-xss-protection: 1; mode=block
    | x-content-type-options: nosniff
    | server: Google Frontend
IO  : Get versions from https://pub.dartlang.org/api/packages/mime.
FINE: HTTP GET https://pub.dartlang.org/api/packages/mime
    | Accept: application/vnd.pub.v2+json
    | user-agent: Dart pub 1.20.0-dev.10.1
FINE: HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/mime
    | took 0:00:00.094116
    | x-cloud-trace-context: 2cbb4867007ab65ce32cdcbc2c1c089f
    | date: Sun, 09 Oct 2016 21:59:52 GMT
    | content-length: 16325
    | content-type: application/json
    | x-frame-options: SAMEORIGIN
    | via: iwhj70:14102
    | x-xss-protection: 1; mode=block
    | x-content-type-options: nosniff
    | server: Google Frontend
SLVR: * start at root
IO  : Get versions from https://pub.dartlang.org/api/packages/path.
FINE: HTTP GET https://pub.dartlang.org/api/packages/path
    | Accept: application/vnd.pub.v2+json
    | user-agent: Dart pub 1.20.0-dev.10.1
FINE: HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/path
    | took 0:00:00.095160
    | x-cloud-trace-context: 3c2c955874d72b5c94d38002694b3c34
    | date: Sun, 09 Oct 2016 21:59:52 GMT
    | content-length: 28727
    | content-type: application/json
    | x-frame-options: SAMEORIGIN
    | via: iwhj70:14102
    | x-xss-protection: 1; mode=block
    | x-content-type-options: nosniff
    | server: Google Frontend
SLVR: | * select http_server 0.9.6 from hosted
SLVR: | | * select mime 0.9.3 from hosted
SLVR: | | | * select browser 0.10.0+2 from hosted
SLVR: | | | | * select path 1.3.9 from hosted
SLVR: BacktrackingSolver took 0:00:00.836775 seconds.
    | - Tried 1 solutions
    | - Requested 4 version lists
    | - Looked up 4 cached version lists
    |
FINE: Resolving dependencies finished (0.879s).
MSG : + browser 0.10.0+2
    | + http_server 0.9.6
    | + mime 0.9.3
    | + path 1.3.9
IO  : Get package from https://pub.dartlang.org/packages/http_server/versions/0.9.6.tar.gz.
MSG : Downloading http_server 0.9.6...
IO  : Created temp directory /home/rinick/.pub-cache/_temp/dirkTjOx6
IO  : Get package from https://pub.dartlang.org/packages/mime/versions/0.9.3.tar.gz.
MSG : Downloading mime 0.9.3...
IO  : Created temp directory /home/rinick/.pub-cache/_temp/dirnaHIvF
IO  : Get package from https://pub.dartlang.org/packages/browser/versions/0.10.0+2.tar.gz.
MSG : Downloading browser 0.10.0+2...
IO  : Created temp directory /home/rinick/.pub-cache/_temp/dirqY7ave
IO  : Get package from https://pub.dartlang.org/packages/path/versions/1.3.9.tar.gz.
MSG : Downloading path 1.3.9...
IO  : Created temp directory /home/rinick/.pub-cache/_temp/dir7lGjwN
FINE: HTTP GET https://pub.dartlang.org/packages/http_server/versions/0.9.6.tar.gz
    | user-agent: Dart pub 1.20.0-dev.10.1
FINE: HTTP GET https://pub.dartlang.org/packages/mime/versions/0.9.3.tar.gz
    | user-agent: Dart pub 1.20.0-dev.10.1
FINE: HTTP GET https://pub.dartlang.org/packages/browser/versions/0.10.0+2.tar.gz
    | user-agent: Dart pub 1.20.0-dev.10.1
FINE: HTTP GET https://pub.dartlang.org/packages/path/versions/1.3.9.tar.gz
    | user-agent: Dart pub 1.20.0-dev.10.1
FINE: HTTP response 200 OK for GET https://pub.dartlang.org/packages/http_server/versions/0.9.6.tar.gz
    | took 0:00:00.358045
    | x-goog-storage-class: STANDARD
    | cache-control: public, max-age=3600
    | last-modified: Thu, 18 Aug 2016 14:34:05 GMT
    | date: Sun, 09 Oct 2016 21:59:53 GMT
    | x-goog-stored-content-length: 40960
    | age: 0
    | x-guploader-uploadid: AEnB2UraiORQzpvFJsl_pe2-ogeuj7qoHmcHkeGBgrT0QDFF1Q8x3Cf23brcnTz1qDk9lR3YY03ziRJGWFZhKRv5tGq1tYTelQ
    | x-goog-hash: crc32c=kFfLUQ==,md5=65FKAUH/BGY69UWlByn0jQ==
    | content-type: application/octet-stream
    | x-goog-generation: 1471530846005000
    | server: UploadServer
    | alt-svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
    | accept-ranges: bytes
    | content-length: 40960
    | x-goog-stored-content-encoding: identity
    | etag: "eb914a0141ff04663af545a50729f48d"
    | x-goog-metageneration: 2
    | expires: Sun, 09 Oct 2016 22:59:53 GMT
FINE: Extracting .tar.gz stream to /home/rinick/.pub-cache/_temp/dirkTjOx6.
IO  : Spawning "tar --extract --gunzip --directory /home/rinick/.pub-cache/_temp/dirkTjOx6" in /home/rinick/neural-style-server/.
FINE: Extracted .tar.gz stream to /home/rinick/.pub-cache/_temp/dirkTjOx6. Exit code 0.
IO  : Renaming directory /home/rinick/.pub-cache/_temp/dirkTjOx6 to /home/rinick/.pub-cache/hosted/pub.dartlang.org/http_server-0.9.6.
FINE: HTTP response 200 OK for GET https://pub.dartlang.org/packages/mime/versions/0.9.3.tar.gz
    | took 0:00:00.603510
    | x-goog-storage-class: STANDARD
    | cache-control: public, max-age=3600
    | last-modified: Wed, 18 Feb 2015 14:46:26 GMT
    | date: Sun, 09 Oct 2016 21:59:53 GMT
    | x-goog-stored-content-length: 19964
    | age: 0
    | x-guploader-uploadid: AEnB2Up1O7j1xJ6gjPQgn2ZA6KbNVrgDSTZGL-A7S6vntB5SQHGY2EnSS3HQENeB0l1kTFu-r-rFHDNAOmKYZ70OXVVJv-lknbs5W2pX8Rb6me1nnTN6CLA
    | x-goog-hash: crc32c=60ND1w==,md5=a8VekHkk+GS5qd3CCge1/w==
    | content-type: application/octet-stream
    | x-goog-generation: 1424270786691000
    | server: UploadServer
    | alt-svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
    | accept-ranges: bytes
    | content-length: 19964
    | x-goog-stored-content-encoding: identity
    | etag: "6bc55e907924f864b9a9ddc20a07b5ff"
    | x-goog-metageneration: 1
    | expires: Sun, 09 Oct 2016 22:59:53 GMT
FINE: Extracting .tar.gz stream to /home/rinick/.pub-cache/_temp/dirnaHIvF.
IO  : Spawning "tar --extract --gunzip --directory /home/rinick/.pub-cache/_temp/dirnaHIvF" in /home/rinick/neural-style-server/.
FINE: HTTP response 200 OK for GET https://pub.dartlang.org/packages/browser/versions/0.10.0+2.tar.gz
    | took 0:00:00.676689
    | x-goog-storage-class: STANDARD
    | cache-control: public, max-age=3600
    | last-modified: Tue, 18 Mar 2014 21:39:30 GMT
    | date: Sun, 09 Oct 2016 21:59:53 GMT
    | x-goog-stored-content-length: 2509
    | age: 0
    | x-guploader-uploadid: AEnB2UrD4UuPGRhUn6nL9CKRg5V56KQOeeNq5Xt3P9ihTMEtbEbFOibBOSJNYn3v5xT4u4a9mAQWnQ-8pXgtfbQfniZzEZAABWyxmvQ_LNPzAHhPD2hH5Ns
    | x-goog-hash: crc32c=Ns3BBA==,md5=WMqnXgUp9ZUEKO90nyn6Cw==
    | content-type: application/octet-stream
    | x-goog-generation: 1395178770126000
    | server: UploadServer
    | alt-svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
    | accept-ranges: bytes
    | content-length: 2509
    | x-goog-stored-content-encoding: identity
    | etag: "58caa75e0529f5950428ef749f29fa0b"
    | x-goog-metageneration: 1
    | expires: Sun, 09 Oct 2016 22:59:53 GMT
FINE: Extracting .tar.gz stream to /home/rinick/.pub-cache/_temp/dirqY7ave.
IO  : Spawning "tar --extract --gunzip --directory /home/rinick/.pub-cache/_temp/dirqY7ave" in /home/rinick/neural-style-server/.
FINE: HTTP response 200 OK for GET https://pub.dartlang.org/packages/path/versions/1.3.9.tar.gz
    | took 0:00:00.757270
    | x-goog-storage-class: STANDARD
    | cache-control: public, max-age=3600
    | last-modified: Wed, 02 Dec 2015 22:10:35 GMT
    | date: Sun, 09 Oct 2016 21:59:53 GMT
    | x-goog-stored-content-length: 31869
    | age: 0
    | x-guploader-uploadid: AEnB2UpflG0Sz-SsDKqzmhrKgoKv79NKBAELG94AEJ_alxu57Fp50_YNnRNjVXHlCZTNftMkf40drNbryW_LTTnxIAyAI8ooF-xVyWb00URk5bDEd6EuyVs
    | x-goog-hash: crc32c=ftJ1Gw==,md5=TNfkxdJxfIcnFuTGvG8bvQ==
    | content-type: application/octet-stream
    | x-goog-generation: 1449094235281000
    | server: UploadServer
    | alt-svc: quic=":443"; ma=2592000; v="36,35,34,33,32"
    | accept-ranges: bytes
    | content-length: 31869
    | x-goog-stored-content-encoding: identity
    | etag: "4cd7e4c5d2717c872716e4c6bc6f1bbd"
    | x-goog-metageneration: 2
    | expires: Sun, 09 Oct 2016 22:59:53 GMT
FINE: Extracting .tar.gz stream to /home/rinick/.pub-cache/_temp/dir7lGjwN.
IO  : Spawning "tar --extract --gunzip --directory /home/rinick/.pub-cache/_temp/dir7lGjwN" in /home/rinick/neural-style-server/.
FINE: Extracted .tar.gz stream to /home/rinick/.pub-cache/_temp/dirqY7ave. Exit code 0.
IO  : Renaming directory /home/rinick/.pub-cache/_temp/dirqY7ave to /home/rinick/.pub-cache/hosted/pub.dartlang.org/browser-0.10.0+2.
FINE: Extracted .tar.gz stream to /home/rinick/.pub-cache/_temp/dirnaHIvF. Exit code 0.
IO  : Renaming directory /home/rinick/.pub-cache/_temp/dirnaHIvF to /home/rinick/.pub-cache/hosted/pub.dartlang.org/mime-0.9.3.
ERR : Connection closed while receiving data
FINE: Exception type: ClientException
FINE: package:http/src/io_client.dart 65                   IOClient.send.<async>.<fn>
    | ===== asynchronous gap ===========================
    | dart:async                                           StreamView.listen
    | package:pub/src/io.dart 663                          store
    | package:pub/src/io.dart 906                          extractTarGz.<async>
    | dart:async                                           _SyncCompleter.complete
    | package:pub/src/io.dart 717                          startProcess.<fn>.<async>
    | ===== asynchronous gap ===========================
    | dart:async                                           _asyncThenWrapperHelper
    | package:pub/src/io.dart                              extractTarGz
    | package:pub/src/source/hosted.dart 272               BoundHostedSource._download.<async>
    | dart:async                                           _SyncCompleter.complete
    | package:pub/src/http.dart 78                         _PubHttpClient.send.<async>
    | dart:async                                           _SyncCompleter.complete
    | package:http/src/io_client.dart 63                   IOClient.send.<async>
    | ===== asynchronous gap ===========================
    | dart:async                                           _asyncThenWrapperHelper
    | package:pub/src/source/hosted.dart                   BoundHostedSource._download
    | package:pub/src/source/hosted.dart 193               BoundHostedSource.downloadToSystemCache.<async>
    | ===== asynchronous gap ===========================
    | dart:async                                           Future.Future.microtask
    | package:pub/src/source/hosted.dart                   BoundHostedSource.downloadToSystemCache
    | package:pub/src/entrypoint.dart 451                  Entrypoint._get.<async>
    | ===== asynchronous gap ===========================
    | dart:async                                           Future.Future.microtask
    | package:pub/src/entrypoint.dart                      Entrypoint._get
    | package:pub/src/entrypoint.dart 204                  Entrypoint.acquireDependencies.<async>.<fn>
    | dart:async                                           Future.wait
    | package:pub/src/entrypoint.dart 203                  Entrypoint.acquireDependencies.<async>
    | dart:async                                           _SyncCompleter.complete
    | package:pub/src/solver/backtracking_solver.dart 182  BacktrackingSolver.solve.<async>
    | dart:async                                           _SyncCompleter.complete
    | package:pub/src/solver/backtracking_solver.dart 609  BacktrackingSolver._getPubspec.<async>
    | dart:async                                           _SyncCompleter.complete
    | package:pub/src/source.dart 202                      BoundSource.describe.<async>
    | ===== asynchronous gap ===========================
    | dart:async                                           _asyncThenWrapperHelper
    | package:pub/src/entrypoint.dart                      Entrypoint.acquireDependencies
    | package:pub/src/command/get.dart 35                  GetCommand.run
    | package:args/command_runner.dart 177                 CommandRunner.runCommand.<fn>
    | dart:async                                           Future.Future.sync
    | package:args/command_runner.dart 130                 CommandRunner.runCommand
    | package:pub/src/command_runner.dart 128              PubCommandRunner.runCommand.<async>.<fn>
    | dart:async                                           Future.Future.sync
    | package:pub/src/utils.dart 72                        captureErrors.<fn>
    | package:stack_trace                                  Chain.capture
    | package:pub/src/utils.dart 86                        captureErrors
    | package:pub/src/command_runner.dart 128              PubCommandRunner.runCommand.<async>
    | dart:async                                           _SyncCompleter.complete
    | package:pub/src/command_runner.dart 214              PubCommandRunner._validatePlatform.<async>
area-library library-io

Most helpful comment

I've just tried on WSL Ubuntu 18.04 with dart2. It seems that dart can be installed using the linux instructions (dart --version works fine), but simple commands such as

pub global activate stagehand

just hangs so basically nothing can be done.
Supporting running io tests on WSL to easily test linux compatibility from windows would be great.

All 24 comments

@rinick - if you have a tiny script that imports dart:io and spawns tar, do you get a similar error?

Probably related to #27555.

now windows linux subystem version is Ubuntu 16.04.1 LTS , the issue is still there

Same here!

I'm getting the same or related error on WSL. The tail of the log is

IO  : HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/path
    | took 0:00:00.341472
    | transfer-encoding: chunked
    | date: Thu, 16 Aug 2018 06:51:45 GMT
    | content-encoding: gzip
    | vary: Accept-Encoding
    | via: 1.1 google
    | content-type: application/json
    | x-frame-options: SAMEORIGIN
    | x-xss-protection: 1; mode=block
    | x-content-type-options: nosniff
    | server: dart:io with Shelf
SLVR: Version solving took 0:04:02.075859 seconds.
    | Tried 1 solutions.
FINE: Resolving dependencies finished (4:02.083s).
ERR : Connection closed while receiving data
FINE: Exception type: ClientException
FINE: package:pub/src/source/hosted.dart 344:7           BoundHostedSource._throwFriendlyError
    | package:pub/src/source/hosted.dart 144:7           BoundHostedSource.doGetVersions
    | ===== asynchronous gap ===========================
    | dart:async                                         _AsyncAwaitCompleter.completeError
    | package:pub/src/source/hosted.dart                 BoundHostedSource.doGetVersions
    | ===== asynchronous gap ===========================
    | dart:async                                         _asyncErrorWrapperHelper
    | package:pub/src/source/hosted.dart                 BoundHostedSource.doGetVersions
    | package:pub/src/source.dart 168:12                 BoundSource.getVersions
    | package:pub/src/solver/package_lister.dart 76:44   PackageLister._versions.<fn>.<fn>
    | package:pub/src/http.dart 274:51                   withDependencyType
    | package:pub/src/solver/package_lister.dart 75:33   PackageLister._versions.<fn>
    | ===== asynchronous gap ===========================
    | dart:async                                         _asyncThenWrapperHelper
    | package:pub/src/utils.dart                         minByAsync
    | package:pub/src/solver/version_solver.dart 351:25  VersionSolver._choosePackageVersion
    | ===== asynchronous gap ===========================
    | dart:async                                         _asyncThenWrapperHelper
    | package:pub/src/solver/version_solver.dart         VersionSolver.solve
    | package:pub/src/solver.dart 35:10                  resolveVersions.<fn>
    | package:pub/src/log.dart 378:18                    progress
    | package:pub/src/solver.dart 32:10                  resolveVersions
    | package:pub/src/global_packages.dart 178:22        GlobalPackages._installInCache

This happens with a high degree of consistency, for any pub global activate <package>.

Are there basic WSL issues around pub?

now windows linux subystem version is Ubuntu 16.04.1 LTS , the issue is still there

Same here with Ubuntu 16.04.5 LTS

I've just tried on WSL Ubuntu 18.04 with dart2. It seems that dart can be installed using the linux instructions (dart --version works fine), but simple commands such as

pub global activate stagehand

just hangs so basically nothing can be done.
Supporting running io tests on WSL to easily test linux compatibility from windows would be great.

I can confirm the same behaviour on WSL 18.04
Here's the output:

FINE: Extracted .tar.gz stream to /home/vlazdra/.pub-cache/_temp/dirEWUKBL. Exit code 0.
IO  : Renaming directory /home/vlazdra/.pub-cache/_temp/dirEWUKBL to /home/vlazdra/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11.
ERR : Connection closed while receiving data
FINE: Exception type: ClientException
FINE: package:http/src/io_client.dart 52:15        IOClient.send.<fn>
    | ===== asynchronous gap ===========================
    | dart:async                                   StreamView.listen
    | package:pub/src/io.dart 627:10               _store
    | package:pub/src/io.dart 873:26               extractTarGz
    | ===== asynchronous gap ===========================
    | dart:async                                   _asyncThenWrapperHelper
    | package:pub/src/io.dart                      extractTarGz
    | package:pub/src/source/hosted.dart 305:11    BoundHostedSource._download
    | ===== asynchronous gap ===========================
    | dart:async                                   _asyncThenWrapperHelper
    | package:pub/src/source/hosted.dart           BoundHostedSource._download
    | package:pub/src/source/hosted.dart 199:13    BoundHostedSource.downloadToSystemCache
    | ===== asynchronous gap ===========================
    | dart:async                                   _asyncThenWrapperHelper
    | package:pub/src/global_packages.dart         GlobalPackages._installInCache
    | package:pub/src/global_packages.dart 120:11  GlobalPackages.activateHosted

It's not alwayas the same dependency.

need to support

Please, why is this not working

Same issue here

The issue is still occurring for me.

A quick workaround for using Pub on WSL is to install Dart on Windows and point WSL $PUB_CACHE to /mnt/c/Users/usr/AppData/Roaming/Pub/Cache. When you need to run pub get, add packages to the Windows Pub cache by copying your pubspec.yaml to a Windows-accessible location and running pub get (or use pub cache add ... if you want a specific package) using the Windows Dart installation. Then, go back to your project on WSL and run pub get --offline. Sometimes you may also need to copy the resulting pubspec.lock back from Windows to WSL.

Pub on the WSL side will use the Windows Pub cache, which will now have all the packages you need.
THe only problem I've found is that Windows Pub creates .bat files for global packages which cannot be used on WSL.

Same here when run pub global activate protoc_plugin

I'm also encountering this while trying to install packages. It would be nice to get some fresh light on the issue.

I believe this is a WSL issue. I've opened https://github.com/microsoft/WSL/issues/4031 with details and an strace (though no activity on it yet).

Same issue with Ubuntu 18.04.2 LTS

Just use WSL2 now. This should work, since it uses a Linux VM.

Needs newest Insider build though:
https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

@nstrelow have you tried it and it worked? (it'd be good to know for sure it's fixed before switching to Insiders :-))

@DanTup tested pub get on WSL 2 and it works.
Tested with:

On the latest Insider build, you can migrate with: https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

It is not perfect yet. File performance is soooo much better (when creating and using files inside the Linux system, _not_ Windows folders).
But CPU performance is down a bit, due to running inside a VM.
They still have a lot of improvements planned for WSL2.

Great to know, thanks! I might hold off a bit (or wait till it hits stable - I just recently did a clean Windows install and moved back from Insiders!) but it's nice to know a fix is on its way 馃憤

I can confirm it works with WSL2. If someone is interested in this upgrade: https://www.ghacks.net/2019/06/13/microsoft-drops-windows-subsystem-for-linux-2-in-latest-windows-10-20h1-build/
I am an hour in and I can't find any defects on both win10, wsl or fs

too late but still: I just ran pub get on wsl (1) and it worked flawlessly

I'm closing this issue given the reports that it works now. Please let us know if you still have problems with the latest Dart and WSL.

Was this page helpful?
0 / 5 - 0 ratings