IntersectMBO / plutus

The Plutus language implementation and tools
Apache License 2.0
1.57k stars 476 forks source link

Unable to get IDE support in VSCode working #3454

Closed segersb closed 3 years ago

segersb commented 3 years ago

Area

[X] Plutus Foundation Related to the GHC plugin, Haskell-to-Plutus compiler, on-chain code [X] Plutus Application Framework Related to the Plutus application backend (PAB), emulator, Plutus libraries [-] Marlowe Related to Marlowe [X] Other Any other topic (Playgrounds, etc.)

Summary

I'm having troubles setting up VSCode to have code completion while developing with Plutus. The cleanest solution I have tried was to use a fresh Ubuntu VM in VirtualBox and start from the "plutus-starter" project: https://github.com/input-output-hk/plutus-starter

The full error can be found below, here is the start: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable PlutusTx.Eq.$fEqByteString

Steps to reproduce

VM (more than 1 cpu is needed otherwise haskell-language-server hangs) Install Ubuntu Install Docker Install VSCode Install the VSCode Remote Development extension pack

Clone https://github.com/input-output-hk/plutus-starter Execute 'mkdir -p ~/.cabal/packages' Open plutus-starter in VSCode, It will ask if you want to open it in the container, say yes. Execute 'cabal update' in terminal Execute 'cabal install' in terminal Open the file examples/src/Plutus/Contracts/Game.hs in VSCode Click in the file and wait for the processing to be done

Expected behavior

There should be no errors in the IDE since 'cabal build' is successful See the attached screenshot to see the error I get

System info (please complete the following information):

Screenshots and attachments

workspace

Additional context

Note I get the same error message when executing 'haskell-language-server' directly in the terminal.

Complete error message: Program error: GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable PlutusTx.Eq.$fEqByteString [DFunId(nt)] No unfolding Context: Compiling expr: PlutusTx.Eq.$fEqByteString Context: Compiling expr: PlutusTx.Eq.$fEqByteString cast (PlutusTx.Eq.N:Eq[0] _N :: GHC.Types.Coercible (PlutusTx.Eq.Eq Data.ByteString.Internal.ByteString) (Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString -> GHC.Types.Bool)) Context: Compiling expr: (PlutusTx.Eq.$fEqByteString cast (PlutusTx.Eq.N:Eq[0] _N :: GHC.Types.Coercible (PlutusTx.Eq.Eq Data.ByteString.Internal.ByteString) (Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString -> GHC.Types.Bool))) (ds_dqOC cast (Plutus.Contracts.Game.N:HashedString[0] :: GHC.Types.Coercible Plutus.Contracts.Game.HashedString Data.ByteString.Internal.ByteString)) Context: Compiling expr: (PlutusTx.Eq.$fEqByteString cast (PlutusTx.Eq.N:Eq[0] _N :: GHC.Types.Coercible (PlutusTx.Eq.Eq Data.ByteString.Internal.ByteString) (Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString -> GHC.Types.Bool))) (ds_dqOC cast (Plutus.Contracts.Game.N:HashedString[0] :: GHC.Types.Coercible Plutus.Contracts.Game.HashedString Data.ByteString.Internal.ByteString)) (PlutusTx.Builtins.sha2_256 (ds_dqOD cast (Plutus.Contracts.Game.N:ClearString[0] :: GHC.Types.Coercible Plutus.Contracts.Game.ClearString Data.ByteString.Internal.ByteString))) Context: Compiling expr: \ (ds_dqOD [Occ=Once] :: Plutus.Contracts.Game.ClearString) -> (PlutusTx.Eq.$fEqByteString cast (PlutusTx.Eq.N:Eq[0] _N :: GHC.Types.Coercible (PlutusTx.Eq.Eq Data.ByteString.Internal.ByteString) (Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString -> GHC.Types.Bool))) (ds_dqOC cast (Plutus.Contracts.Game.N:HashedString[0] :: GHC.Types.Coercible Plutus.Contracts.Game.HashedString Data.ByteString.Internal.ByteString)) (PlutusTx.Builtins.sha2_256 (ds_dqOD cast (Plutus.Contracts.Game.N:ClearString[0] :: GHC.Types.Coercible Plutus.Contracts.Game.ClearString Data.ByteString.Internal.ByteString))) Context: Compiling expr: \ (ds_dqOC [Occ=Once] :: Plutus.Contracts.Game.HashedString) (ds_dqOD [Occ=Once] :: Plutus.Contracts.Game.ClearString) -> (PlutusTx.Eq.$fEqByteString cast (PlutusTx.Eq.N:Eq[0] _N :: GHC.Types.Coercible (PlutusTx.Eq.Eq Data.ByteString.Internal.ByteString) (Data.ByteString.Internal.ByteString -> Data.ByteString.Internal.ByteString -> GHC.Types.Bool))) (ds_dqOC cast (Plutus.Contracts.Game.N:HashedString[0] :: GHC.Types.Coercible Plutus.Contracts.Game.HashedString Data.ByteString.Internal.ByteString)) (PlutusTx.Builtins.sha2_256 (dsdqOD cast (Plutus.Contracts.Game.N:ClearString[0] :: GHC.Types.Coercible Plutus.Contracts.Game.ClearString Data.ByteString.Internal.ByteString))) Context: Compiling definition of: Plutus.Contracts.Game.isGoodGuess Context: Compiling expr: Plutus.Contracts.Game.isGoodGuess Context: Compiling expr: Plutus.Contracts.Game.isGoodGuess hs Context: Compiling expr: Plutus.Contracts.Game.isGoodGuess hs cs Context: Compiling expr: \ [Occ=Dead] -> Plutus.Contracts.Game.isGoodGuess hs cs Context: Compiling expr: \ (cs [Occ=Once] :: Plutus.Contracts.Game.ClearString) [Occ=Dead] -> Plutus.Contracts.Game.isGoodGuess hs cs Context: Compiling expr: \ (hs [Occ=Once] :: Plutus.Contracts.Game.HashedString) (cs [Occ=Once] :: Plutus.Contracts.Game.ClearString) [Occ=Dead] -> Plutus.Contracts.Game.isGoodGuess hs cs Context: Compiling definition of: Plutus.Contracts.Game.validateGuess Context: Compiling expr: Plutus.Contracts.Game.validateGuess Context: Compiling expr at "main:Plutus.Contracts.Game:(102,8)-(102,46)"

luigy commented 3 years ago

It seems running cabal build from /workspaces/plutus-starter is key in order to reproduce the reported issue. When I first ran this up to cabal update and let Dev Container load the file(it took some time) it got haskell-language-server working properly. I'm waiting on cabal build to finish to see if it changes anything else

luigy commented 3 years ago

cabal build finishing didn't change much with respect to the plugin error. I tried to repro my original behavior with a clean environment as the first run I did, but no luck. Taking a closer look

segersb commented 3 years ago

I tried doing a 'cabal clean' + running the VSCode command 'Haskell: Restart Haskell LSP server', but I still got the error.

FrankC01 commented 3 years ago

I'm having the same issue

franleplant commented 3 years ago

Same issue over here

luigy commented 3 years ago

Fixes have now landed on plutus-starter https://github.com/input-output-hk/plutus-starter/pull/29. Just ensure the flag defer-plugin-errors is enabled. Please reopen if you're still experiencing any problems

Thanks @silky for putting a new release of the container and bumping