-2

Using a Windows 10 machine with build 18363 with the Windows Subsystem for Linux installed (Ubuntu 18.04 LTS).

With a goal to install Jekyll, followed the steps mentioned in the documentation (which means to use a repository from BrightBox, which hosts optimized versions of Ruby for Ubuntu) but found a wall when the time to update Ruby gems came.

gem update

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /var/lib/gems/2.5.0 directory.

You don't have permissions

Even though the documentation says so, I thought permissions could be solved with sudo, byt of course it didn't

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

This is the content in gem_mke.out file

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

This is the content of the mkmf.log file

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 */

--------------------
Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145

1 Answers1

2

If you don't want to use sudo for installing gems, you can reinstall ruby for the local user by compiling it from sources, but I have to admit I did not try that. My guess is that this will not fix the cannot find -lzlibwapi error that you encountered.

On my machine, I instead solved the issue by installing two missing libraries (that the second one was missing was only reported after installing the first one):

sudo apt-get install zlib1g-dev libgdbm-dev 

You can then continue the installation of Jekyll, but you again have to insert sudo:

sudo gem install jekyll bundler

Even if you use sudo for installing gems, you can then use Jekyll normally (i.e., without sudo).

When using jekyll, you might run into the "Operation not permitted @ apply2files" error. To prevent this, edit (or create) /etc/wsl.conf and add the appropriate mount options.

Martin J.H.
  • 2,085
  • 1
  • 22
  • 37