0%

bundle install 引发的报错问题

最近将 Mac 系统和 Xcode 更新到了最新的版本,Mac 系统为 macOS Catalina 10.15.1,Xcode 最新版本为11.2.1。当我 pod install 后报错如下:

1
2
3
 wdy  ~/Desktop/workspace/peoject  pod install
Could not find proper version of cocoapods (1.7.5) in any of the sources
Run `bundle install` to install missing gems.

再执行 bundle install

1
2
3
4
5
6
7
8
9
10
11
12
 ✘ wdy  ~/Desktop/workspace/peoject  sudo bundle install
Password:
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.
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.

Fetching source index from https://gems.ruby-china.org/

Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://gems.ruby-china.org/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://gems.ruby-china.org/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://gems.ruby-china.org/
Could not fetch specs from https://gems.ruby-china.org/

还是报错,难道我的 gem 源不对?去官网看了之后,发现已经由原来的 https://gems.ruby-china.org/ 改成了 https://gems.ruby-china.com/,命令如下:

1
2
3
4
5
6
7
✘ wdy  ~/Desktop/workspace/peoject  gem sources --add https://gems.ruby-china.com/ --remove https://gems.ruby-china.org/
source https://gems.ruby-china.com/ already present in the cache
source https://gems.ruby-china.org/ not present in cache
wdy  ~/Desktop/workspace/peoject  gem sources -l
*** CURRENT SOURCES ***

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

再执行 bundle install 还是报同样的错,忘了还需要设置 bundle config

1
bundle config mirror.https://gems.ruby-china.org https://gems.ruby-china.com

以上配置好了之后,执行 bundle install 会报另外一个错,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 wdy  ~/Desktop/workspace/peoject  sudo bundle install
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.
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Fetching gem metadata from https://gems.ruby-china.com/........
Fetching CFPropertyList 3.0.1
Installing CFPropertyList 3.0.1
Using concurrent-ruby 1.1.5
Using i18n 0.9.5
Fetching minitest 5.8.5
Installing minitest 5.8.5
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 4.2.11.1
Using public_suffix 2.0.5
Using addressable 2.7.0
Using atomos 0.1.3
Fetching babosa 1.0.3
Installing babosa 1.0.3
Using bundler 1.17.2
Fetching claide 1.0.3
Installing claide 1.0.3
Using fuzzy_match 2.0.4
Using nap 1.1.0
Fetching cocoapods-core 1.7.5
Installing cocoapods-core 1.7.5
Using cocoapods-deintegrate 1.0.4
Using cocoapods-downloader 1.2.2
Using cocoapods-plugins 1.0.0
Using cocoapods-search 1.0.0
Using cocoapods-stats 1.1.0
Using netrc 0.11.0
Fetching cocoapods-trunk 1.4.0
Installing cocoapods-trunk 1.4.0
Using cocoapods-try 1.1.0
Using colored2 3.1.2
Using escape 0.0.4
Using fourflusher 2.3.1
Using gh_inspector 1.1.3
Using molinillo 0.6.6
Using ruby-macho 1.4.0
Using nanaimo 0.2.6
Fetching xcodeproj 1.12.0
Installing xcodeproj 1.12.0
Fetching cocoapods 1.7.5
Installing cocoapods 1.7.5
Using colored 1.2
Using highline 1.7.10
Using commander-fastlane 4.4.6
Using declarative 0.0.10
Using declarative-option 0.1.0
Using digest-crc 0.4.1
Using unf_ext 0.0.7.6
Using unf 0.1.4
Using domain_name 0.5.20190701
Using dotenv 2.7.5
Using emoji_regex 1.0.1
Fetching excon 0.67.0
Installing excon 0.67.0
Using multipart-post 2.0.0
Using faraday 0.15.4
Using http-cookie 1.0.3
Using faraday-cookie_jar 0.0.6
Using faraday_middleware 0.13.1
Fetching fastimage 2.1.7
Installing fastimage 2.1.7
Using jwt 2.1.0
Using memoist 0.16.0
Using multi_json 1.13.1
Using os 1.0.1
Using signet 0.11.0
Using googleauth 0.6.7
Using httpclient 2.8.3
Using mime-types-data 3.2019.0904
Using mime-types 3.3
Using uber 0.1.0
Using representable 3.0.4
Using retriable 3.1.2
Using google-api-client 0.23.9
Using google-cloud-env 1.2.1
Using google-cloud-core 1.3.1
Using google-cloud-storage 1.16.0
Fetching json 2.2.0
Installing json 2.2.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0/ext/json/ext/generator
/Users/wdy/.rvm/rubies/ruby-2.6.0/bin/ruby -I /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0 -r
./siteconf20191204-12343-1w3gnyc.rb extconf.rb
creating Makefile

current directory: /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.bundle
ld: warning: directory not found for option '-L/usr/local/opt/libksba/lib'
ld: warning: directory not found for option '-L/usr/local/opt/libksba/lib'
ld: warning: directory not found for option '-L/usr/local/opt/libksba/lib'

current directory: /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0/ext/json/ext/generator
make "DESTDIR=" install
make: /usr/local/opt/coreutils/bin/gmkdir: No such file or directory
make: *** [.sitearchdir.-.json.-.ext.time] Error 1

make install failed, exit code 2

Gem files will remain installed in /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0 for
inspection.
Results logged to
/Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0/json-2.2.0/gem_make.out

An error occurred while installing json (2.2.0), and Bundler cannot continue.
Make sure that `gem install json -v '2.2.0' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
fastlane-plugin-firim was resolved to 0.2.0, which depends on
firim was resolved to 0.2.1, which depends on
fastlane was resolved to 2.131.0, which depends on
json

好像是安装 json 2.2.0 的时候失败了,需要单独安装一下,那就按提示来,执行命令如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  wdy  ~/Desktop/workspace/peoject  sudo gem install json -v '2.2.0' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.

current directory: /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0/ext/json/ext/generator
/Users/wdy/.rvm/rubies/ruby-2.6.0/bin/ruby -I /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0 -r ./siteconf20191204-12556-140ytz4.rb extconf.rb
creating Makefile

current directory: /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.bundle
ld: warning: directory not found for option '-L/usr/local/opt/libksba/lib'
ld: warning: directory not found for option '-L/usr/local/opt/libksba/lib'
ld: warning: directory not found for option '-L/usr/local/opt/libksba/lib'

current directory: /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0/ext/json/ext/generator
make "DESTDIR=" install
make: /usr/local/opt/coreutils/bin/gmkdir: No such file or directory
make: *** [.sitearchdir.-.json.-.ext.time] Error 1

make install failed, exit code 2

Gem files will remain installed in /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/gems/json-2.2.0 for inspection.
Results logged to /Users/wdy/.rvm/rubies/ruby-2.6.0/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0/json-2.2.0/gem_make.out

还是失败,在第23行给的错误提示 /usr/local/opt/coreutils/bin/gmkdir 这个目录找不到,网上查了之后,需要用 brew 安装 coreutils,执行命令:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  wdy  ~/Desktop/workspace/peoject  brew install coreutils
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/coreutils-8.31.catalina.bottle.1.tar.gz
==> Downloading from https://akamai.bintray.com/72/7262e4c76483ea796454db828c25955be1e6b2bc8e056ba1dd6e92bfe1118da5?_
######################################################################## 100.0%
==> Pouring coreutils-8.31.catalina.bottle.1.tar.gz
==> Caveats
Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
==> Summary
🍺 /usr/local/Cellar/coreutils/8.31: 476 files, 9.2MB
==> `brew cleanup` has not been run in 30 days, running now...

成功之后再去安装那个 json,完整的命令如下:

1
2
3
4
5
6
7
8
 wdy  ~/Desktop/workspace/peoject  sudo gem install json -v '2.2.0' -n /usr/local/bin/
Password:
Building native extensions. This could take a while...
Successfully installed json-2.2.0
Parsing documentation for json-2.2.0
Installing ri documentation for json-2.2.0
Done installing documentation for json after 1 seconds
1 gem installed

最后再去执行 bundle install 就没有报错了。