Error "Failed to build lzma-" when trying to cabal build Plutus Pioneer Program's Week2 code

Hello everyone, I’m trying to run the command “cabal build” the Week02 code of plutus-pioneer-program but it has this error and I have tried everything but the same error keeps appear:

Failed to build lzma-
Build log (
Configuring library for lzma-
Preprocessing library for lzma-
compiling dist/build/LibLzma_hsc_make.c failed (exit code 1)
rsp file was: "dist/build/hsc2hscall1082370-0.rsp"
command was: /nix/store/d2fqghv083a8q7j8sjb2m5q6i840h691-gcc-wrapper-10.2.0/bin/cc -c dist/build/LibLzma_hsc_make.c -o dist/build/LibLzma_hsc_make.o -D__GLASGOW_HASKELL__=810 -Dlinux_BUILD_OS=1 -Dx86_64_BUILD_ARCH=1 -Dlinux_HOST_OS=1 -Dx86_64_HOST_ARCH=1 -Idist/build/autogen -Idist/build/global-autogen -include dist/build/autogen/cabal_macros.h -I/nix/store/3av3p9ky0lg2f1bc5jgg2sl872z7g4m9-ghc- -I/nix/store/3av3p9ky0lg2f1bc5jgg2sl872z7g4m9-ghc- -I/nix/store/grcf3skqwdw35pki3d0gf7mj0flskni7-gmp-6.2.1-dev/include -I/nix/store/3av3p9ky0lg2f1bc5jgg2sl872z7g4m9-ghc- -I/nix/store/3av3p9ky0lg2f1bc5jgg2sl872z7g4m9-ghc- -I/nix/store/wxb1awkkkbjp26jwqf854488qbzlkk25-libffi-3.3-dev/include -I/nix/store/3av3p9ky0lg2f1bc5jgg2sl872z7g4m9-ghc-
error: LibLzma.hsc:44:10: fatal error: lzma.h: No such file or directory
compilation terminated.

cabal: Failed to build lzma- (which is required by
plutus-pioneer-program-week02- See the build log above for details.

Here are the steps I do:

  1. cd into plutus-apps directory then

$ git checkout 81ba78edb1d634a13371397d8c8b19829345ce0d

You might ask why this commit, because from the tutorial. Then I run

$ nix-shell

  1. Now I’m inside the nix-shell, I cd into plutus-pioneer-program’s Week2 code and then run:

[nix-shell:…/plutus-pioneer-program/code/week02]# cabal update
[nix-shell:…/plutus-pioneer-program/code/week02]# cabal build

That’s all, the error above appears of ‘cabal build’ command. After investigating, I think the error is caused by missing lzma.h, I installed liblzma-dev from https:// cardano.stackexchange .com/questions/6425/lzma-0-0-0-3-missing-when-building-week-01-code (forum doesn’t allow me to post 2 links lul), but the error remains.

Would anyone help me out please? Thank you very much!

Install liblzma-dev does it for me.

I don’t use nix-shell.