tldr-pages / tldr-c-client

C command-line client for tldr pages
MIT License
293 stars 50 forks source link

Error: Downloading file: https://github.com/tldr-pages/tldr/archive/main.zip #114

Closed cworld1 closed 4 weeks ago

cworld1 commented 2 months ago

Problem I met

 ~ $ tldr --update
Error: Downloading file: https://github.com/tldr-pages/tldr/archive/main.zip

Seems I'm having a good connection with the url. But the cmd tldr --update gives me error too quickly.

What I tried

There might be some bad caches or configs on it.

What I found

 ~ [1]$ curl -v https://github.com/tldr-pages/tldr/archive/main.zip
* Uses proxy env variable no_proxy == 'localhost,127.0.0.1,localaddress,.localdomain.com'
* Uses proxy env variable https_proxy == 'http://127.0.0.1:7890'
*   Trying 127.0.0.1:7890...
* Connected to 127.0.0.1 (127.0.0.1) port 7890
* CONNECT tunnel: HTTP/1.1 negotiated
* allocate connect buffer
* Establish HTTP proxy tunnel to github.com:443
> CONNECT github.com:443 HTTP/1.1
> Host: github.com:443
> User-Agent: curl/8.4.0
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* CONNECT phase completed
* CONNECT tunnel established, response 200
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES128-GCM-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=github.com
*  start date: Mar  7 00:00:00 2024 GMT
*  expire date: Mar  7 23:59:59 2025 GMT
*  subjectAltName: host "github.com" matched cert's "github.com"
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo ECC Domain Validation Secure Server CA
*  SSL certificate verify ok.
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://github.com/tldr-pages/tldr/archive/main.zip
* [HTTP/2] [1] [:method: GET]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: github.com]
* [HTTP/2] [1] [:path: /tldr-pages/tldr/archive/main.zip]
* [HTTP/2] [1] [user-agent: curl/8.4.0]
* [HTTP/2] [1] [accept: */*]
> GET /tldr-pages/tldr/archive/main.zip HTTP/2
> Host: github.com
> User-Agent: curl/8.4.0
> Accept: */*
>
< HTTP/2 302
< server: GitHub.com
< date: Mon, 22 Apr 2024 06:10:42 GMT
< content-type: text/html; charset=utf-8
< vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, Accept-Encoding, Accept, X-Requested-With
< location: https://codeload.github.com/tldr-pages/tldr/zip/refs/heads/main
< cache-control: max-age=0, private
< strict-transport-security: max-age=31536000; includeSubdomains; preload
< x-frame-options: deny
< x-content-type-options: nosniff
< x-xss-protection: 0
< referrer-policy: no-referrer-when-downgrade
< content-security-policy: default-src 'none'; base-uri 'self'; child-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com api.githubcopilot.com objects-origin.githubusercontent.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.com/assets-cdn/worker/ gist.github.com/assets-cdn/worker/
< content-length: 0
< x-github-request-id: 6919:3BF392:27A5547:2AD9251:6625FFBF
<
* Connection #0 to host 127.0.0.1 left intact

It show a redirection for that link. I tried to use curl to download it, and actually it need 302 redirection flag:

curl -L -o main.zip https://github.com/tldr-pages/tldr/archive/main.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 7273k  100 7273k    0     0  1500k      0  0:00:04  0:00:04 --:--:-- 2018k

More infos

And there's my env vars:

set -x
CARGO_HOME /Users/cworld/.local/share/cargo
COLORFGBG '15;0'
COLORTERM truecolor
COMMAND_MODE unix2003
EDITOR nvim
GOPATH /Users/cworld/.local/share/go
HISTFILE /Users/cworld/.local/state/bash/history
HOME /Users/cworld
HOMEBREW_API_DOMAIN https://mirrors.bfsu.edu.cn/homebrew-bottles/api
HOMEBREW_BOTTLE_DOMAIN https://mirrors.bfsu.edu.cn/homebrew-bottles
HOMEBREW_BREW_GIT_REMOTE https://mirrors.bfsu.edu.cn/git/homebrew/brew.git
HOMEBREW_CORE_GIT_REMOTE https://mirrors.bfsu.edu.cn/git/homebrew/homebrew-core.git
HOMEBREW_PIP_INDEX_URL https://mirrors.bfsu.edu.cn/pypi/web/simple
ITERM_PROFILE Default
ITERM_SESSION_ID w0t1p0:E0D2521C-70F0-4135-AC5D-5DFE6624FB5D
LANG en_US.UTF-8
LC_TERMINAL iTerm2
LC_TERMINAL_VERSION 3.4.23
LESSHISTFILE /Users/cworld/.local/state/less/history
LOGNAME cworld
NODE_REPL_HISTORY /Users/cworld/.local/share/node_repl_history
NPM_CONFIG_USERCONFIG /Users/cworld/.config/npm/npmrc
PATH '/Users/cworld/.local/bin'  '/usr/local/bin'  '/System/Crypt…
PNPM_HOME /Users/cworld/.local/share/pnpm
PWD /Users/cworld
SHELL /usr/local/bin/fish
SHLVL 1
SSH_AUTH_SOCK /private/tmp/com.apple.launchd.mdabSNE4MV/Listeners
TERM xterm-256color
TERM_PROGRAM iTerm.app
TERM_PROGRAM_VERSION 3.4.23
TERM_SESSION_ID w0t1p0:E0D2521C-70F0-4135-AC5D-5DFE6624FB5D
TLDR_CACHE_DIR /Users/cworld/.cache/tldr
TMPDIR /var/folders/hk/v81bfvy97mg4ry2lyfh7vdkh0000gn/T/
USER cworld
XDG_CACHE_HOME /Users/cworld/.cache
XDG_CONFIG_HOME /Users/cworld/.config
XDG_DATA_HOME /Users/cworld/.local/share
XDG_RUNTIME_DIR
XDG_STATE_HOME /Users/cworld/.local/state
XPC_FLAGS 0x0
XPC_SERVICE_NAME 0
__CFBundleIdentifier com.googlecode.iterm2
__CF_USER_TEXT_ENCODING 0x0:0:0
http_proxy http://127.0.0.1:7890
https_proxy http://127.0.0.1:7890
no_proxy localhost,127.0.0.1,localaddress,.localdomain.com
cworld1 commented 2 months ago

Hi @cworld1

After checking the issue

tldrc will try to store the main.zip in the following three paths.

  1. $TLDR_CACHE_DIR/.tldrc/

  2. $HOME/.tldrc/

  3. <Current users' home directory>/.tldrc/

Can you help check

  1. if there is $TLDR_CACHE_DIR env variable?

  2. if the $HOME directory is write-enabled? or share the permission of $HOME directory

From the log above it seems connect to the proxy 127.0.0.1:7890 first, not sure if the proxy cannot write to the home directory.

  1. Cannot find $TLDR_CACHE_DIR env war
  2. $HOME is writable (or I will get stuck on other things)
  3. Whether to use proxy, I got the same result.

I tried to use another client and solve my problem. Still thank you.