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

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

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

[复制链接]
灌水成绩
19011
118
19588
主题
帖子
积分

等级头衔

ID : 1

管理员

积分成就 威望 : 8
贡献 : 9
下载币 : 434
在线时间 : 1943 小时
注册时间 : 2013-9-5
最后登录 : 2026-9-9

发表于 2026-4-23 21:32:19 | 显示全部楼层 |阅读模式 IP:广东东莞
免责
安装 bundler 报错:' B% X7 |3 @) p5 L5 j# t
0 }. |% _& G$ h

% x  k% k/ ?& t- \2 y9 y' I. b# ~  w! j8 H) p: M* w
ERROR: Could not find a valid gem 'bundler' (= 1.17.3), here is why:
- z5 T1 o0 o: H/ N
& X1 K# ^. P+ E" Y3 w
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 O1 |3 A5 X0 ]+ T8 l- D2 i3 q5 ^
2 i! f2 n: q. h) n3 Q

' i+ \- ]1 {2 m$ k' K

; G  p1 K1 t$ g1.添加国内源:7 ^+ W0 m# e1 L9 b$ Z- y9 I
( m. h" i9 t2 X' {5 \8 h
5 i( h! u8 @+ g/ V% j' j2 v* c
! |1 d2 L$ |2 s
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/1 [1 n1 ?3 t8 R5 H6 O

& B6 |( g! r( \

  m. X7 e( |% n  F( M  b+ L  @; B" w' w5 K
; O% d, y) D  P6 l& {, {- ^
注意:如果之前自己瞎捣鼓已配置过源,建议先清理:
6 l$ R" O2 @7 A6 y2 \6 A6 ?
% t" ^' C1 s5 m! q/ C$ V$ b( R0 c- `( X0 F: L6 t+ z5 y) k
# h" e' S' \5 x; ~
gem sources --remove https://rubygems.org/1 U: ^0 |: q. I& O# w3 m

: E, w4 u8 l3 B8 u6 r0 [; Agem sources --add https://gems.ruby-china.com/. z1 h" K+ }. J, R2 @7 T/ A
3 O- n% _+ I4 s

4 ?+ O: W& t, v6 \; \  g
2 i4 m7 R* [. b0 b
2.验证当前源:
1 q8 L+ I" I1 G: l4 U( X, h* }6 e6 U' n+ O4 J9 D8 o

; I( J9 K7 ^1 B* i: }- K$ ]2 I0 w4 p& O( M/ [% u+ @
gem sources -l6 B3 C6 q  ^: c* Q8 o7 V+ R7 d0 \

2 j  }4 h( t4 ]( q; Z/ b

; {; Z5 h8 ]" y1 K& k9 P

0 I: x# |& n. [8 b/ b9 q应该显示:
6 v1 e, H0 N3 P" T& d) ~& l3 `7 K* h' Q$ z' g) v. @& b" N9 N) O3 x
& p% |. a) ?% I" r, f, i" h! E
8 u# G, d3 I# y9 Y3 J  ?% `
*** CURRENT SOURCES ***
* K+ `( U; R: w* `- v1 L4 i
  K1 S/ ]% @( W. I5 n5 Z! G
https://gems.ruby-china.com/
5 I' d4 N, c3 k3 R9 G

* ]0 s& L% X5 }( Z$ U. Q2 p; k1 K; c

8 s! F) i# `' I5 A
* m( l7 c" ~: f- V7 x
3.安装 bundler:% ]9 x% h; K- ?: \( m
# J* m- E1 A5 f$ v2 I
6 b) \/ H# H. u* O, n- |& E- u

' k! q8 R9 @, _  t5 J) F+ hgem install bundler -v 1.17.3
2 l: Q8 t6 t8 Y+ w2 C7 r2 `; e

. ^0 q6 `% u' n3 O& h& u
. c6 A$ K7 D- E% p$ [1 S( g/ U

$ d' t7 X/ D3 a或离线安装(下载 .gem 文件):6 ~' m) n; Q, L

- C- r! Q+ F! g- e. r! F
' r" D9 A! n% ?
, @3 N# ]7 D4 H' T$ n; ]1 h0 g/ |gem fetch bundler -v 1.17.3/ c' p9 |* T: R% F

0 r. c6 b) U2 J, ?- k" @, }

. t" ]; I8 B' s- c" ~1 Y

2 S8 S8 k5 n) J" _/ k本地安装:  ?2 i- v; D9 q( }' Q+ k
' @* j, W- d! E2 ^0 D
5 q, n9 q' d% t# S; z  {( [2 X+ l
) T# h! u, p2 A1 e* Q7 j
gem install ./bundler-1.17.3.gem) p& F4 Y! t9 Q# L# l

; Z2 v  X8 {% h( q
3 v, G3 E# i4 A& z$ B
. D7 q9 f% c2 p- [$ Q
安装完成后运行:( `! F3 }9 ?, B: Z0 v/ A  s, u) O
$ J4 o$ Q6 t$ F; D2 T

8 }6 j0 K0 P% S. b' Y/ z" A" W% l: r+ v, M/ f0 B4 q4 f/ w
bundle -v
+ V* z  S- h* D& i* e. e. M: Q% p2 S& k
* N/ F3 _) J1 J6 d! I

. d: E. g7 }- I! ]- N

9 k  b5 ~" X' Z9 V# U# S+ W应输出:7 ]% O2 F7 A. H) @7 N( {
7 |0 x) _: k$ A, c% g; a9 |" H& I
- a' _2 z  j6 C, N7 s0 E, r
' ?$ J2 B: m# Q: _' ~
Bundler version 1.17.32 Q" D8 n  J* q. Y1 h
$ J; ]% j. L/ ]

; o* a# F0 d7 f& q( A; G
, Z& i+ x/ T( b8 p# R4 Y# G
到这里环境已经安装成功!安装依赖并启动:
0 ~9 W" E  T+ n4 }6 Z9 k4 L: \3 a9 Q4 {. v/ G$ g

5 h2 r( f, Z8 t/ F
3 y* U9 v8 Y* e7 l5 ^. u5 pcd /home/root/dldl-gm && sh restart-alpha.sh
( l: P' B3 Y0 ~3 w9 u; F
% }  a7 B# s9 G( C8 r. `

  ]' {. B- N& N" _  o/ ?+ ]' x% d7 ^

& G2 O0 B$ X- }# |5 C' S0 V3 f. u* h会报错如下:0 x: R( f' U0 A' t
& k& }/ ]/ b* ^0 U7 H/ H# u) [; y! H
1 Z. B) Z  Z) y( }( ~
* z5 Q  i9 p+ l* _  o& ^. A# }* a- b
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this5 o  F) {: S7 c
0 _+ |+ `- p$ \* x# }+ e
application for all non-root users on this machine.
2 h- l7 e$ n& U" X5 s% k

8 m0 w+ O3 L! p3 r" a2 bFetching source index from http://rubygems.org/( E. ]0 a" P; Z- p0 p
% @9 w8 t, \. D, h( X1 a$ K$ Y
. T# X. A; \. @% y" e

7 u. z( y) b# O: O0 h9 HRetrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from http://rubygems.org/2 n! W4 H, j* a/ B- b+ w" r, e7 K
2 |; I% q  U1 @% V4 E  }8 J! h8 B
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from http://rubygems.org/
" ]  T: q5 O  Y/ e- Z! j, b. J& G

" D2 R1 M/ N! k: F9 h
5 d: w/ X6 K! f- E  d+ ~

$ e& U  x$ M0 D& S7 F解决方案一:全局配置 Bundler 使用 Ruby China 镜像(HTTPS)8 \) B( N- b# V( w1 n

% i3 l; h- D1 I& Q4 e8 |5 I7 H7 H6 Q% Q8 b: U/ P; l. K
& @# e! r2 ]3 D0 {& }
bundle config set --global mirror.http://rubygems.org https://gems.ruby-china.com% i; X6 T8 O; v% M

$ `, g% w# _0 \1 ?6 z4 Ybundle config set --global mirror.https://rubygems.org https://gems.ruby-china.com3 C# i) j/ L, S7 V1 y8 n* Z

7 x. j4 _; J7 Q3 u

$ n$ k0 r+ J" n5 |7 A/ V
+ f' h: q6 z: {2 T# z
验证配置:
1 S* w* R6 ]; O- R6 q4 l( l( i/ j
2 c4 c' Q5 K  Z
" y# {. N4 W, ?+ j
bundle config list9 |' F4 H) x2 c* o# G. ?& E1 l. I
+ ^8 G7 @/ J7 g# o$ ^6 n7 c
( Q( ?0 t' R9 y* O- F3 m
9 s: u8 m- i: a0 }
应看到类似:
0 a" _1 p/ q+ `% j: i; l* _- B- j* d
$ ?" K' v+ l- e" A5 A  N: R
0 P# k; q$ G$ r* K& ?1 j
Settings are listed in order of priority. The top value will be used.
# H5 S" w& {' ]  N/ F$ ~
+ x8 k4 |4 P1 C) o' M
mirror.http://rubygems.org
( \0 o3 K+ O8 G' P$ g

4 g# h2 [# M5 B2 vSet via BUNDLE_MIRROR__HTTP://RUBYGEMS__ORG: "https://gems.ruby-china.com"
  o0 @- g, o5 @" O

: {8 r/ R5 M0 a' L. O2 rmirror.https://rubygems.org: \% ^0 X1 y" v! L8 n/ A

3 b# S" Q; O, o1 ~' S" z) [$ c5 [Set via BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG: "https://gems.ruby-china.com"6 W0 M* f, T1 }
3 i/ V) o6 a! \& X% t
! x2 m% [9 [9 F( y1 l
& T) D) k$ B1 |) H1 P
这会把所有对 rubygems.org 的请求(无论 HTTP/HTTPS)都重定向到 https://gems.ruby-china.com解决方案二:
+ l( L* ~9 I8 @4 a9 H
& q3 q6 T, s/ f" d5 R
- H  C4 i+ h& v& {$ H6 _! T5 ]$ K$ e) J- Y7 Z3 A. I5 d2 U" }
打开:/home/root/dldl-gm/Gemfile和Gemfile.lock5 P1 A2 S+ _/ j; H, D
0 E4 S) L/ g+ W( m* {
0 {$ }9 Z! [2 T* G
1 Q* I: X' n- R0 D
* l7 V" L1 ^: }% p
# P: j$ T) @+ I- r2 I3 F
0 _; W5 ]3 K2 d3 o  h

+ C( N0 n% _3 X0 p1 L+ U把文件里面的:http://rubygems.org/ 改为 https://gems.ruby-china.com/
) b; g" Y) f* c2 f& o+ i
" v" D- T9 y2 ^; i# N

& I% U7 [3 K. G' H- q$ d
. x( x* J% V% ?8 r! ~% m* N. k
重新安装依赖并启动:
& ?3 d* X$ n" p7 m' L* k: Q) }, t( E

& `, k7 |' b9 f! t# c! N* [& C8 [' G% p( N
cd /home/root/dldl-gm && sh restart-alpha.sh# o) @+ |3 g# }0 K

0 U8 ^! z# a+ c& r% W8 ?* j- _
, Y+ p, _" h' a- {! E  Y- a

. I* }) V/ c& W+ [. q应看到类似:
4 C: \- n, H& _- Q+ V8 J" F3 r* D! X
2 ^6 W/ V9 o1 o+ W% k: C5 g

) h- w2 y: q/ z' u' |2 W) yDon't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this" b: ?" f" g7 _- s4 ~

/ S: B5 Q+ `6 Iapplication for all non-root users on this machine.
& U3 F: `8 y0 e! K9 k" Y

7 i1 @- y& O: ?Fetching gem metadata from https://gems.ruby-china.com/..........! s" {( d4 d4 H' U2 n. d

- U: H) i- d& }7 z$ f* KFetching rake 12.3.1
2 ^; ]+ {* X8 A) K  G5 u3 n
& a: X7 x' e, f& S3 R
Installing rake 12.3.1) H$ Q4 Q* g3 [3 |: n7 W1 S

) S, u% Z, }* u- D3 T9 |; NFetching concurrent-ruby 1.0.5
! [: V& h) A' E- }# `

0 w2 z, O  P& \0 ~$ W% k% s+ g8 ~

7 {6 \7 T$ W2 x' ^8 H) ~, N% Q

  F" q5 M) G4 `恭喜您,这就是已经在正常安装依赖了!/ f7 V  Z2 ^4 M/ B+ t
免责
帖子地址打造全网最多免费游戏网站
今日来客 列表模式
本月有问题处理时间8:00-12:00上夜班  9.7发布
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-9-9 09:28

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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