设为首页收藏本站 国外访客:

 找回密码
 立即注册
搜索
查看: 23151|回复: 0

[教程/工具] 斗罗安装dldl-gm后台bundler环境和依赖报错解决方案

[复制链接]
灌水成绩
19649
120
20243
主题
帖子
积分

等级头衔

ID : 1

管理员

积分成就 威望 : 8 点
贡献 : 9 次
下载币 : 449 枚
在线时间 : 2005 小时
注册时间 : 2013-9-5
最后登录 : 2026-10-25

发表于 2026-4-23 21:32:19 | 显示全部楼层 |阅读模式 IP:广东东莞
免责
安装 bundler 报错:
0 t- _* z0 i4 T# i. q
" t9 w: Q. ~4 r5 E1 g) R/ F' t1 x; s  k
+ t5 I- I3 `* t- I$ T- Q
ERROR: Could not find a valid gem 'bundler' (= 1.17.3), here is why:- F3 ?# ^* @9 P/ s# @( w) @' l8 [
& u; ?* ]3 V  c/ \
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)6 E" M6 `7 q' K+ @. v9 K

9 R5 i' g$ B5 X/ p
* V' ~! t; @0 p- q9 p& Q

% |' Z9 K' S7 j# l5 U9 S  K1.添加国内源:
: E* t& u7 c& L( Q& p0 N- G: r' I
( R: y- S0 _4 l$ F% {  P& \' z  T$ f* e4 d; D
9 C  L+ u5 _7 W
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
/ Q2 e& f" Z+ G* ]

6 E  S3 y5 a! X
% m" U+ Q2 K. ~5 F# K9 u

. ?8 Q7 ^" @3 s. B2 G+ m注意:如果之前自己瞎捣鼓已配置过源,建议先清理:/ h2 v$ L. B: b4 f* X" W1 c

. E. F9 t; C- A* O/ K1 V; e2 n* ~2 m+ K: j
* c! V; m. d  v+ E8 L4 v: S; Z% s* N
gem sources --remove https://rubygems.org/5 j: u8 Y6 M. P
% O$ U7 Q$ W, R( x% m1 d: Q
gem sources --add https://gems.ruby-china.com/# u8 J3 a5 O" c, \  I
. X  u  G% u. ]
: r( N. a% z/ |' x

8 i/ p8 y) B/ d2.验证当前源:9 u; A! k7 p' G, f. J; t

, o# U$ g+ l6 E+ h% T7 T- t& s
3 l- h& x8 r* \+ O1 @
; m8 l8 I/ h5 F$ M! Agem sources -l
( p# F  E- X. A) B3 j: N

1 T, z& a: U2 y; d

8 ]' E! S1 }4 g/ w/ f1 S
& x. ]5 R( m$ G, X+ W9 @( a
应该显示:% W) G' N  V$ h% d9 V2 l

. s+ k* |7 @2 l& R1 U) F: V, H/ b/ }* W
2 o* j0 _' r2 U2 ?% V7 [- u1 }
*** CURRENT SOURCES ***
+ \8 H1 a* p( s5 f. m1 ?
& c2 q. [* E5 B. _) \
https://gems.ruby-china.com/
, l7 _- ~- e. T& U& @
5 q0 B# D7 L# ~
2 Q. ]4 P+ v! m6 D# j7 ^

4 [$ Q" T  w* ?0 r+ o3.安装 bundler:
2 a! r, e: O" s6 ?5 _7 ?# [$ G1 K+ j7 x+ j3 X5 l4 H
% o, N, Q) ?# t" P0 b, J. l% L, L

2 K2 i- T( {5 Ugem install bundler -v 1.17.30 X1 Z! Z' N% s+ U% l
' z0 J6 w& m- ?+ A! l" z& b

: m/ B$ W) Y5 F' w- t9 x- C

+ U, N; G; I0 f5 r# ]或离线安装(下载 .gem 文件):
: @0 H1 u! r! Y+ O. M8 i+ w9 B9 g3 S
& w( n- Z# P1 l: _8 X& h4 ^. V) M% E, @
+ m) U/ G  V9 N' M) L6 c1 r+ D( q( B; ~$ B. P7 o4 {  u
gem fetch bundler -v 1.17.3
0 R' X0 D" l# Z" ]
. x: S! N7 ^1 \8 E% f6 F. B
% e+ i4 P9 s$ D) ~

- ]1 |8 D- p. d本地安装:
& B1 S9 m9 U7 i/ s# P3 n: A% _% F- n+ H! B6 k/ p

