<p>It turned out that I was starting the playground server wrong - I was trying to use <code>nix-build</code> inside a nix shell.</p>
<p>What actually works (without any code modifications):</p>
<ul>
<li>server:</li>
</ul>
<pre><code>&gt; nix-shell
&gt; cd plutus-playground-server/
&gt; plutus-playground-server
</code></pre>
<ul>
<li>client:</li>
</ul>
<pre><code>&gt; nix-shell
&gt; cd plutus-playground-client/
&gt; npm start
</code></pre>
<p>I also added <code>allow-import-from-derivation = true</code> to my nix.conf (as <a href="https://github.com/input-output-hk/cardano-node/blob/master/doc/getting-started/building-the-node-using-nix.md" rel="nofollow noreferrer">
cardano-node docs</a> suggest).</p>
<p>My nix.conf is now:</p>
<pre><code>substituters        = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
experimental-features = nix-command flakes
allow-import-from-derivation = true
</code></pre>
<p>Thank you @Fermat for your help :)</p>

CC BY-SA 4.0
2022-04-08T18:46:25.980Z
2022-04-08T18:46:25.980Z
Marek Mizier
<p>I can't compile any of the example scripts using Plutus Playground gui:</p>
<pre><code>Compilation Error, Line 2, Column 1 (jump)
 error:
    Could not find module `Playground.Contract'
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
2 | import Playground.Contract
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation Error, Line 3, Column 1 (jump)
 error:
    Could not find module `Plutus.Contract'
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
3 | import Plutus.Contract
  | ^^^^^^^^^^^^^^^^^^^^^^
Compilation Error, Line 4, Column 1 (jump)
 error:
    Could not find module `PlutusTx.Prelude'
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
4 | import PlutusTx.Prelude
  | ^^^^^^^^^^^^^^^^^^^^^^^
</code></pre>
<p>Looks like all non-standard modules are considered missing (screenshot from playground gui after hitting &quot;Compile&quot;).</p>
<p><a href="https://i.sstatic.net/ECD8N.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ECD8N.png" alt="missing modules" /></a></p>
<p>I'm using Ubuntu 20.04. Here's what I did:</p>
<ol>
<li>Installed nix using <code>sh &lt;(curl -L https://nixos.org/nix/install) --daemon</code> (multi-user installation)</li>
<li>Cloned <code>plutus-apps</code> (latest, currently: dd1678bba97e489dc54f2384a7be81e32659ba76)</li>
<li>Ran <code>nix-shell</code> in <code>plutus-apps</code> dir.</li>
<li>Started playground server inside the nix shell using</li>
</ol>
<pre><code>$(nix-build -A plutus-playground.server)/bin/plutus-playground-server webserver
</code></pre>
<p>and client:</p>
<pre><code>npm start
</code></pre>
<p>At this point gui was running ok, but I was getting errors while trying to compile examples:</p>
<pre><code>ConnectionError (HttpExceptionRequest Request { host = &quot;localhost&quot; port = 8009 secure = False requestHeaders = [(&quot;Accept&quot;,&quot;application/json;charset=utf-8,application/json&quot;),(&quot;Content-Type&quot;,&quot;application/json;charset=utf-8&quot;)] path = &quot;/runghc&quot; queryString = &quot;&quot; method = &quot;POST&quot; proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 proxySecureMode = ProxySecureWithConnect } NoResponseDataReceived)
</code></pre>
<ol start="5">
<li>After some googling/debugging I came up with a solution to connection errors - running the server with:</li>
</ol>
<pre><code>WEBGHC_URL=http://localhost:8081  $(nix-build -A plutus-playground.server)/bin/plutus-playground-server webserver -p 8081
</code></pre>
<p>and changing client configuration in <code>webpack.config.js</code>:</p>
<pre><code>    devServer: {
        contentBase: path.join(__dirname, &quot;dist&quot;),
        compress: true,
        port: 8009,
        https: false, // changed from true due to CA errors
        stats: &quot;errors-warnings&quot;,
        proxy: {
            &quot;/api&quot;: {
                target: &quot;http://localhost:8081&quot;, // port changed from 8080
            },
        },
    },

</code></pre>
<p>After these changes playground at least tries to compile the scripts, but it looks like webghc doesn't see plutus packages.</p>
<p>As I mentioned I'm using Ubuntu 20.04 and ghcup with following tool versions:</p>
<pre><code>✔✔ ghc   8.10.7   recommended,base-4.14.3.0 hls-powered
✔✔ cabal 3.6.2.0  latest,recommended                   
✔✔ hls   1.6.1.0  latest,recommended                   
✔✔ stack 2.7.5    latest,recommended                   
✔✔ ghcup 0.1.17.6 latest,recommended 
</code></pre>
<p>My nix.conf:</p>
<pre><code>» cat /etc/nix/nix.conf

build-users-group = nixbld
substituters        = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
experimental-features = nix-command flakes     
</code></pre>
<p>Does anyone know what I'm missing? Please halp :)</p>
<p>EDIT:</p>
<p>Output of <code>nix-shell</code> command:</p>
<pre><code>» nix-shell                                                                                                                                               130 ↵
trace: To materialize project.plan-nix for cabal-install entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: WARNING: 8.10.5 is out of date, consider using 8.10.7.
trace: haskell-nix.haskellLib.cleanGit: /nix/store/dgp5f75dgadnxvy1mybjky2hm7wyxnpl-cardano-node does not seem to be a git repository,
assuming it is a clean checkout.
trace: To make project.plan-nix for cardano-node a fixed-output derivation but not materialized, set `plan-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.plan-nix for cardano-node entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: WARNING: 8.10.5 is out of date, consider using 8.10.7.
trace: To make project.plan-nix for cardano-node a fixed-output derivation but not materialized, set `plan-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.plan-nix for cardano-node entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: To make project.plan-nix for haskell-project a fixed-output derivation but not materialized, set `plan-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
nix-pre-commit-hooks: hooks up to date
pid 1234077's current affinity list: 0-15
pid 1234077's new affinity list: 0-15
</code></pre>

