scibrokes / setup-centOS7-DO

设置与管理服务器
https://gitee.com/englianhu
GNU General Public License v3.0
0 stars 0 forks source link

Using github PAT from envvar GITHUB_PAT 错误: Failed to install 'unknown package' from GitHub: Timeout was reached: [api.github.com] Resolving timed out after 10000 milliseconds #3

Closed englianhu closed 1 year ago

englianhu commented 1 year ago
if(!require('REmap')) devtools::install_github('lchiffon/REmap')
载入需要的程辑包:REmap
Warning: 不存在叫‘REmap’这个名字的程辑包Using github PAT from envvar GITHUB_PAT
错误: Failed to install 'unknown package' from GitHub:
  Timeout was reached: [api.github.com] Resolving timed out after 10000 milliseconds

虚拟服务器 / 代理服务器(VPN / Proxy Server)

引用:虚拟服务器 / 代理服务器(VPN / Proxy Server)

englianhu commented 1 year ago
:~$ ## https://www.flyvpn.com/download/linux-vpn
:~$ wget https://www.flyvpn.com/files/downloads/linux/flyvpn-x86_64-4.1.1.0.tar.gz
:~$ ## sudo tar -xzf flyvpn-x86_64-4.1.1.0.tar.gz
:~$ ## sudo tar -xzvf flyvpn-x86_64-4.1.1.0.tar.gz
:~$ sudo tar -zxvf flyvpn-x86_64-4.1.1.0.tar.gz
:~$ sudo rm -rf flyvpn-x86_64-4.1.1.0.tar.gz
:~$ sudo chmod a+x flyvpn

:~$ ## 查看flyvpn飞跃虚拟服务器基本功能
:~$ sudo ./flyvpn
flyvpn 4.1.1.0 (core:20210315-1730)
Can not open config file: /etc/flyvpn.conf

Usage: ./flyvpn -h
Usage: ./flyvpn {login|list|logout}
Usage: ./flyvpn connect "Shanghai 1*"
Default config file: /etc/flyvpn.conf
Config file options:
        user your-account-name
        pass your-password

:~$ ## 通过`sudo micro /etc/flyvpn.conf`设置用户名和密码,Ctrl+S储存后Ctrl+Q退出,如下
:~$ sudo micro /etc/flyvpn.conf
user Your-Account-Name
pass Your-Password

:~$ ## 查询所有虚拟服务器列表
:~$ sudo ./flyvpn list

:~$ ## 登录账户并链接虚拟服务器
:~$ sudo ./flyvpn login
:~$ sudo ./flyvpn connect 'Shaoxing #12'                flyvpn 4.1.1.0 (core:20210315-1730)
Load config file: /etc/flyvpn.conf
Command: connect
Account: englianhu@gmail.com
=====================================================
Web Site: https://www.flyvpn.com
Login Result: OK
Login Message: You are a free trial user and you can use 3 free trials per day. Or you can upgrade to enjoy paid service.
Membership: Free VPN
Expiration: (expired)
=====================================================
Server: "Shaoxing #12"
Please choose protocol [udp/tcp/lwip/proxy]: udp
2022-08-26 08:49:27 [I] flyvpn state = 102, rx = 592, tx = 1683
2022-08-26 08:49:28 [I] flyvpn state = 200, rx = 869, tx = 2771
2022-08-26 08:49:28 [I] flyvpn protocol: udp
2022-08-26 08:49:28 [I] flyvpn opened tun: tun0
2022-08-26 08:49:28 [I] flyvpn setting ip addresses and routes ...
2022-08-26 08:49:29 [I] flyvpn server: Shaoxing #12, server virtual ip: 10.253.240.1, client virtual ip: 10.253.250.5
2022-08-26 08:49:29 [I] flyvpn tun: tun0
2022-08-26 08:49:29 [I] flyvpn dns: 114.114.114.114,223.5.5.5
2022-08-26 08:49:29 [I] flyvpn use vpn as default route gateway
2022-08-26 08:49:29 [I] flyvpn backup dns /etc/resolv.conf to /tmp/flyvpn-data/resolv.conf.backup
2022-08-26 08:49:29 [I] flyvpn update dns nameserver in /etc/resolv.conf
2022-08-26 08:49:29 [I] flyvpn done

欲知更多详情,请查阅

englianhu commented 1 year ago
:~$ sudo ./flyvpn --help
flyvpn 4.1.1.0 (core:20210315-1730)

Usage: ./flyvpn -h
Usage: ./flyvpn {login|list|logout}
Usage: ./flyvpn connect "Shanghai 1*"
Default config file: /etc/flyvpn.conf
Config file options:
        user your-account-name
        pass your-password

For experts: ./flyvpn -c /etc/flyvpn.conf {login|list|connect|logout}
Config file advanced options:
        cache_dir /tmp
        connect server-name(wildcard supported)
        protocol {udp|tcp|lwip|socks5|http|proxy}
        use_vpn_dns {yes|no}
        use_vpn_route {yes|no}
        up_down your-script-file

