安装 bundler 报错:1 L+ d+ B+ n7 p! { P- o+ p
. G' Y" M Q/ n# n
: i% |! ^9 R5 _4 f7 T# d0 {8 n3 I9 }) w+ D" [; _
ERROR: Could not find a valid gem 'bundler' (= 1.17.3), here is why:% E0 ?" J+ \. c% I
- o) { d5 u f6 n; Z7 c. `+ [2 Q
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) ]9 `' x" {' C) I! g6 V9 C5 G+ E) g8 a
5 `4 c0 s: G0 |# F2 c5 t% T: W 7 B( N" v/ W% e1 L2 E1.添加国内源:3 K3 r! p% l! D! ]! D$ R$ ?2 q
& O7 j4 ]! z& C% a
3 s6 h4 C) A( U3 k* R
m3 V2 q( |# e, e T3 F& r2 V
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ 2 m/ R1 |( ^9 R7 |# o: h! q0 A . c1 `7 w4 p2 a+ `% L; Y# a) k8 S V2 \6 [( P0 |: G
% W9 @: Q0 J% J 注意:如果之前自己瞎捣鼓已配置过源,建议先清理: : p, n1 K3 P G: o/ x, y& N' G1 G* z8 U( d1 K
7 u2 X- G' U! D' A * |- j" k, _0 c3 V. d % w8 q |# I: V, m w* NDon't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this 2 N* Q+ o5 ]) _( R# a. a' y, a% d6 j9 [, v
application for all non-root users on this machine. 7 Q/ {! J# M3 U : P L: `, ^. u' S' O: g$ t# pFetching source index from http://rubygems.org// i$ P' b8 j! B+ p6 B$ ^7 S
1 [6 t I1 ?4 D" K8 i
7 A* B5 x6 l& V2 j% r6 l# U& `7 V' _) _
Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from http://rubygems.org/ " Q; d/ Y6 k; ]0 p* p- v" [; {. q) Q6 |* |3 Z, q+ Z5 e& K
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from http://rubygems.org/ 6 ^3 S' {, V) {4 {/ X- K6 R ; Z+ x% ?6 D7 O% ^1 G 3 f5 U6 R; M. V3 @* W `# m6 T 0 G& J) n) q3 E3 h& D0 e |1 F解决方案一:全局配置 Bundler 使用 Ruby China 镜像(HTTPS)' G: }+ x8 u/ n+ S0 @* k# t
- c+ W9 }* A3 F6 m, c. Y & }' p- {9 F2 p' P6 S' R( b/ v( x9 I; ?6 N% d* ^7 O, \
bundle config set --global mirror.http://rubygems.org https://gems.ruby-china.com* R& P( s. e# T/ u% N( c
8 K. p7 P/ f7 _4 M4 j0 m9 ]
bundle config set --global mirror.https://rubygems.org https://gems.ruby-china.com ) w$ c' i2 L7 B; I. o ] ; y1 L6 E2 h- Y ) \* {+ j* m& j7 s. l ; E+ o/ W" _5 {2 T6 R/ F7 `验证配置: / e: z3 X7 M" i2 @, k: D4 R- x0 v. C3 N
! y, ^- K. Q* ~, {6 B' q ' p( a3 x; D% \8 W! g9 R, I" b( tbundle config list ( f1 T9 |# u; b - j0 I, w, m/ M* w) h2 I & X9 C" B/ G" K! U' Z: ~; e" S j 应看到类似:9 U `/ s3 x4 `
0 G/ y$ a& Z3 |8 j . f% l: B. g) i& V3 p' `! }" s$ Z$ ~ % z6 b8 [2 j8 |% mSettings are listed in order of priority. The top value will be used.$ m, L* |' a6 q# q* w
1 g$ h1 D* N% a# umirror.http://rubygems.org 4 j6 A; V$ B! I. }& i& r7 ], D 6 ^1 Z. J/ v' ]0 O1 Q; i# { rSet via BUNDLE_MIRROR__HTTP://RUBYGEMS__ORG: "https://gems.ruby-china.com"7 k8 P9 N7 Z4 \( p
, V1 e7 W; k/ D6 D
mirror.https://rubygems.org2 S3 C; K. |; y7 c; Y
+ {6 |* Q% {4 v. d3 L
Set via BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG: "https://gems.ruby-china.com" 1 J( A% U" H3 j& B6 x7 i8 c9 k0 e# i8 R ~4 a! h
8 I6 |) I, o9 V" Z
8 S& \9 T/ o1 z. A 这会把所有对 rubygems.org 的请求(无论 HTTP/HTTPS)都重定向到 https://gems.ruby-china.com解决方案二:& R. E" B3 v0 h0 p4 M- x9 u: l
+ n1 W! i3 f9 U6 o; E6 Q
$ e0 X- _! ~% f
$ T: k8 M& Z4 S3 X' q3 F/ v& E
打开:/home/root/dldl-gm/Gemfile和Gemfile.lock( R' D' I3 [2 l& E/ r' e
% Y) g/ v" a! F7 d) \, ^ 7 k$ r( ]0 t5 h6 D& n1 U5 e $ Y d# H, X; P3 K ; X$ ]1 V6 b8 X+ F l& C$ _% K& `' `; |0 E
8 {4 H( s+ d3 B4 Q3 n
; T, E% f8 C" f
把文件里面的:http://rubygems.org/ 改为 https://gems.ruby-china.com/6 r4 E- Z; |- ?( G
0 s6 \ m' c* R
/ o0 q0 W$ v' r+ e" e# G
4 i* D% Q9 d) _+ L% X1 H 重新安装依赖并启动: ) Z- b4 T" Z9 n6 n7 ]) w, d Q: t) |( B- g" s4 p1 I! N! p
6 _3 v" G# R z
J' f, c5 p: w& r' n8 P1 tcd /home/root/dldl-gm && sh restart-alpha.sh5 \' t. ?4 Z( P9 r
5 u: D4 G+ \$ N9 f V d- ^
% A& ~: z0 ^$ A! _6 t) l & l' }0 F: K+ f应看到类似: % _, |/ m+ O: S' o# o) w9 N$ O% j/ D8 V' }# y
# u, R- h6 w. T6 o C; i7 D: }& z6 d' M. u6 g1 q' M+ E, Z
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this : a# K1 y( j+ p G, c" U$ g% }/ e* v7 \. b! R4 g
application for all non-root users on this machine. 5 S, W" C B, f 9 y" |; s: i) V4 `) Y- A, H9 rFetching gem metadata from https://gems.ruby-china.com/..........9 f; ?/ g" h: V" p, Q( L
3 x( w8 K- R- g! u& D. Y
Fetching rake 12.3.1 # E6 {9 Z. y0 z- `- V+ U' j% S& Y+ H5 V, h! ]( n
Installing rake 12.3.1, I' { t! ~( X6 e' t
) |2 v0 ~7 N, e t# ?& p* m; W7 z$ l$ LFetching concurrent-ruby 1.0.5 ) Y M( ]& t7 p( e! }! T 6 b' f6 e8 |+ ]9 B4 F& ?9 v, v' f- `& ]) {4 f7 ?( v0 A