CC BY-SA 4.0
2022-04-07T06:52:46.177Z
Does your plutus-app checked out commit (dd1678bba97e489dc54f2384a7be81e32659ba76) match your cabal project file dependency declaration of plutus-apps (see tag of repo)?
Will
CC BY-SA 4.0
2022-04-07T09:23:49.200Z
Did you logout and login after installing nix? Your reachable paths where software might needs to be updated after install. If this is the case, just purge the plutus-app directory and git clone it again. Also check when you enter your nix-shell stuff is being pulled from somy hydra.iohk server.
Fermat
CC BY-SA 4.0
2022-04-07T09:37:59.467Z
@William-BerlinPool I'm just trying to get the playground working without any other external projects. (not using plutus-pioneer-program repo atm)
Marek Mizier
CC BY-SA 4.0
2022-04-07T09:45:32.060Z
@Fermat I did log out / log in after installing nix. Running nix-shell (for the first time) downloaded lots of deps from cache. I've pasted output of subsequent runs in the main post. I also tried to run playground using Ubuntu 20.04 on Windows WSL2 with the same result.
Marek Mizier
CC BY-SA 4.0
2022-04-07T12:16:55.760Z
If you would like we can debug it together on the IOHK dev discord channel collaborate room? Just post a message there and Ill contact you :)
Fermat
CC BY-SA 4.0
2022-04-07T13:47:12.443Z
@Fermat I'd love to, but I'm not on that discord. Can you send me a link?
Marek Mizier
CC BY-SA 4.0
2022-04-08T08:25:13.020Z
https://discord.gg/m8pHXMDu is the IOG technical community discord server.
Fermat
CC BY-SA 4.0
2022-04-08T10:14:24.983Z
@Fermat posted in #pioneers-questions
Marek Mizier
<plutus-pioneer-program><plutus-playground>
Can't compile Plutus Playground examples: Could not find module `Playground.Contract' (Ubuntu 20.04)
# Can't compile Plutus Playground examples: Could not find module `Playground.Contract' (Ubuntu 20.04)

(Asked by: username_0 on 2022-04-06)

I can't compile any of the example scripts using Plutus Playground gui:
Compilation Error, Line 2, Column 1 (jump)
 error:
    Could not find module `Playground.Contract'
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
2 | import Playground.Contract
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^
Compilation Error, Line 3, Column 1 (jump)
 error:
    Could not find module `Plutus.Contract'
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
3 | import Plutus.Contract
  | ^^^^^^^^^^^^^^^^^^^^^^
