unikraft / pykraft

Python library for configuring and building unikernels
Other
177 stars 42 forks source link

Error: `lex: command not found` when running `kraft up` (flex is installed, NixOS) #91

Open WesleyAC opened 2 years ago

WesleyAC commented 2 years ago

Describe the bug

When I run kraft up -p linuxu -m x86_64 -t helloworld kraft-test on NixOS, I get the following error:

 100.00% :::::::::::::::::::::::::::::::::::::::: |       32 /       32 |:  app/helloworld@0.6                                                                                                                     
[INFO    ] Initialized new unikraft application: /home/wesleyac/code/kraft-test/build/kraft-test
make: Entering directory '/home/wesleyac/.unikraft/unikraft'
LN      Makefile
mkdir -p /home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig/lxdialog
make --no-print-directory CC="/nix/store/da9l6ifizmh883j94gzx5n51h8lrrp00-gcc-wrapper-10.3.0/bin/gcc" HOSTCC="/nix/store/da9l6ifizmh883j94gzx5n51h8lrrp00-gcc-wrapper-10.3.0/bin/gcc" \
obj=/home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig -C /home/wesleyac/.unikraft/unikraft/support/kconfig -f Makefile.br /home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig/conf
/nix/store/da9l6ifizmh883j94gzx5n51h8lrrp00-gcc-wrapper-10.3.0/bin/gcc -I. -I/home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig -DCONFIG_=\"\"   -c fixdep.c -o /home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig/fixdep.o
/nix/store/da9l6ifizmh883j94gzx5n51h8lrrp00-gcc-wrapper-10.3.0/bin/gcc -I. -I/home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig -DCONFIG_=\"\"   /home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig/fixdep.o -o /home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig/fixdep
sh: line 1: lex: command not found
make[2]: *** [Makefile.rules:70: /home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig/lexer.lex.c] Error 127
make[1]: *** [/home/wesleyac/code/kraft-test/build/kraft-test/build/Makefile:756: /home/wesleyac/code/kraft-test/build/kraft-test/build/kconfig/conf] Error 2
make: *** [Makefile:984: sub-make] Error 2
make: Leaving directory '/home/wesleyac/.unikraft/unikraft'
[CRITICAL] Could not configure application

I am building on NixOS. I am using poetry to install the staging version of kraft. I have flex in my $PATHwhich flex reports /nix/store/jqgqy1az5x81c4vdgys8q2is5hhhr8ap-flex-2.6.4/bin/flex. I do not have lex in my path, but from reading through the Makefiles, it doesn't seem like a lex binary should be required — ~/.unikraft/unikraft/Makefile sets LEX := flex.

To Reproduce Steps to reproduce the behavior:

  1. Install Nix or NixOS
  2. Run nix-shell -p poetry flex to install poetry and flex
  3. Run poetry init to set up a poetry project.
  4. Add kraft = { git = "https://github.com/unikraft/kraft.git", branch = "staging" } to pyproject.toml and run poetry update and poetry install to install kraft.
  5. Run poetry shell to get a shell where kraft is available.
  6. Run kraft up -p linuxu -m x86_64 -t helloworld kraft-test

My guess is that you could also reproduce this behaviour on other linuxes by removing the symlink from /bin/lex to /bin/flex (or /usr/bin/, as the case may be), but I have not tested that.

Expected behavior

A hello world unikernel is built.

Desktop (please complete the following information):

vladandrew commented 2 years ago

Hi,

I think the lex binary is needed by kconfig[1].

[1] https://github.com/unikraft/unikraft/tree/staging/support/kconfig

WesleyAC commented 2 years ago

Ah, I see — and indeed, adding LEX := flex to the Makefile.rules in that directory appears to fix this problem. Would it be reasonable to upstream that change, or does kconfig rely on the lex compatibility mode somehow?