使用安装了 Windows 10 Linux 子系统(Ubuntu 18.04 LTS)的版本 18363 的 Windows 10 机器。
为了安装 Jekyll,请按照文档(这意味着使用来自亮盒,它托管了针对 Ubuntu 的 Ruby 优化版本),但是在更新 Ruby gem 的时候遇到了障碍。
gem update
错误:执行 gem 时...(Gem::FilePermissionError)您没有 /var/lib/gems/2.5.0 目录的写权限。
尽管文档这么说,但我认为权限问题可以用 sudo 来解决,但当然没有
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/zlib-1.1.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.5.0/gems/zlib-1.1.0 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/zlib-1.1.0/gem_make.out
Gems updated: bigdecimal csv date etc fileutils gdbm io-console ipaddr json psych rdoc stringio strscan webrick zlib
这是 gem_mke.out 文件中的内容
current directory: /var/lib/gems/2.5.0/gems/zlib-1.1.0/ext/zlib
/usr/bin/ruby2.5 -r ./siteconf20200312-8262-tpvi49.rb extconf.rb
checking for deflateReset() in -lz... no
checking for deflateReset() in -llibz... no
checking for deflateReset() in -lzlib1... no
checking for deflateReset() in -lzlib... no
checking for deflateReset() in -lzdll... no
checking for deflateReset() in -lzlibwapi... no
*** 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.5
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-zlib
--without-zlib
--with-libzlib
--without-libzlib
--with-zlib1lib
--without-zlib1lib
--with-zliblib
--without-zliblib
--with-zdlllib
--without-zdlllib
--with-zlibwapilib
--without-zlibwapilib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/zlib-1.1.0/mkmf.log
extconf failed, exit code 1
这是 mkmf.log 文件的内容
have_library: checking for deflateReset() in -lz... -------------------- no
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lz -lpthread -lgmp -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘deflateReset’ undeclared (first use in this function)
int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
^~~~~~~~~~~~
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lz -lpthread -lgmp -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void deflateReset();
14: int t(void) { deflateReset(); return 0; }
/* end */
--------------------
have_library: checking for deflateReset() in -llibz... -------------------- no
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -llibz -lpthread -lgmp -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘deflateReset’ undeclared (first use in this function)
int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
^~~~~~~~~~~~
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -llibz -lpthread -lgmp -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -llibz
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void deflateReset();
14: int t(void) { deflateReset(); return 0; }
/* end */
--------------------
have_library: checking for deflateReset() in -lzlib1... -------------------- no
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lzlib1 -lpthread -lgmp -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘deflateReset’ undeclared (first use in this function)
int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
^~~~~~~~~~~~
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lzlib1 -lpthread -lgmp -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lzlib1
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void deflateReset();
14: int t(void) { deflateReset(); return 0; }
/* end */
--------------------
have_library: checking for deflateReset() in -lzlib... -------------------- no
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lzlib -lpthread -lgmp -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘deflateReset’ undeclared (first use in this function)
int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
^~~~~~~~~~~~
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lzlib -lpthread -lgmp -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lzlib
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void deflateReset();
14: int t(void) { deflateReset(); return 0; }
/* end */
--------------------
have_library: checking for deflateReset() in -lzdll... -------------------- no
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lzdll -lpthread -lgmp -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘deflateReset’ undeclared (first use in this function)
int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
^~~~~~~~~~~~
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lzdll -lpthread -lgmp -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lzdll
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void deflateReset();
14: int t(void) { deflateReset(); return 0; }
/* end */
--------------------
have_library: checking for deflateReset() in -lzlibwapi... -------------------- no
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lzlibwapi -lpthread -lgmp -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:13:57: error: ‘deflateReset’ undeclared (first use in this function)
int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
^~~~~~~~~~~~
conftest.c:13:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))deflateReset; return !p; }
/* end */
"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.5.0 -I/usr/include/ruby-2.5.0/ruby/backward -I/usr/include/ruby-2.5.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/ruby2.5-KHV_pi/ruby2.5-2.5.7=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -lruby-2.5 -lzlibwapi -lpthread -lgmp -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lzlibwapi
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: extern void deflateReset();
14: int t(void) { deflateReset(); return 0; }
/* end */
--------------------
答案1
如果你不想使用 sudo 安装 gems,你可以为本地用户重新安装 ruby通过从源代码编译它,但我必须承认我没有尝试过。我猜这会不是修复cannot find -lzlibwapi
您遇到的错误。
在我的计算机上,我通过安装两个缺失的库解决了该问题(仅在安装第一个库后才报告第二个库缺失):
sudo apt-get install zlib1g-dev libgdbm-dev
然后您可以继续安装 Jekyll,但您必须再次插入sudo
:
sudo gem install jekyll bundler
即使您使用sudo
安装 gems,您也可以正常使用 Jekyll(即无需 sudo)。
使用 jekyll 时,您可能会遇到“Operation not allowed @ apply2files”错误。为了防止这种情况,请编辑(或创建)/etc/wsl.conf
并添加适当的安装选项。