[Ruby On Rails] nokogiri 설치 시 에러 해결법

 


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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
root@5393:~/programming/ruby/my_blog# 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 is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 11.2.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.9.0
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using pkg-config 1.1.7
Using rack 1.6.4
Using mime-types-data 3.2016.0521
Using arel 6.0.3
Using debug_inspector 0.0.2
Using byebug 9.0.5
Using coffee-script-source 1.10.0
Using execjs 2.7.0
Using thor 0.19.1
Using concurrent-ruby 1.0.2
Using multi_json 1.12.1
Using libv8 3.16.14.15
Using bundler 1.11.2
Using ref 2.0.0
Using sass 3.4.22
Using tilt 2.0.5
Using spring 1.7.2
Using sqlite3 1.3.11
Using turbolinks-source 5.0.0
Using rdoc 4.2.2
Using tzinfo 1.2.2
Installing nokogiri 1.6.8 with native extensions
 
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
 
    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20170701-6593-1pwqi3e.rb extconf.rb
Using pkg-config version 1.1.7
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
 
Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
        --help
        --clean
        --use-system-libraries
        --enable-static
        --disable-static
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --enable-cross-build
        --disable-cross-build
 
To see why this extension failed to compile, please check the mkmf.log which can be found here:
 
  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/mkmf.log
 
extconf failed, exit code 1
 
Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.6.8 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out
Using rack-test 0.6.3
Using mime-types 3.1
Using binding_of_caller 0.7.2
Using coffee-script 2.4.1
Using uglifier 3.0.0
Using sprockets 3.6.3
Installing therubyracer 0.12.2 with native extensions
 
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
 
    current directory: /var/lib/gems/2.3.0/gems/therubyracer-0.12.2/ext/v8
/usr/bin/ruby2.3 -r ./siteconf20170701-6593-15nql70.rb extconf.rb
checking for main() in -lpthread... yes
creating Makefile
 
To see why this extension failed to compile, please check the mkmf.log which can be found here:
 
  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/therubyracer-0.12.2/mkmf.log
 
current directory: /var/lib/gems/2.3.0/gems/therubyracer-0.12.2/ext/v8
make "DESTDIR=" clean
 
current directory: /var/lib/gems/2.3.0/gems/therubyracer-0.12.2/ext/v8
make "DESTDIR="
compiling accessor.cc
make: g++: Command not found
Makefile:207: recipe for target 'accessor.o' failed
make: *** [accessor.o] Error 127
 
make failed, exit code 2
 
Gem files will remain installed in /var/lib/gems/2.3.0/gems/therubyracer-0.12.2 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/therubyracer-0.12.2/gem_make.out
Using turbolinks 5.0.0
Using sdoc 0.4.1
Using activesupport 4.2.6
An error occurred while installing nokogiri (1.6.8), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.8'` succeeds before bundling.
root@5393:~/programming/ruby/my_blog# gem uninstall nokogiri
ERROR:  While executing gem ... (Gem::InstallError)
    nokogiri is not installed in GEM_HOME, try:
        gem uninstall -i /usr/share/rubygems-integration/2.3.0 nokogiri
root@5393:~/programming/ruby/my_blog# xcode-select --install
xcode-select: command not found
root@5393:~/programming/ruby/my_blog#
root@5393:~/programming/ruby/my_blog#
root@5393:~/programming/ruby/my_blog# gem uninstall nokogiri
ERROR:  While executing gem ... (Gem::InstallError)
    nokogiri is not installed in GEM_HOME, try:
        gem uninstall -i /usr/share/rubygems-integration/2.3.0 nokogiri
root@5393:~/programming/ruby/my_blog# xcode-select --install
xcode-select: command not found
root@5393:~/programming/ruby/my_blog# gem install nokogiri
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.
 
    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.0/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20170701-6682-9rdzv7.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.2.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
 
Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
        --help
        --clean
        --use-system-libraries
        --enable-static
        --disable-static
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --enable-cross-build
        --disable-cross-build
 
To see why this extension failed to compile, please check the mkmf.log which can be found here:
 
  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.0/mkmf.log
 
extconf failed, exit code 1
 
Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.8.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.0/gem_make.out
 
cs

위와 같이 오류가 발생하였습니다. 

bundle install 을 하던 중에 nokogiri 에서 생긴 문제인 것 같습니다.


아래의 명령어 두개를 입력해주면 정상적으로 설치가 잘 됩니다. 

1
sudo apt-get install build-essential patch


1
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev



- 출처 -
http://www.nokogiri.org/tutorials/installing_nokogiri.html