0 k4 x0 i5 ]1 l+ m
, u" n5 I& Y' u- j  I, n8 J' ?gem install ./bundler-1.17.3.gem
. |+ s8 Z; y: @  c( {

4 _8 U7 v0 q6 V; ^5 t) ?; s
3 m1 c% x' d% X  U! i4 n9 [7 O

' D+ }4 b. y) w% k+ f- K9 O安装完成后运行:. n" }& w3 |# f& D

+ D. ?* T! k9 {; O0 Y
8 W. L; c# F" C* W) N
! I4 r; D/ z. M4 }7 k3 qbundle -v
0 ^, q0 a8 Y. ]

, Y; j7 {1 F9 {% [+ E, _1 r6 h( P

# [2 i/ |" m. J. C

5 W/ j1 s' M, u3 r# `# ^1 L" I应输出:% S/ D- l) t! ^/ h

, J: {& l9 _6 Z
7 ]( C1 ~) v( ~* {8 A+ V) f5 x6 [, B7 o& {7 i5 E
Bundler version 1.17.3! d) e0 }4 w9 h: ~/ |' [
' l1 K6 e/ j+ f9 R5 M  ?

- c, j- h2 @$ G3 \6 w4 R- `$ L+ g
4 _5 C6 V7 o1 ^" w, w; f
到这里环境已经安装成功!安装依赖并启动:  ], {5 ^) G  i1 a, Y6 t5 ]
; m4 f1 ?3 Q* G; `

, h* o' W% w# y  s' f* Y' M/ t' Q/ d
cd /home/root/dldl-gm && sh restart-alpha.sh
" G( w& A3 L! H+ z& w

/ k% X: s3 B" ?) |! D
: |3 n8 r: g+ @0 y: S

& V# R( o. Z1 N# }8 C3 n; }8 |会报错如下:
/ i* W' e/ E/ ^' a
9 X+ V. _) n" S% N* V4 O8 k1 y8 E2 r% t# S+ [# l
" i& S, C) O& t
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this
7 ?5 T3 o# f5 z0 t; @2 f" T% I

* N9 P/ J5 V8 T0 C8 }application for all non-root users on this machine.5 @  Q; T/ _% E$ n* R$ V9 x/ k' k

6 u- f# o; B3 `  y3 h# \8 uFetching source index from http://rubygems.org/
; m+ u- c1 h  I7 Z
# G( \1 g9 x5 I4 J/ _2 r

9 w+ b2 c' a: ^+ Z4 W$ X$ P

% m' ^: a' x& _; R) SRetrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from http://rubygems.org/
" U5 a) S! b# F, N
* l: K6 o) h( l- _2 O7 R
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from http://rubygems.org/# w! I* K6 }/ ?5 l* g, E

! L7 @: v: e. ?. ^
" E: N& D" i& ]4 f; V+ W* h
, |9 A5 p8 s, B7 K5 N
解决方案一:全局配置 Bundler 使用 Ruby China 镜像(HTTPS)2 B0 A/ X) c2 }3 b2 \) v: }

: n& F# q; K# x* D  R2 l5 l
, X7 T) M" F- ?) E+ i) R% S
! t! Q) x( ?1 r0 a; Obundle config set --global mirror.http://rubygems.org https://gems.ruby-china.com* c5 s0 c. L- _6 _! Y' L/ U
! p. F7 N( ^8 r& c) x
bundle config set --global mirror.https://rubygems.org https://gems.ruby-china.com
. s; Y! I9 e0 L# p5 t
& p& c# L5 ]1 D! R- U$ ]: \

' N% L" O% c5 k0 X* _' l! D0 c7 V

9 C6 y* N9 R, z5 ?验证配置:
* N/ n- X- s$ A7 \5 \& A
. R5 {3 M: k6 N1 R; v/ `4 t' p: b6 H) n' G8 Z8 A, n  h
- u* k$ ?" \  ]
bundle config list) d0 L! \- y2 [+ ]* l
3 e; V0 Y# p& L6 F1 m. R

$ K* y8 r( W  b0 q+ B% K

" t8 [% w; }; W( x应看到类似:9 G) _5 S' ^+ |& W9 ?+ {/ ?+ l

. y) G: k* a  K0 I2 D$ {, p7 A

+ R7 r/ r% X  fSettings are listed in order of priority. The top value will be used.
- B$ |' A; ^- r' C; p7 T
& o) b8 O0 i0 R% o5 [) \
mirror.http://rubygems.org
) b; b3 Y8 j: W) q4 W) ?( w
3 U" ~* V: u; l" M
Set via BUNDLE_MIRROR__HTTP://RUBYGEMS__ORG: "https://gems.ruby-china.com"
! m8 u" G: C* c2 @% l2 I! `, I$ y
% G8 e' E# K, f3 k( n7 e$ P
mirror.https://rubygems.org/ I& q# s1 F5 X0 s) L4 Y% S

( z# n4 h7 @! O  M( R, g* ~Set via BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG: "https://gems.ruby-china.com"& J0 f/ i5 I2 A" Q: j
4 ^  j8 ~' q! Y7 a' f8 P$ M: q% `

; A0 Q% g, K- q3 `
0 N$ [$ u# a. O
这会把所有对 rubygems.org 的请求(无论 HTTP/HTTPS)都重定向到 https://gems.ruby-china.com解决方案二:
! C- M9 Y% H! Q1 d; l5 D8 ?) D0 E/ ?9 H, w' T7 D! u) s6 p

9 W* k% ]& _5 E  M1 O' ]) S0 ]4 I, f" @
打开:/home/root/dldl-gm/Gemfile和Gemfile.lock9 _5 ^! `# u" m' @8 e* Q2 u6 l
7 L! |% ?; ~& o( _( Q+ ]

4 i, p, b" B* `0 w: s' r  G
% v' c/ I8 n! k1 D# T9 H7 \) V) r
+ k; Q$ P3 B  v# J: \' D. r- O
  M$ o# S0 b) m2 Y, \0 A: ]0 U
7 q7 b) K- p5 l. B; r( }
  R0 \+ g+ Z! y) X5 M( h
把文件里面的:http://rubygems.org/ 改为 https://gems.ruby-china.com/
  k! ~: J5 a2 X

( T! y3 C0 A- H" ^4 k8 I# P

, Y" k$ r1 V. y4 T4 K/ L; q" U
9 @( I3 [* j. p/ f! I- q1 q
重新安装依赖并启动:$ p1 L7 Z+ E/ G3 I
4 @5 G2 K: Q5 b" n6 Q3 ?% E& T+ F0 ~
: ^7 @5 o! A, s* f9 u) Y

: `. ^$ J( h1 Z5 W" T3 l2 {% [cd /home/root/dldl-gm && sh restart-alpha.sh( l0 z/ }* h' }) S$ |

  U$ Q+ x2 t% C) M5 g! w0 }

) C" s$ k* _+ U( q) @
2 m& U, E% m8 ^( B0 g  `8 }
应看到类似:4 O9 e3 A2 s8 _4 Y  `0 I

' h* i# r8 m8 Y# J7 d9 t9 |6 S2 X' o+ x
+ v, g' q; q1 g4 c% J! o: R
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this7 v7 K2 p$ N) R: c
  M0 @9 S& ?3 E6 }8 x- U/ A
application for all non-root users on this machine.
) p" l- ?0 E- [1 S1 o$ g; |

0 `' P" `/ p7 O8 F7 o$ T2 c5 VFetching gem metadata from https://gems.ruby-china.com/..........
& U+ D; G0 P7 a; c% a/ |9 c8 [
% a# x1 v! P3 B3 F
Fetching rake 12.3.1
: a& c! o% Z: S  k' d3 k1 }
: P$ j" j& @7 Z
Installing rake 12.3.1
5 Y9 c' g9 n0 \) Q* g

5 Z2 v0 m$ j! a% h& l* UFetching concurrent-ruby 1.0.5
1 m/ y: ?' L0 m! A. x" `6 v2 O1 G

+ |- r9 D. K' D: c
5 j  V5 F' w& R7 e

' K, H& m" }, {恭喜您,这就是已经在正常安装依赖了!( z1 U3 C/ T: `! {8 X7 F& {
免责
帖子地址 打造全网最多免费游戏网站,部分资源失效,私聊站长补
今日访客 列表模式
10月上白班,问题处理时间等晚上
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|蔡州手游 |网站地图

GMT+8, 2026-10-25 11:16

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表