china0396 发表于 6 天前

斗罗安装dldl-gm后台bundler环境和依赖报错解决方案

安装 bundler 报错:



ERROR: Could not find a valid gem 'bundler' (= 1.17.3), here is why:

Unable to download data from https://rubygems.org/ - Errno::ENETUNREACH: Network is unreachable - connect(2) for "api.rubygems.org" port 443 (https://api.rubygems.org/specs.4.8.gz)



1.添加国内源:



gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/



注意:如果之前自己瞎捣鼓已配置过源,建议先清理:



gem sources --remove https://rubygems.org/

gem sources --add https://gems.ruby-china.com/



2.验证当前源:



gem sources -l



应该显示:



*** CURRENT SOURCES ***

https://gems.ruby-china.com/



3.安装 bundler:



gem install bundler -v 1.17.3



或离线安装(下载 .gem 文件):



gem fetch bundler -v 1.17.3



本地安装:



gem install ./bundler-1.17.3.gem



安装完成后运行:



bundle -v



应输出:



Bundler version 1.17.3



到这里环境已经安装成功!安装依赖并启动:



cd /home/root/dldl-gm && sh restart-alpha.sh



会报错如下:



Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this

application for all non-root users on this machine.

Fetching source index from http://rubygems.org/



Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from http://rubygems.org/

Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from http://rubygems.org/



解决方案一:全局配置 Bundler 使用 Ruby China 镜像(HTTPS)



bundle config set --global mirror.http://rubygems.org https://gems.ruby-china.com

bundle config set --global mirror.https://rubygems.org https://gems.ruby-china.com



验证配置:



bundle config list



应看到类似:



Settings are listed in order of priority. The top value will be used.

mirror.http://rubygems.org

Set via BUNDLE_MIRROR__HTTP://RUBYGEMS__ORG: "https://gems.ruby-china.com"

mirror.https://rubygems.org

Set via BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG: "https://gems.ruby-china.com"



这会把所有对 rubygems.org 的请求(无论 HTTP/HTTPS)都重定向到 https://gems.ruby-china.com解决方案二:



打开:/home/root/dldl-gm/Gemfile和Gemfile.lock







把文件里面的:http://rubygems.org/ 改为 https://gems.ruby-china.com/



重新安装依赖并启动:



cd /home/root/dldl-gm && sh restart-alpha.sh



应看到类似:



Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this

application for all non-root users on this machine.

Fetching gem metadata from https://gems.ruby-china.com/..........

Fetching rake 12.3.1

Installing rake 12.3.1

Fetching concurrent-ruby 1.0.5



恭喜您,这就是已经在正常安装依赖了!
页: [1]
查看完整版本: 斗罗安装dldl-gm后台bundler环境和依赖报错解决方案