Compilation Error, Line 4, Column 1 (jump)
 error:
    Could not find module `PlutusTx.Prelude'
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
4 | import PlutusTx.Prelude
  | ^^^^^^^^^^^^^^^^^^^^^^^

Looks like all non-standard modules are considered missing (screenshot from playground gui after hitting "Compile").

I'm using Ubuntu 20.04. Here's what I did:

Installed nix using sh <(curl -L https://nixos.org/nix/install) --daemon (multi-user installation)
Cloned plutus-apps (latest, currently: dd1678bba97e489dc54f2384a7be81e32659ba76)
Ran nix-shell in plutus-apps dir.
Started playground server inside the nix shell using

$(nix-build -A plutus-playground.server)/bin/plutus-playground-server webserver

and client:
npm start

At this point gui was running ok, but I was getting errors while trying to compile examples:
ConnectionError (HttpExceptionRequest Request { host = "localhost" port = 8009 secure = False requestHeaders = [("Accept","application/json;charset=utf-8,application/json"),("Content-Type","application/json;charset=utf-8")] path = "/runghc" queryString = "" method = "POST" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.1 proxySecureMode = ProxySecureWithConnect } NoResponseDataReceived)


After some googling/debugging I came up with a solution to connection errors - running the server with:

WEBGHC_URL=http://localhost:8081  $(nix-build -A plutus-playground.server)/bin/plutus-playground-server webserver -p 8081

and changing client configuration in webpack.config.js:
    devServer: {
        contentBase: path.join(__dirname, "dist"),
        compress: true,
        port: 8009,
        https: false, // changed from true due to CA errors
        stats: "errors-warnings",
        proxy: {
            "/api": {
                target: "http://localhost:8081", // port changed from 8080
            },
        },
    },


After these changes playground at least tries to compile the scripts, but it looks like webghc doesn't see plutus packages.
As I mentioned I'm using Ubuntu 20.04 and ghcup with following tool versions:
✔✔ ghc   8.10.7   recommended,base-4.14.3.0 hls-powered
✔✔ cabal 3.6.2.0  latest,recommended                   
✔✔ hls   1.6.1.0  latest,recommended                   
✔✔ stack 2.7.5    latest,recommended                   
✔✔ ghcup 0.1.17.6 latest,recommended 

My nix.conf:
» cat /etc/nix/nix.conf

build-users-group = nixbld
substituters        = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
experimental-features = nix-command flakes     

Does anyone know what I'm missing? Please halp :)
EDIT:
Output of nix-shell command:
» nix-shell                                                                                                                                               130 ↵
trace: To materialize project.plan-nix for cabal-install entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: WARNING: 8.10.5 is out of date, consider using 8.10.7.
trace: haskell-nix.haskellLib.cleanGit: /nix/store/dgp5f75dgadnxvy1mybjky2hm7wyxnpl-cardano-node does not seem to be a git repository,
assuming it is a clean checkout.
trace: To make project.plan-nix for cardano-node a fixed-output derivation but not materialized, set `plan-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.plan-nix for cardano-node entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: WARNING: 8.10.5 is out of date, consider using 8.10.7.
trace: To make project.plan-nix for cardano-node a fixed-output derivation but not materialized, set `plan-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.plan-nix for cardano-node entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: To make project.plan-nix for haskell-project a fixed-output derivation but not materialized, set `plan-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
nix-pre-commit-hooks: hooks up to date
pid 1234077's current affinity list: 0-15
pid 1234077's new affinity list: 0-15

**Tags:** plutus-pioneer-program, plutus-playground
> **Comments:**
> **username_1**: Does your plutus-app checked out commit (dd1678bba97e489dc54f2384a7be81e32659ba76) match your cabal project file dependency declaration of plutus-apps (see tag of repo)?  
> **username_2**: Did you logout and login after installing nix? Your reachable paths where software might needs to be updated after install. If this is the case, just purge the plutus-app directory and git clone it again. Also check when you enter your nix-shell stuff is being pulled from somy hydra.iohk server.  
> **username_0**: @William-BerlinPool I'm just trying to get the playground working without any other external projects. (not using plutus-pioneer-program repo atm)  
> **username_0**: @Fermat I did log out / log in after installing nix. Running nix-shell (for the first time) downloaded lots of deps from cache. I've pasted output of subsequent runs in the main post. I also tried to run playground using Ubuntu 20.04 on Windows WSL2 with the same result.  
> **username_2**: If you would like we can debug it together on the IOHK dev discord channel collaborate room? Just post a message there and Ill contact you :)  
> **username_0**: @Fermat I'd love to, but I'm not on that discord. Can you send me a link?  
> **username_2**: https://discord.gg/m8pHXMDu is the IOG technical community discord server.  
> **username_0**: @Fermat posted in #pioneers-questions  

---

## 1 answers

### Answer by username_0 on 2022-04-08. Score: 1 | Accepted answer

It turned out that I was starting the playground server wrong - I was trying to use nix-build inside a nix shell.
What actually works (without any code modifications):

server:

> nix-shell
> cd plutus-playground-server/
> plutus-playground-server


client:

> nix-shell
> cd plutus-playground-client/
> npm start

I also added allow-import-from-derivation = true to my nix.conf (as 
cardano-node docs suggest).
My nix.conf is now:
substituters        = https://hydra.iohk.io https://iohk.cachix.org https://cache.nixos.org/
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= iohk.cachix.org-1:DpRUyj7h7V830dp/i6Nti+NEO2/nhblbov/8MW7Rqoo= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
experimental-features = nix-command flakes
allow-import-from-derivation = true

Thank you @Fermat for your help :)


---