引用:FlyVPN Linux 使用教程

通过sudo micro /etc/flyvpn.conf设置:

复制粘贴如下后,Ctrl+S储存后Ctrl+Q退出。

user englianhu@gmail.com #邮箱账户
pass ****** #密码
connect "Shaoxing #12" #连接服务器
protocol udp #协议类型设置

如果都设置好的话,日后只需要以下两行即可登录并连接,使用虚拟服务器。

:~$ sudo ./flyvpn login
:~$ sudo ./flyvpn connect
englianhu commented 1 year ago

我遇到了同样的问题,然后我使用remotes::install_github()并从R会话中设置了Sys.setenv("R_REMOTES_NO_ERRORS_FROM_WARNINGS" = "true")

参考:

引用:腾讯云:R install_github:错误:无法安装'unknown install_github‘


:~$ sudo ./flyvpn login
:~$ sudo ./flyvpn connect

如上更换IP后再尝试安装,就不会再出现‘unknown package’和[api.github.com] timeout错误信息,而是以下Bad credentials和限次的错误信息。

if(!require('REmap')) devtools::install_github('lchiffon/REmap')
载入需要的程辑包:REmap
Warning: 不存在叫‘REmap’这个名字的程辑包Using github PAT from envvar GITHUB_PAT
错误: Failed to install 'unknown package' from GitHub:
  HTTP error 401.
  Bad credentials

  Rate limit remaining: 59/60
  Rate limit reset at: 2022-08-26 18:27:52 UTC

参考文献:

englianhu commented 1 year ago

Issue resolved. Looked through the install_github code. Not sure where, why or how a GITHUB_PAT was set in my R environment! Unsetting it worked fine.


> install_github("StatsWithR/statsr")
Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo StatsWithR/statsr@master
from URL https://api.github.com/repos/StatsWithR/statsr/zipball/master
Installation failed: Bad credentials (401)

> install_github
function (repo, username = NULL, ref = "master", subdir = NULL,
auth_token = github_pat(quiet), host = "https://api.github.com",
quiet = FALSE, ...)
      <Snip - snip>
}
<environment: namespace:devtools>

> github_pat(1)
[1] "bf<snip><snip>88"

> github_pat

function (quiet = FALSE)
{
pat <- Sys.getenv("GITHUB_PAT")
   <snip - snip>
return(NULL)
}
<environment: namespace:devtools>

> Sys.getenv("GITHUB_PAT")
[1] "bf<snip><snip>88"

> Sys.unsetenv("GITHUB_PAT")
> Sys.getenv("GITHUB_PAT")

[1] ""

> install_github("StatsWithR/statsr")
Downloading GitHub repo StatsWithR/statsr@master
from URL https://api.github.com/repos/StatsWithR/statsr/zipball/master
Installing statsr                     <<< Bob's your uncle

Originally posted by @kanasethu in https://github.com/r-lib/devtools/issues/1566#issuecomment-320504796


倘若尚未有任何猫城筹码,需要新建个猫城新筹码如下。

猫城新筹码01

猫城新筹码02

> lib('usethis')
usethis 
   TRUE 
> create_github_token()
• Call `gitcreds::gitcreds_set()` to register this token in the local Git credential store
  It is also a great idea to store this token in any password-management software that you use
✔ Opening URL 'https://github.com/settings/tokens/new?scopes=repo,user,gist,workflow&description=DESCRIBE THE TOKEN\'S USE CASE'
> edit_r_environ()
• Modify '/home/englianhu/.Renviron'
• Restart R for changes to take effect
> rstudioapi::restartSession()
englianhu commented 1 year ago
sudo su - -c "R -e \"devtools::install_github('wrathematics/Rdym')\""
sudo su - -c "R -e \"devtools::install_github('gaborcsardi/praise')\""
sudo su - -c "R -e \"remotes::install_github('csgillespie/rprofile')\""
sudo su - -c "R -e \"remotes::install_github('jalvesaq/colorout')\""
sudo su - -c "R -e \"devtools::install_github('mpiktas/midasr')\""
sudo su - -c "R -e \"devtools::install_github('onnokleen/mfGARCH')\""
sudo su - -c "R -e \"devtools::install_github('business-science/tibbletime')\""
sudo su - -c "R -e \"devtools::install_github('DavisVaughan/furrr')\""
sudo su - -c "R -e \"devtools::install_github('lchiffon/REmap')\""

目前再通过终端安装如上,即可顺利安装R程序包。如果猫城筹码尚在,只需要更新一下,如下。

> lib('devtools')
> lib('tidytuesdayR') ## tidytuesdayR::github_pat(1)
> github_pat(1)
[1] "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"
> Sys.getenv("GITHUB_PAT")
[1] "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"
> Sys.unsetenv("GITHUB_PAT")
> Sys.getenv("GITHUB_PAT")
[1] ""