灌水成绩
等级头衔
ID : 1
管理员
积分成就
威望 : 8
点
贡献 : 9 次
下载币 : 397 枚
在线时间 : 1837 小时
注册时间 : 2013-9-5
最后登录 : 2026-7-26
安装 bundler 报错: ( Y( X1 c1 o: h
. K7 ^# v6 H" \# g2 @0 ^1 [
0 T& ~ q# q- R9 c6 q0 L+ A: L: z / P0 w' ]& Y2 R8 ^( H1 ^
ERROR: Could not find a valid gem 'bundler' ( = 1.17 . 3 ) , here is why:
* E$ |* p) p" ? 1 W5 f4 y- g, N
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 )
7 Y' y0 i" b1 U- I # R: ]8 B2 f1 \' J9 u, c
) u/ k- p* C7 s# T$ f2 v7 r
S4 O) V! {# E! R- [# p4 R
1.添加国内源: ) C: f& j% E) e( g# W
- r( _7 j+ G& ]' | $ v; m! ^9 N8 K
+ {5 j5 A Y+ G4 p' ]2 y gem sources --add https ://gems.ruby-china.com/ --remove https://rubygems.org/
; b4 Z" y* |7 ?3 R' p* H 6 W" N. B; U+ T: S
, @8 j( r4 M8 ^$ v2 o) R y 4 ^1 P" l3 C/ y% F
注意:如果之前自己瞎捣鼓已配置过源,建议先清理: * M k& X3 j% r; ]+ F4 F, e, r* H6 d
- a9 k: w- k& R
4 E1 @2 r4 J# G/ Y8 r 2 _/ {* x. `7 t* X! X8 x
gem sources --remove https ://rubygems.org/ . x4 n, e1 ?( _; i1 A# A6 Q
/ O0 d" L2 o$ p* Z4 U+ d
gem sources --add https ://gems.ruby-china.com/ ( d+ a5 T/ x4 D# a/ a, M2 `$ e+ Q
9 A$ U- H' K. C. T# d1 l% R
S+ z0 a3 t) B8 Y: A2 i- v$ [
* \. z5 ^3 B4 U6 W 2.验证当前源: 1 |3 J, o' N, d7 U2 i
8 {5 @) t9 l4 ^' l' Y: P( M
( } f- ~( [/ i3 @
6 b1 s4 ]+ j% L- g* B$ D
gem sources -l : ^) o3 ]) x+ b- p( q
7 B6 o/ _& ~: }' `: ~ 3 {+ q) X: {& V3 L; _6 B7 ]9 r
6 n1 u" Q2 b- `* S2 i |1 A
应该显示:
! h# F8 y/ y }* Q' X% m - y! |$ N% L; P, l
1 o* P9 h9 q. Y/ C 1 W" A, z& I" C U( m
*** CURRENT SOURCES ***
& U$ j. e1 N/ G6 C
9 p- L: z) N" j7 n: }* I https ://gems.ruby-china.com/ ! G4 ?6 ]) B6 G2 A$ y
1 t4 [/ o! y& L+ u' C$ i Q7 X7 o' z' e
5 h7 m5 y3 Z0 F% v6 R6 E % C/ ~8 h$ k$ N% T2 _% X
3.安装 bundler:
8 J0 ]7 Y' S% O* Q
1 `' b7 y8 ?& s4 S 9 M1 X; {6 C" L. |0 t* k, `7 K# X
- I6 R( @! j* j gem install bundler -v 1.17 . 3 N5 Q) k( z6 o2 c7 Y* `$ @$ V# u5 M; b
8 ^& X- Z! S% b # t8 q$ q* k! ?- ^5 k# x
# f9 _3 ^( q j+ ? 或离线安装(下载 .gem 文件):
- Y1 y6 _/ b* p! F6 A# Y : I* c0 ]+ ^2 i, h J j0 R( f Y4 s; s
: v0 T" `8 S4 ?& z/ z% z
: ^: m: V1 M2 L6 N gem fetch bundler -v 1.17 . 3 6 H8 J2 k, t# ?- F
- O) Y3 f" T/ }4 B D
. P {) |- F. A3 l w! e
, m# p# h9 Y( M8 u" P. y" F 本地安装:
' |3 a/ p$ R) Y* Z; ~# u% P
# y u, l+ X1 o: s, e( y
1 g4 v+ P$ w" [ 9 U/ L1 [. \& P' l% c
gem install ./bundler- 1.17 . 3 . gem 0 E* h$ m9 F: M0 Q, X x
3 e S r- r7 V9 r. q 4 h/ I- l9 m5 b! [3 N+ Q" r& q
) I/ v. ?) N; \1 ]% B 安装完成后运行:
3 m1 T* `/ S$ m$ F" C" M; Q
2 } b* D. Q4 ^: m& g ( y) @: i# H: y5 M& a" T3 J! e
# E$ D0 y1 }- w6 `) L( Q" z bundle -v 8 g& i* D$ I2 w
0 | Y( v4 f. v9 N7 C$ Y' D2 p' U * M: r% B: d8 v) S% U [ `3 E
' o3 y* [( ?* D/ U5 R1 F 应输出:
, u" ^( L" N# b- O 6 b: s2 W) U' A. Y- ~8 M* ~
2 {; n6 g" T. k/ d" N * k! o. e) {+ { o8 e
Bundler version 1.17 . 3 5 L+ \% s' f! C# W. J+ P( N
2 x# H7 N7 G' x1 D0 B7 v, B; o
2 {3 K: T$ @& r! \/ T7 X - s9 c0 X5 B0 g: O
到这里环境已经安装成功! 安装依赖并启动:
; o+ z$ c* R( G1 ]( o, `
7 D; a5 O: c p' G2 t0 f ) I7 e c4 Y% l, h8 ]
- f' p& e' n" u( x% B cd /home/root/dldl-gm && sh restart-alpha. sh
5 X1 o& ?( |2 K5 B- Y4 g, \ " Y* h3 _1 M* R/ K- Y; k$ F" \
8 ^2 g6 w. ^% F' t" |
! \3 i! ^4 {# P' g: A 会报错如下:
1 l/ R- v( b6 h; g) G8 V
# |* d$ Z- q+ J+ P0 y
; {& n, j' r$ d 1 U% q1 k' Y9 u
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this
, r: W3 q0 `" ^- p6 h " S7 n7 H8 v0 j' \! H6 i
application for all non-root users on this machine.
! Q0 j4 l/ a6 i- j6 n: |2 G& }7 o $ d' Q+ ]0 M/ W2 d1 m
Fetching source index from http ://rubygems.org/
& C' x) [ E) T* @+ G9 H4 W) X1 ]
/ F- Y& P! w8 j/ M/ c/ k# r& @ u 9 _/ U, m- Y9 y& I# T7 z- l4 |
' }7 h# X% `# z! K
Retrying fetcher due to error ( 2 / 4 ) : Bundler::HTTPError Could not fetch specs from http ://rubygems.org/ , b4 i2 L+ `$ j/ {( C i) r! g) m ]
. N+ J$ f0 \) `$ d4 A2 c
Retrying fetcher due to error ( 3 / 4 ) : Bundler::HTTPError Could not fetch specs from http ://rubygems.org/
/ |' s# N! R' s$ k9 h i ! b/ X; a5 H0 u& R8 y( w
+ d1 H6 W; u+ \# v' h# x( M6 b
7 @6 h& W* A/ S. r; \7 }2 H
解决方案一: 全局配置 Bundler 使用 Ruby China 镜像(HTTPS) - {* E4 Q- O0 D) n; b$ V# q- p0 n3 w
6 T& I: x% ?( X- V1 i
' ?0 F$ l, _% c2 L : d" {9 T. T" b% H
bundle config set --global mirror. http ://rubygems.org https://gems.ruby-china.com # G( l R: [$ }8 p! Z8 E
- ^5 y+ z' w1 {7 J% O( D
bundle config set --global mirror. https ://rubygems.org https://gems.ruby-china.com ( E2 N! C' w: z+ M
/ V1 a5 ]& f8 F8 G7 y* q' G
7 o* k( M; o; G) p' B5 A
8 h* U' U8 s- f- i 验证配置:
. G% r1 W7 H9 a2 o* u/ {
7 p6 J3 j }7 E
/ ^7 o/ g/ @& F! J; G/ a. y+ I
& R% l& t( N9 A: @: U% L, [# L5 W bundle config list 8 P; s/ a( t) D' g! I8 h! M3 v
+ I; F: y+ m9 f/ v8 I1 `, v) f% u : E& Z: ]& S* l" n4 M
% R% k$ u# K& `) @ 应看到类似:
! H$ t. g* X% K. {# ^: s) P
- c' a- q7 ~, s7 V5 X: C 0 b. o: m) J G- `& E; ^$ D2 P
5 D7 H* ^: r# }; j9 ?) O1 `8 ] Settings are listed in order of priority. The top value will be used. 5 n9 i0 S. U' \; W2 e' _
$ W# v4 G: v6 n X/ ^ mirror. http ://rubygems.org
* y$ s8 \" x6 k: ^8 ~' | 9 `, O8 v4 C# |2 i/ x# t
Set via BUNDLE_MIRROR__HTTP ://RUBYGEMS__ORG: "https://gems.ruby-china.com" - A: S* k" r. a) x. k( K7 c6 v( P
% ]! n" T" T6 d! i
mirror. https ://rubygems.org
8 H ?8 E" {" f: g% V3 | 3 F w$ R& @3 x; k+ q
Set via BUNDLE_MIRROR__HTTPS ://RUBYGEMS__ORG: "https://gems.ruby-china.com" ) h& R5 x% G) U1 E2 n8 g% y
3 H# B. e- P7 [5 M, V8 K% u: _ : g5 `4 Q- F8 N) `2 t
3 R$ U( o1 D1 r0 R 这会把所有对 rubygems.org 的请求(无论 HTTP/HTTPS)都重定向到 https://gems.ruby-china.com 解决方案二:
) \$ e7 \# g3 j# j: n8 S
5 m9 C( n3 W1 |2 q( N% l : @ w2 V' P; v- h
+ L+ V" c6 A! C" Y' z" j 打开:/home/root/dldl-gm/Gemfile和Gemfile. lock
5 j7 V' Q' l T. h
. W% x% R+ Q, O+ C5 ^/ M# d
, R+ I. W M) J . V9 ]- S) p' R$ K5 R& Y
1 {4 o3 ^& J- J, x
4 f( x u& A7 w+ ^% T! b 4 X2 q9 b; K) s6 D" M# E
+ f X- v C8 U
把文件里面的:http ://rubygems.org/ 改为 https://gems.ruby-china.com/
! [) `6 H; f, G; O) e d2 {
* W0 k7 r* n, \. W0 ?# q0 ~ + _: _# r9 X2 ^ I' f0 B
& l0 [# M8 k" u# g; a4 c$ l+ Q
重新安装依赖并启动:
; s. V4 B" O( w( ?8 t+ b 9 Q6 f* |& L* V4 c1 N
* n# X% \6 i5 |1 V( G
( n( n1 {9 f3 y# ~* Q
cd /home/root/dldl-gm && sh restart-alpha. sh
5 V2 I8 U7 M+ R 2 h5 M. y0 o0 X" Z% e- Y
# q! [: ^3 }- j2 n- _0 Z) e
8 P7 I: k9 u3 Z9 _, @4 c% F; [1 G 应看到类似: V u8 B# V3 X+ ~+ @
q, n; Z6 o* w" `4 \+ H, R
# B3 _. g, a4 _5 J4 }) e ) ]$ F: T+ D* M( H* i
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this
0 J* S( K! [ C. |$ X9 W8 y
) G( _1 ]& z8 {$ ~6 p( v9 a0 f! m5 X application for all non-root users on this machine. , ^/ a8 ]; Z( H: n, T
) X% C# X5 Z9 v; Z1 I5 b4 _
Fetching gem metadata from https ://gems.ruby-china.com/.......... % V* _" [) q( H+ B
~+ e2 m5 h" s1 y9 B; k Fetching rake 12.3 . 1 ' v+ S- h$ U" G5 `# Q8 b8 _+ _
9 c( X0 P3 B# Z. h2 [8 f$ ~; a; e Installing rake 12.3 . 1 6 y' C# z& i* U
6 y1 I0 v X2 C' C5 w- K, _
Fetching concurrent-ruby 1.0 . 5
5 f* @ d7 s1 C1 z ' O8 s! i8 b8 Z" Q5 I T+ V
0 g& C- o( X& o" c& W1 n( @
' ~6 W: e, G( ]# [1 u; T 恭喜您,这就是已经在正常安装依赖了!
' z& m, n/ e& X6 ~# W+ V& b9 [