6

When compiling supplied code for Plutus Pioneer Program, the haskell extension for VSCode IDE reports a compilation error. This prevents a lot of useful IDE functions from working, because the IDE doesn't analyze an uncompilable file. The code compiles correctly in ghci (cabal repl) and using command line "cabal build"

The error is related to the template Haskell code that is required to write Plutus validators. Error states that a name is not INLINABLE, but it is. I have verified that ghc and haskell-language-server are both using same Haskell compiler (8.10.4.20210212). Does anyone know how to eliminate the error while using VSCode?

related (unanswered) Stack Exchange question: related issue

VSCode screen showing reported error

VSCode screen showing code compiling without in ghc1

Error when running haskell-language-server from command line

source code here

2 Answers 2

3

I found a workaround that is sufficient to get my IDE usable.

**WORKAROUND: ** By comparing the cabal files for Plutus week10 (which compiles OK in IDE) with week07 (error), I discovered that adding the GHC argument -fplugin-opt PlutusTx.Plugin:defer-errors into the ".cabal" file suppressed the error and allowed IDE functions like code completion to work. With this insight, I discovered that this issue had been reported in Plutus Issue 3454 and this workaround described in a Plutus Pull Request.

2
0

I seem to have a partial solution, that wasn't available at the time the question was asked. (I spent a lot of time trying to get my VS Code and HSL to work with a Ubuntu dev container I'd started in July of 2021, but I couldn't get it going. I was trying to get HSL to load the nix environment before building or use nix build instead of the default, but that stuff was over my head.)

Eventually I found the plutus-starter project and the plutus-starter container on IOHK.

Basic solution:

  • clone the plutus-starter repo to local
  • open a new window in VS Code, then open the repo folder.
  • this will ask to open in a devcontainer, click yes
  • this will DL the container from Docker Hub, and create and run it. (will take a while)
  • then in the VS Code terminal, run cabal update and cabal.repl
  • this will take a while to build the project.
  • Cmd-Shift-P and select Reload Window
  • This at least shows me type info on roll over, and will go to definitions and references within the project, and will show compiler errors, and have some code hints, etc.
  • The error at the top of the code file is still there though. The plutus-starter.cabal file has the defer-errors option defined in it, but it's behind a flag, and I'm not sure how to get HSL to set the flag to true and then send it to cabal.
  • I'm also not sure yet how to transfer this to an existing Plutus project. My approach going forward is just clone the plutus-starter repo and make a copy and then start my future projects in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.