Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to upload the package #16658

Closed
pj0579 opened this issue Apr 17, 2018 · 18 comments
Closed

Failed to upload the package #16658

pj0579 opened this issue Apr 17, 2018 · 18 comments

Comments

@pj0579
Copy link

@pj0579 pj0579 commented Apr 17, 2018

Steps to Reproduce

flutter packages pub publish --verbose

## Logs
ERR : Failed to upload the package.
FINE: Exception type: ApplicationException
FINE: package:pub/src/utils.dart 735           fail
    | package:pub/src/command/lish.dart 106    LishCommand._publish
    | ===== asynchronous gap ===========================
    | dart:async                               _Completer.completeError
    | package:pub/src/command/lish.dart        LishCommand._publish
    | ===== asynchronous gap ===========================
    | dart:async                               _asyncErrorWrapperHelper
    | package:pub/src/command/lish.dart 64     LishCommand._publish
    | package:pub/src/command/lish.dart 145    LishCommand.run
    | ===== asynchronous gap ===========================
    | dart:async                               _asyncThenWrapperHelper
    | package:pub/src/command/lish.dart 115    LishCommand.run
    | package:args/command_runner.dart 194     CommandRunner.runCommand
    | ===== asynchronous gap ===========================
    | dart:async                               new Future.microtask
    | package:args/command_runner.dart 142     CommandRunner.runCommand
    | package:pub/src/command_runner.dart 167  PubCommandRunner.runCommand.<fn>
    | dart:async                               new Future.sync
    | package:pub/src/utils.dart 103           captureErrors.<fn>
    | package:stack_trace                      Chain.capture
    | package:pub/src/utils.dart 118           captureErrors
    | package:pub/src/command_runner.dart 167  PubCommandRunner.runCommand
pub finished with exit code 1

#0      throwToolExit (package:flutter_tools/src/base/common.dart:28)
#1      pubInteractively (package:flutter_tools/src/dart/pub.dart:183)
<asynchronous suspension>
#2      PackagesPassthroughCommand.runCommand (package:flutter_tools/src/commands/packages.dart:131)
#3      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:333)
<asynchronous suspension>
#4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:270)
<asynchronous suspension>
#5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142)
<asynchronous suspension>
#6      _rootRun (dart:async/zone.dart:1126)
#7      _CustomZone.run (dart:async/zone.dart:1023)
#8      runZoned (dart:async/zone.dart:1501)
#9      AppContext.run (package:flutter_tools/src/base/context.dart:141)
<asynchronous suspension>
#10     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:261)
#11     CommandRunner.runCommand (package:args/command_runner.dart:194)
<asynchronous suspension>
#12     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:298)
<asynchronous suspension>
#13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142)
<asynchronous suspension>
#14     _rootRun (dart:async/zone.dart:1126)
#15     _CustomZone.run (dart:async/zone.dart:1023)
#16     runZoned (dart:async/zone.dart:1501)
#17     AppContext.run (package:flutter_tools/src/base/context.dart:141)
<asynchronous suspension>
#18     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:254)
<asynchronous suspension>
#19     CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:109)
#20     new Future.sync (dart:async/future.dart:222)
#21     CommandRunner.run (package:args/command_runner.dart:109)
#22     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:168)
#23     run.<anonymous closure> (package:flutter_tools/runner.dart:54)
<asynchronous suspension>
#24     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:142)
<asynchronous suspension>
#25     _rootRun (dart:async/zone.dart:1126)
#26     _CustomZone.run (dart:async/zone.dart:1023)
#27     runZoned (dart:async/zone.dart:1501)
#28     AppContext.run (package:flutter_tools/src/base/context.dart:141)
<asynchronous suspension>
#29     runInContext (package:flutter_tools/src/context_runner.dart:41)
<asynchronous suspension>
#30     run (package:flutter_tools/runner.dart:49)
#31     main (package:flutter_tools/executable.dart:48)
<asynchronous suspension>
#32     main (file:///Users/xukankan/flutter/packages/flutter_tools/bin/flutter_tools.dart:16)
#33     _startIsolate.<anonymous closure> (dart:isolate-patch/dart:isolate/isolate_patch.dart:277)
#34     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:165)

Flutter Doctor

[✓] Flutter (Channel beta, v0.2.8, on Mac OS X 10.13 17A405, locale zh-Hans-CN)
• Flutter version 0.2.8 at /Users/xukankan/flutter
• Framework revision b397406 (2 weeks ago), 2018-04-02 13:53:20 -0700
• Engine revision c903c21
• Dart version 2.0.0-dev.43.0.flutter-52afcba357

[!] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/xukankan/Library/Android/sdk
• Android NDK at /Users/xukankan/Library/Android/sdk/ndk-bundle
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] iOS toolchain - develop for iOS devices (Xcode 9.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.2, Build version 9C40b
• ios-deploy 1.9.2
• CocoaPods version 1.4.0

[✓] Android Studio (version 3.0)
• Android Studio at /Applications/Android Studio.app/Contents

@pj0579

This comment has been minimized.

Copy link
Author

@pj0579 pj0579 commented Apr 17, 2018

FINE: Loading OAuth2 credentials.
FINE: Saving OAuth2 credentials.
IO : Writing 358 characters to text file /Users/xukankan/.pub-cache/credentials.json.
MSG : Uploading...
IO : HTTP GET https://pub.flutter-io.cn/api/packages/versions/new
| Accept: application/vnd.pub.v2+json
| authorization:
| user-agent: Dart pub 2.0.0-edge.0d5cf900b021bf5c9fa593ffa12b15bcd1cc5fe0
IO : HTTP response 200 OK for GET https://pub.flutter-io.cn/api/packages/versions/new
| took 0:00:00.659161
| connection: keep-alive
| date: Tue, 17 Apr 2018 08:04:27 GMT
| vary: Accept-Encoding
| content-type: application/json
| x-xss-protection: 1; mode=block
| x-swift-cachetime: 0
| server: Tengine
| timing-allow-origin: *
| alt-svc: hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35"
| content-length: 1250
| x-swift-savetime: Tue, 17 Apr 2018 08:04:27 GMT
| x-frame-options: SAMEORIGIN
| via: 1.1 google, cache13.l2nu17-1[543,200-0,M], cache42.l2nu17-1[544,0], cache2.cn211[555,200-0,M], cache3.cn211[557,0]
| x-content-type-options: nosniff
| x-cache: MISS TCP_MISS dirn:-2:-2 mlen:-1
| eagleid: ca6cfacb15239522674032688e
IO : HTTP POST https://storage.flutter-io.cn
| authorization:
| content-type: multipart/form-data; boundary=dart-http-boundary-UQeyosyVNKQbc0B5HAYg0TVGmohJD1YC04va-sVpr4JlrsjKwfC
| user-agent: Dart pub 2.0.0-edge.0d5cf900b021bf5c9fa593ffa12b15bcd1cc5fe0
IO : HTTP response 200 OK for POST https://storage.flutter-io.cn
| took 0:00:01.794945
| last-modified: Tue, 10 Apr 2018 06:02:07 GMT
| date: Tue, 17 Apr 2018 08:04:29 GMT
| content-encoding: gzip
| vary: Accept-Encoding
| x-reqid: BlUAANMXC9uDKiYV
| access-control-expose-headers: X-Log, X-Reqid
| x-m-reqid: M2QAAKTgA86DKiYV
| x-swift-cachetime: 0
| server: Tengine
| x-log: mc.g;s.gh;PFDS;IO:1
| content-disposition: inline; filename=""; filename*=utf-8' '
| accept-ranges: bytes
| content-length: 361
| x-swift-savetime: Tue, 17 Apr 2018 08:04:29 GMT
| etag: "FiFvdr5ZBIMcaPj0iLjPvsai3oOy.gz"
| x-qiniu-zone: 2
| eagleid: 7b7d07cb15239522682807417e
| connection: keep-alive
| cache-control: public, max-age=31536000
| access-control-allow-origin: *
| access-control-max-age: 2592000
| content-type: text/html
| x-m-log: QNM:xs478;SRCPROXY:xs486;SRC:234;SRCPROXY:234;QNM3:234
| x-svr: IO
| timing-allow-origin: *
| content-transfer-encoding: binary
| via: cache32.l2nu17-1[1464,200-0,M], cache14.l2nu17-1[1470,0], cache2.cn441[1491,200-0,M], cache3.cn441[1492,0]
| x-qnm-cache: RawProxy
| x-cache: MISS TCP_MISS dirn:-2:-2 mlen:-1
FINE: Uploading finished (2.508s).
FINE: Saving OAuth2 credentials.
IO : Writing 358 characters to text file /Users/xukankan/.pub-cache/credentials.json.

@peng8350

This comment has been minimized.

Copy link

@peng8350 peng8350 commented May 3, 2018

@pj0579 这个问题你是怎么解决的,能否告知一下,和你完全一模一样的异常信息

@pj0579

This comment has been minimized.

Copy link
Author

@pj0579 pj0579 commented May 4, 2018

@peng8350 万能解决办法 终端翻墙就行了

@peng8350

This comment has been minimized.

Copy link

@peng8350 peng8350 commented May 4, 2018

@pj0579 刚刚解决了,但不是这个问题,curl www.google.com,能正常获取页面,如果是没有翻墙,它会不断timeout,但没有这个消息显示

   sudo flutter packages pub publish -v

用sudo就解决了- -,搞了半天

@zoechi

This comment has been minimized.

Copy link
Contributor

@zoechi zoechi commented May 4, 2018

@zoechi

This comment has been minimized.

Copy link
Contributor

@zoechi zoechi commented Aug 1, 2018

If you need sudo you probably have installed Flutter in a directory with insufficient permissions (for example c:\Program Files).
You should fix the permissions or delete and reinstall Flutter in a different directory.

@chenyuantao

This comment has been minimized.

Copy link

@chenyuantao chenyuantao commented Aug 26, 2018

@pj0579 你是怎样终端翻墙的?开SS,然后终端 export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;吗?我终端可以curl google,但是仍然失败

@shaomaicheng

This comment has been minimized.

Copy link

@shaomaicheng shaomaicheng commented Oct 20, 2018

@pj0579 你是怎样终端翻墙的?开SS,然后终端 export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;吗?我终端可以curl google,但是仍然失败

你好,你这边有解决吗,我也是终端翻墙的。pub的get没问题,但是传plugin上不去,也是google的oauth走的时候timeout了

@chenyuantao

This comment has been minimized.

Copy link

@chenyuantao chenyuantao commented Oct 20, 2018

@pj0579 你是怎样终端翻墙的?开SS,然后终端 export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;吗?我终端可以curl google,但是仍然失败

你好,你这边有解决吗,我也是终端翻墙的。pub的get没问题,但是传plugin上不去,也是google的oauth走的时候timeout了

去掉官方指引里面对PUB_HOSTED_URL、FLUTTER_STORAGE_BASE_URL的修改,这些修改会导致上传pub失败。
https://github.com/flutter/flutter/wiki/Using-Flutter-in-China

@02002love

This comment has been minimized.

Copy link

@02002love 02002love commented Mar 26, 2019

@pj0579 刚刚解决了,但不是这个问题,curl www.google.com,能正常获取页面,如果是没有翻墙,它会不断timeout,但没有这个消息显示

   sudo flutter packages pub publish -v

用sudo就解决了- -,搞了半天

我也是被坑了半天, 生活在墙内遇见这,也是😐无语了,额鹅鹅鹅

@sharpron

This comment has been minimized.

Copy link

@sharpron sharpron commented Jul 22, 2019

我用的windows翻了墙还是不行,换mac后解决

@yuxuelian

This comment has been minimized.

Copy link

@yuxuelian yuxuelian commented Aug 21, 2019

我也是 Windows 报同样的错误 我终端可以curl www.google.com,但是仍然失败

@XingXiaoWu

This comment has been minimized.

Copy link

@XingXiaoWu XingXiaoWu commented Sep 7, 2019

我也是 Windows 报同样的错误 我终端可以curl www.google.com,但是仍然失败

兄弟你解决了吗

@XingXiaoWu

This comment has been minimized.

Copy link

@XingXiaoWu XingXiaoWu commented Sep 7, 2019

macos: 10.14.6
shell : zsh
terminal tool : iterm2

Open ss access network, the default port is 1087
Through the

export http_proxy = http://127.0.0.1:1087
export https_proxy = http://127.0.0.1:1087

I can "curl www.google.com"
I think the network is OK

But the authorization has been stuck, as shown in the figure below。

macos: 10.14.6
shell : zsh
终端工具 : iterm2

开的ss访问外网,默认端口为1087
通过

export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087

可以在终端curl www.google.com获取网页
我认为是翻出去了

但是一直卡在授权,如下图,
尝试过使用

sudo flutter packages pub publish -v

flutter packages pub publish --server=https://pub.dartlang.org

均是如此
image

@XingXiaoWu

This comment has been minimized.

Copy link

@XingXiaoWu XingXiaoWu commented Sep 7, 2019

我想我知道原因了,是国内镜像导致的,但仅仅在shell中关闭时不够的,索性把我的解决过程贴出来。
建议做如下操作
1.设置终端代理
举例这里用小飞机

Mac:在终端输入
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087
测试
curl www.google.com
有回文则成功

2.关闭国内镜像
我这里用的zsh,用bash的切换到.bash_profile文件

vim ~/.zshrc


export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

将PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL注释掉
3.cd到写好的插件仓库根目录,执行一次

flutter packages get

这时候就会把你的插件里的lock文件中的国内镜像转到官方源上了
4.正常使用
sudo flutter packages pub publish -v

flutter packages pub publish --server=https://pub.dartlang.org
即可

P.S:猜测上面那位Windows不行换成Mac就行了的老哥应该是在mac第一次拉仓库然后vscode自动做了一次package get操作,所以就ok了

@wqycsu

This comment has been minimized.

Copy link

@wqycsu wqycsu commented Oct 28, 2019

我想我知道原因了,是国内镜像导致的,但仅仅在shell中关闭时不够的,索性把我的解决过程贴出来。
建议做如下操作
1.设置终端代理
举例这里用小飞机

Mac:在终端输入
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087
测试
curl www.google.com
有回文则成功

2.关闭国内镜像
我这里用的zsh,用bash的切换到.bash_profile文件

vim ~/.zshrc


export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

将PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL注释掉
3.cd到写好的插件仓库根目录,执行一次

flutter packages get

这时候就会把你的插件里的lock文件中的国内镜像转到官方源上了
4.正常使用
sudo flutter packages pub publish -v

flutter packages pub publish --server=https://pub.dartlang.org
即可

P.S:猜测上面那位Windows不行换成Mac就行了的老哥应该是在mac第一次拉仓库然后vscode自动做了一次package get操作,所以就ok了

@XingXiaoWu 使用你的方法仍然会报错,报错信息为:

IO : HTTP response 400 Bad Request for GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=dc9b6168-34e8-4361-ad7d-3a9a8bfb297f&bucket=pub-packages&key=tmp/dc9b6168-34e8-4361-ad7d-3a9a8bfb297f&etag=91f59489a999a618844811e7bfcd03f4
| took 0:00:00.964942
| date: Mon, 28 Oct 2019 09:18:00 GMT
| content-length: 69
| strict-transport-security: max-age=31536000; preload
| 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
FINE: Uploading finished (5.081s).
FINE: Saving OAuth2 credentials.
IO : Writing 431 characters to text file /Users/weiquanyun/flutter/flutter/.pub-cache/credentials.json.
ERR : Version 0.0.2 of package log already exists..
FINE: Exception type: ApplicationException
FINE: package:pub/src/utils.dart 571:5 fail
| package:pub/src/http.dart 302:3 handleJsonError
| package:pub/src/command/lish.dart 105:9 LishCommand._publish
| ===== asynchronous gap ===========================
| dart:async Future.catchError
| package:pub/src/utils.dart 109:52 captureErrors.
| package:stack_trace Chain.capture
| package:pub/src/utils.dart 122:11 captureErrors
| package:pub/src/command_runner.dart 171:13 PubCommandRunner.runCommand
pub finished with exit code 1

error提示package已经存在,然后我修改了版本号,结果仍然报错,不过报错信息发生了变化:

IO : HTTP GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=d6171cb3-43c9-428a-b876-59c8374376f9&bucket=pub-packages&key=tmp/d6171cb3-43c9-428a-b876-59c8374376f9&etag=80895c6946e7b5b1be2ecd3ab49c84d7
| Accept: application/vnd.pub.v2+json
| authorization:
| user-agent: Dart pub 2.5.0
IO : HTTP response 400 Bad Request for GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=d6171cb3-43c9-428a-b876-59c8374376f9&bucket=pub-packages&key=tmp/d6171cb3-43c9-428a-b876-59c8374376f9&etag=80895c6946e7b5b1be2ecd3ab49c84d7
| took 0:00:01.097374
| date: Mon, 28 Oct 2019 09:22:28 GMT
| content-length: 115
| strict-transport-security: max-age=31536000; preload
| 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
FINE: Uploading finished (5.674s).
FINE: Saving OAuth2 credentials.
IO : Writing 431 characters to text file /Users/weiquanyun/flutter/flutter/.pub-cache/credentials.json.
ERR : InsufficientPermissions: Insufficient permissions to upload new versions of package log..
FINE: Exception type: ApplicationException
FINE: package:pub/src/utils.dart 571:5 fail
| package:pub/src/http.dart 302:3 handleJsonError
| package:pub/src/command/lish.dart 105:9 LishCommand._publish
| ===== asynchronous gap ===========================
| dart:async Future.catchError
| package:pub/src/utils.dart 109:52 captureErrors.
| package:stack_trace Chain.capture
| package:pub/src/utils.dart 122:11 captureErrors
| package:pub/src/command_runner.dart 171:13 PubCommandRunner.runCommand
pub finished with exit code 1

请问你知道该如何解决吗?

@XingXiaoWu

This comment has been minimized.

Copy link

@XingXiaoWu XingXiaoWu commented Oct 28, 2019

我想我知道原因了,是国内镜像导致的,但仅仅在shell中关闭时不够的,索性把我的解决过程贴出来。
建议做如下操作
1.设置终端代理
举例这里用小飞机

Mac:在终端输入
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087
测试
curl www.google.com
有回文则成功

2.关闭国内镜像
我这里用的zsh,用bash的切换到.bash_profile文件

vim ~/.zshrc


export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

将PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL注释掉
3.cd到写好的插件仓库根目录,执行一次

flutter packages get

这时候就会把你的插件里的lock文件中的国内镜像转到官方源上了
4.正常使用
sudo flutter packages pub publish -v

flutter packages pub publish --server=https://pub.dartlang.org
即可
P.S:猜测上面那位Windows不行换成Mac就行了的老哥应该是在mac第一次拉仓库然后vscode自动做了一次package get操作,所以就ok了

@XingXiaoWu 使用你的方法仍然会报错,报错信息为:

IO : HTTP response 400 Bad Request for GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=dc9b6168-34e8-4361-ad7d-3a9a8bfb297f&bucket=pub-packages&key=tmp/dc9b6168-34e8-4361-ad7d-3a9a8bfb297f&etag=91f59489a999a618844811e7bfcd03f4
| took 0:00:00.964942
| date: Mon, 28 Oct 2019 09:18:00 GMT
| content-length: 69
| strict-transport-security: max-age=31536000; preload
| 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
FINE: Uploading finished (5.081s).
FINE: Saving OAuth2 credentials.
IO : Writing 431 characters to text file /Users/weiquanyun/flutter/flutter/.pub-cache/credentials.json.
ERR : Version 0.0.2 of package log already exists..
FINE: Exception type: ApplicationException
FINE: package:pub/src/utils.dart 571:5 fail
| package:pub/src/http.dart 302:3 handleJsonError
| package:pub/src/command/lish.dart 105:9 LishCommand._publish
| ===== asynchronous gap ===========================
| dart:async Future.catchError
| package:pub/src/utils.dart 109:52 captureErrors.
| package:stack_trace Chain.capture
| package:pub/src/utils.dart 122:11 captureErrors
| package:pub/src/command_runner.dart 171:13 PubCommandRunner.runCommand
pub finished with exit code 1

error提示package已经存在,然后我修改了版本号,结果仍然报错,不过报错信息发生了变化:

IO : HTTP GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=d6171cb3-43c9-428a-b876-59c8374376f9&bucket=pub-packages&key=tmp/d6171cb3-43c9-428a-b876-59c8374376f9&etag=80895c6946e7b5b1be2ecd3ab49c84d7
| Accept: application/vnd.pub.v2+json
| authorization:
| user-agent: Dart pub 2.5.0
IO : HTTP response 400 Bad Request for GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=d6171cb3-43c9-428a-b876-59c8374376f9&bucket=pub-packages&key=tmp/d6171cb3-43c9-428a-b876-59c8374376f9&etag=80895c6946e7b5b1be2ecd3ab49c84d7
| took 0:00:01.097374
| date: Mon, 28 Oct 2019 09:22:28 GMT
| content-length: 115
| strict-transport-security: max-age=31536000; preload
| 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
FINE: Uploading finished (5.674s).
FINE: Saving OAuth2 credentials.
IO : Writing 431 characters to text file /Users/weiquanyun/flutter/flutter/.pub-cache/credentials.json.
ERR : InsufficientPermissions: Insufficient permissions to upload new versions of package log..
FINE: Exception type: ApplicationException
FINE: package:pub/src/utils.dart 571:5 fail
| package:pub/src/http.dart 302:3 handleJsonError
| package:pub/src/command/lish.dart 105:9 LishCommand._publish
| ===== asynchronous gap ===========================
| dart:async Future.catchError
| package:pub/src/utils.dart 109:52 captureErrors.
| package:stack_trace Chain.capture
| package:pub/src/utils.dart 122:11 captureErrors
| package:pub/src/command_runner.dart 171:13 PubCommandRunner.runCommand
pub finished with exit code 1

请问你知道该如何解决吗?

没看出来变化啊,不一直是http 400么

@wqycsu

This comment has been minimized.

Copy link

@wqycsu wqycsu commented Oct 28, 2019

我想我知道原因了,是国内镜像导致的,但仅仅在shell中关闭时不够的,索性把我的解决过程贴出来。
建议做如下操作
1.设置终端代理
举例这里用小飞机

Mac:在终端输入
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087
测试
curl www.google.com
有回文则成功

2.关闭国内镜像
我这里用的zsh,用bash的切换到.bash_profile文件

vim ~/.zshrc


export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

将PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL注释掉
3.cd到写好的插件仓库根目录,执行一次

flutter packages get

这时候就会把你的插件里的lock文件中的国内镜像转到官方源上了
4.正常使用
sudo flutter packages pub publish -v

flutter packages pub publish --server=https://pub.dartlang.org
即可
P.S:猜测上面那位Windows不行换成Mac就行了的老哥应该是在mac第一次拉仓库然后vscode自动做了一次package get操作,所以就ok了

@XingXiaoWu 使用你的方法仍然会报错,报错信息为:

IO : HTTP response 400 Bad Request for GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=dc9b6168-34e8-4361-ad7d-3a9a8bfb297f&bucket=pub-packages&key=tmp/dc9b6168-34e8-4361-ad7d-3a9a8bfb297f&etag=91f59489a999a618844811e7bfcd03f4
| took 0:00:00.964942
| date: Mon, 28 Oct 2019 09:18:00 GMT
| content-length: 69
| strict-transport-security: max-age=31536000; preload
| 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
FINE: Uploading finished (5.081s).
FINE: Saving OAuth2 credentials.
IO : Writing 431 characters to text file /Users/weiquanyun/flutter/flutter/.pub-cache/credentials.json.
ERR : Version 0.0.2 of package log already exists..
FINE: Exception type: ApplicationException
FINE: package:pub/src/utils.dart 571:5 fail
| package:pub/src/http.dart 302:3 handleJsonError
| package:pub/src/command/lish.dart 105:9 LishCommand._publish
| ===== asynchronous gap ===========================
| dart:async Future.catchError
| package:pub/src/utils.dart 109:52 captureErrors.
| package:stack_trace Chain.capture
| package:pub/src/utils.dart 122:11 captureErrors
| package:pub/src/command_runner.dart 171:13 PubCommandRunner.runCommand
pub finished with exit code 1

error提示package已经存在,然后我修改了版本号,结果仍然报错,不过报错信息发生了变化:

IO : HTTP GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=d6171cb3-43c9-428a-b876-59c8374376f9&bucket=pub-packages&key=tmp/d6171cb3-43c9-428a-b876-59c8374376f9&etag=80895c6946e7b5b1be2ecd3ab49c84d7
| Accept: application/vnd.pub.v2+json
| authorization:
| user-agent: Dart pub 2.5.0
IO : HTTP response 400 Bad Request for GET https://pub.dartlang.org/api/packages/versions/newUploadFinish?upload_id=d6171cb3-43c9-428a-b876-59c8374376f9&bucket=pub-packages&key=tmp/d6171cb3-43c9-428a-b876-59c8374376f9&etag=80895c6946e7b5b1be2ecd3ab49c84d7
| took 0:00:01.097374
| date: Mon, 28 Oct 2019 09:22:28 GMT
| content-length: 115
| strict-transport-security: max-age=31536000; preload
| 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
FINE: Uploading finished (5.674s).
FINE: Saving OAuth2 credentials.
IO : Writing 431 characters to text file /Users/weiquanyun/flutter/flutter/.pub-cache/credentials.json.
ERR : InsufficientPermissions: Insufficient permissions to upload new versions of package log..
FINE: Exception type: ApplicationException
FINE: package:pub/src/utils.dart 571:5 fail
| package:pub/src/http.dart 302:3 handleJsonError
| package:pub/src/command/lish.dart 105:9 LishCommand._publish
| ===== asynchronous gap ===========================
| dart:async Future.catchError
| package:pub/src/utils.dart 109:52 captureErrors.
| package:stack_trace Chain.capture
| package:pub/src/utils.dart 122:11 captureErrors
| package:pub/src/command_runner.dart 171:13 PubCommandRunner.runCommand
pub finished with exit code 1

请问你知道该如何解决吗?

没看出来变化啊,不一直是http 400么

ERR信息不一样,应该是插件名称有问题(log估计不能用),我换了名字重新创建一个就好了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
10 participants
You can’t perform that action at this time.