Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building the CLI in WSL2 (Ububtu 2204.2.33.0) #169

Open
magnuspalmblad opened this issue Aug 31, 2023 · 4 comments
Open

Building the CLI in WSL2 (Ububtu 2204.2.33.0) #169

magnuspalmblad opened this issue Aug 31, 2023 · 4 comments

Comments

@magnuspalmblad
Copy link

I get the following error when trying to build the CLI in WSL2:

$ sudo gem install unipept
Building native extensions. This could take a while...
ERROR:  Error installing unipept:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/3.0.0/gems/ffi-1.15.5/ext/ffi_c
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230831-9902-z89lod.rb extconf.rb
checking for ffi.h... *** 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)3.0
        --with-ffi_c-dir
        --without-ffi_c-dir
        --with-ffi_c-include
        --without-ffi_c-include=${ffi_c-dir}/include
        --with-ffi_c-lib
        --without-ffi_c-lib=${ffi_c-dir}/lib
        --enable-system-libffi
        --disable-system-libffi
        --with-libffi-config
        --without-libffi-config
        --with-pkg-config
        --without-pkg-config
        --with-ffi-dir
        --without-ffi-dir
        --with-ffi-include
        --without-ffi-include=${ffi-dir}/include
        --with-ffi-lib
        --without-ffi-lib=${ffi-dir}/lib
/usr/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/lib/ruby/3.0.0/mkmf.rb:613:in `try_cpp'
        from /usr/lib/ruby/3.0.0/mkmf.rb:1124:in `block in have_header'
        from /usr/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
        from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
        from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
        from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
        from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
        from /usr/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
        from /usr/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
        from /usr/lib/ruby/3.0.0/mkmf.rb:1123:in `have_header'
        from extconf.rb:10:in `system_libffi_usable?'
        from extconf.rb:42:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/ffi-1.15.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/3.0.0/gems/ffi-1.15.5 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/ffi-1.15.5/gem_make.out

where the log file contains the following:

$ cat  /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/ffi-1.15.5/mkmf.log
package configuration for libffi is not found
"x86_64-linux-gnu-gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-3.0.0 -I/usr/include/ruby-3.0.0/ruby/backward -I/usr/include/ruby-3.0.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -ffile-prefix-map=/build/ruby3.0-ohOwi0/ruby3.0-3.0.2=. -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-strong -rdynamic -Wl,-export-dynamic     -lruby-3.0  -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

I have the following versions of ruby and gem installed:

$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]

and

$ gem -v
3.3.5

and I have the latest ruby-dev installed as well (1:3.0~exp1).

Any ideas? Has anyone installed unipept in Ubuntu in WSL2 before?

@pverscha
Copy link
Member

pverscha commented Sep 4, 2023

@magnuspalmblad Thank you for reporting this issue. This is probably the result of a Ruby dependency that is not installed on WSL by default. Can you try to perform the following 2 commands?

  1. Install the required dev dependencies for Ruby apt install clang make ruby-dev libffi-dev
  2. Install FFI (which is causing the error): gem install ffi

I don't have a Windows system at my disposal at this time, but I will try this out myself tonight.

@magnuspalmblad
Copy link
Author

Step 1 worked without errors. However, step 2 generates a similar error as when trying to install unipept:

$ sudo gem install ffi
Building native extensions. This could take a while...
ERROR:  Error installing ffi:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/3.0.0/gems/ffi-1.15.5/ext/ffi_c
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230904-10844-j3v4jg.rb extconf.rb
checking for ffi.h... *** 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)3.0
        --with-ffi_c-dir
        --without-ffi_c-dir
        --with-ffi_c-include
        --without-ffi_c-include=${ffi_c-dir}/include
        --with-ffi_c-lib
        --without-ffi_c-lib=${ffi_c-dir}/lib
        --enable-system-libffi
        --disable-system-libffi
        --with-libffi-config
        --without-libffi-config
        --with-pkg-config
        --without-pkg-config
        --with-ffi-dir
        --without-ffi-dir
        --with-ffi-include
        --without-ffi-include=${ffi-dir}/include
        --with-ffi-lib
        --without-ffi-lib=${ffi-dir}/lib
/usr/lib/ruby/3.0.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/lib/ruby/3.0.0/mkmf.rb:613:in `try_cpp'
        from /usr/lib/ruby/3.0.0/mkmf.rb:1124:in `block in have_header'
        from /usr/lib/ruby/3.0.0/mkmf.rb:971:in `block in checking_for'
        from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block (2 levels) in postpone'
        from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
        from /usr/lib/ruby/3.0.0/mkmf.rb:361:in `block in postpone'
        from /usr/lib/ruby/3.0.0/mkmf.rb:331:in `open'
        from /usr/lib/ruby/3.0.0/mkmf.rb:357:in `postpone'
        from /usr/lib/ruby/3.0.0/mkmf.rb:970:in `checking_for'
        from /usr/lib/ruby/3.0.0/mkmf.rb:1123:in `have_header'
        from extconf.rb:10:in `system_libffi_usable?'
        from extconf.rb:42:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/ffi-1.15.5/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/3.0.0/gems/ffi-1.15.5 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/ffi-1.15.5/gem_make.out

The log file has a bit more info:

$ cat /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0/ffi-1.15.5/mkmf.log
package configuration for libffi is not found
"x86_64-linux-gnu-gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-3.0.0 -I/usr/include/ruby-3.0.0/ruby/backward -I/usr/include/ruby-3.0.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -ffile-prefix-map=/build/ruby3.0-ohOwi0/ruby3.0-3.0.2=. -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-strong -rdynamic -Wl,-export-dynamic     -lruby-3.0  -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

I checked, and libffi-dev is installed (the newest version 3.4.2-4).

@pverscha
Copy link
Member

pverscha commented Sep 4, 2023

@magnuspalmblad Thank you for trying this out. I will check this myself tonight and I will get back to you with (hopefully) a solution.

@pverscha
Copy link
Member

I'm sorry for the delay in looking into this issue. I have now had similar reports coming in from other users and found a workaround for using Unipept in WSL (Windows Subsystem for Linux):

  1. Deinstall ruby: sudo apt purge ruby
  2. Install Ruby Version Manager (RVM)
    • gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
    • \curl -sSL https://get.rvm.io | bash
    • source /home/<linux_username>/.rvm/scripts/rvm (replace <linux_username> with your username in WSL)
  3. Install Ruby 3.0 using RVM: rvm install ruby-3.0
  4. rvm use ruby-3.0
  5. Finally, install gem install unipept

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants