user7: After I upgraded my container to the commit from plutus pioneer programm lecture 3 the VsCode server won't spawn anymore in the dev container.
VSCode tells
could not fetch remote environment

Failed to connect to the remote extension host server (Error: WebSocket close with status code 1006)

The console tells something about getaddrinfo ENOTFOUND localhost:
*
* Visual Studio Code Server
*
* Reminder: You may only use this software with Visual Studio family products,
* as described in the license https://aka.ms/vscode-remote/license
*

Extension host agent listening on 38293

[4406 ms] Start: Run in container: echo 38293 >/root/.vscode-server/data/Machine/.devport
[4408 ms] 
[4409 ms] 
[4409 ms] Port forwarding for container port 38293 starts listening on local port.
[4410 ms] Port forwarding local port 38293 to container port 38293
[4421 ms] Port forwarding connection from 65417 > 38293 > 38293 in the container.
[4421 ms] Start: Run: wsl -d Ubuntu -e /bin/sh -c cd '/home/wutze/workspace/plutus-pioneer-program' && DISPLAY='1' ELECTRON_RUN_AS_NODE='1' SSH_ASKPASS='c:\Users\wutze\.vscode\extensions\ms-vscode-remote.remote-containers-0.177.0\scripts\ssh-askpass.bat' VSCODE_SSH_ASKPASS_NODE='C:\Users\wutze\AppData\Local\Programs\Microsoft VS Code\Code.exe' VSCODE_SSH_ASKPASS_MAIN='c:\Users\wutze\.vscode\extensions\ms-vscode-remote.remote-containers-0.177.0\dist\common\sshAskpass.js' VSCODE_SSH_ASKPASS_HANDLE='\\.\pipe\ssh-askpass-32ff11722b3a35f061eaff56993e1deab5d0eea2-sock' DOCKER_CONTEXT='default' VSCODE_SSH_ASKPASS_COUNTER='14' docker 'exec' '-i' '-u' 'root' '-e' 'VSCODE_REMOTE_CONTAINERS_SESSION=c2909e18-9ccb-4e7f-9ffc-a2aed511465e1620332517761' '73ba0ca7a6a532509c5d66df05fbfd39d8174e93661432cdbb28933efd49c768' '/root/.vscode-server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node' '-e' '
[4554 ms] [20:22:02] Extension host agent started.
[4580 ms] Installing extensions...
[4750 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --global credential.helper '!f() { /root/.vscode-server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node /tmp/vscode-remote-containers-b989d5aac79afe5555725461b56f804a3d10bef0.js $*; }; f' || true
[4755 ms] 
[4756 ms] 
[4931 ms] Port forwarding 65417 > 38293 > 38293 stderr: Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
[4932 ms] Port forwarding 65417 > 38293 > 38293 stderr: Remote close with error
[4955 ms] Port forwarding 65417 > 38293 > 38293: Local close
[4956 ms] Port forwarding 65417 > 38293 > 38293 terminated by extension with code 1 and signal null.

Any ideas what's gooing wrong? The commit from lecture 1 worked.
I already checked all hosts files from windows, wsl and the dev-container, all contain the localhost 127.0.0.1 entry.
I also opened a cli in the dev container and startded node with /root/.vscode-server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node and it also fails
> dns.lookup('localhost', {hints: dns.ADDRCONFIG|dns.V4MAPPED}, console.log)
GetAddrInfoReqWrap {
  callback: [Function: log],
  family: 0,
  hostname: 'localhost',
  oncomplete: [Function: onlookup]
}
> Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
    at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:131:14) {
  errno: -3007,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'localhost'

for another hostname it works:
> dns.lookup('www.google.de', {hints: dns.ADDRCONFIG|dns.V4MAPPED}, console.log)
GetAddrInfoReqWrap {
  callback: [Function: log],
  family: 0,
  hostname: 'www.google.de',
  oncomplete: [Function: onlookup]
}
> null 142.250.184.227 4

It is definitly this commit in plutus because if I checkout the one before it suddenly works again:
SHA-1: 5dbd3b833b40217cb1a63d4f52351ae8876ba86c

* adds a non-root user for use in the devcontainer (#2956)

* adds a non-root user for use in the devcontainer

* remove un-needed files

* .cabal folder permissions for volume mapping


user4333: This is a follow-up to the answer from wutzebaer.
The Cardano team has since patched the repository to address the issue.
They did not, however, revert the problem file to its previous working state. Instead they re-introduced the file using a different method and with different contents. Namely, the new nsswitch.conf file only contains hosts: dns file
Apparently, this seems to have solved the problem for many, but there are still some cases where it is failing.
The workaround that wutzebaer posted still works, but I have a few improvements:

The nsswitch.conf file only needs to contain.
hosts: file dns 

Note that the order is file dns, not dns file
The reordering of these properties is the new fix that needs to be made officially.

The nsswitch.conf file should be stored in the project where it can be committed to the repository, not in the user's home directory. In this way, the project remains self-contained and not dependent on any user-specific environment.


The new instructions:

create <project folder>/.devcontainer/nsswitch.conf
with the contents:
hosts: file dns


Update the devcontainer.json to mount the nsswitch.conf in the container.
{
    "name": "Plutus Starter Project",
    "image": "docker.io/inputoutput/plutus-starter-devcontainer:v1.0.10",

    "remoteUser": "plutus",

    "mounts": [
        // This shares cabal's remote repository state with the host. We don't mount the whole of '.cabal', because
        // 1. '.cabal/config' contains absolute paths that will only make sense on the host, and
        // 2. '.cabal/store' is not necessarily portable to different version of cabal etc.
        "source=${localEnv:HOME}${localEnv:USERPROFILE}/.cabal/packages,target=/home/plutus/.cabal/packages,type=bind,consistency=cached",
        "source=${localWorkspaceFolder}/.devcontainer/nsswitch.conf,target=/etc/nsswitch.conf,type=bind,consistency=cached",
    ],

    "settings": {
       // Note: don't change from bash so it runs .bashrc
        "terminal.integrated.shell.linux": "/bin/bash"
    },

    // IDs of extensions inside container
    "extensions": [
        "haskell.haskell"
    ],
}



For bonus points, note that I have also modified the other mount configuration
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.cabal/packages,target=/home/plutus/.cabal/packages,type=bind,consistency=cached"
changing source=${localEnv:HOME}/.cabal/packages
to source=${localEnv:HOME}${localEnv:USERPROFILE}/.cabal/packages
This is because the HOME environment variable is not a standard variable in Windows, although many people may have it defined due to various (often 'nix-like) software installs. Microsoft's recommendation is to pair ${localEnv:HOME}${localEnv:USERPROFILE} since HOME is only valid for Linux and USERPROFILE is only valid for Windows.
In my case, the HOME variable is not defined, so spinning up the container would give me mount errors because it was looking for /.cabal/packages instead of C:\Users\FuzzyLogic/.cabal/packages

user7: Ok, I found the issue, someone removed the nsswitch file here: https://github.com/input-output-hk/plutus/commit/5dbd3b833b40217cb1a63d4f52351ae8876ba86c
The file tells the system to lookup the hosts file, but without the file, it won't.
So, I just opened a my wsl-ubuntu and created the file in my home folder:
vi ~/nsswitch.conf

and put the content
passwd:    files mymachines systemd
group:     files mymachines systemd
shadow:    files

hosts:     files mymachines dns myhostname
networks:  files

ethers:    files
services:  files
protocols: files
rpc:       files

Now, I changed the devcontainer.json so it mounts the file:
{
    "name": "Plutus Starter Project",
    "image": "plutus-devcontainer:latest",

    "remoteUser": "plutus",

    "mounts": [
        // This shares cabal's remote repository state with the host. We don't mount the whole of '.cabal', because
        // 1. '.cabal/config' contains absolute paths that will only make sense on the host, and
        // 2. '.cabal/store' is not necessarily portable to different version of cabal etc.
        "source=${localEnv:HOME}/.cabal/packages,target=/home/plutus/.cabal/packages,type=bind,consistency=cached",
        "source=${localEnv:HOME}/nsswitch.conf,target=/etc/nsswitch.conf,type=bind,consistency=cached",
    ],

    "settings": {
        // Note: don't change from bash so it runs .bashrc
        "terminal.integrated.shell.linux": "/bin/bash"
    },
    
    // IDs of extensions inside container
    "extensions": [
        "haskell.haskell"
    ],
}

Now I'm back in business

7: <p>After I upgraded my container to the commit from plutus pioneer programm lecture 3 the VsCode server won't spawn anymore in the dev container.</p>
<p>VSCode tells</p>
<pre><code>could not fetch remote environment

Failed to connect to the remote extension host server (Error: WebSocket close with status code 1006)
</code></pre>
<p>The console tells something about <code>getaddrinfo ENOTFOUND localhost</code>:</p>
<pre><code>*
* Visual Studio Code Server
*
* Reminder: You may only use this software with Visual Studio family products,
* as described in the license https://aka.ms/vscode-remote/license
*

Extension host agent listening on 38293

[4406 ms] Start: Run in container: echo 38293 &gt;/root/.vscode-server/data/Machine/.devport
[4408 ms] 
[4409 ms] 
[4409 ms] Port forwarding for container port 38293 starts listening on local port.
[4410 ms] Port forwarding local port 38293 to container port 38293
[4421 ms] Port forwarding connection from 65417 &gt; 38293 &gt; 38293 in the container.
[4421 ms] Start: Run: wsl -d Ubuntu -e /bin/sh -c cd '/home/wutze/workspace/plutus-pioneer-program' &amp;&amp; DISPLAY='1' ELECTRON_RUN_AS_NODE='1' SSH_ASKPASS='c:\Users\wutze\.vscode\extensions\ms-vscode-remote.remote-containers-0.177.0\scripts\ssh-askpass.bat' VSCODE_SSH_ASKPASS_NODE='C:\Users\wutze\AppData\Local\Programs\Microsoft VS Code\Code.exe' VSCODE_SSH_ASKPASS_MAIN='c:\Users\wutze\.vscode\extensions\ms-vscode-remote.remote-containers-0.177.0\dist\common\sshAskpass.js' VSCODE_SSH_ASKPASS_HANDLE='\\.\pipe\ssh-askpass-32ff11722b3a35f061eaff56993e1deab5d0eea2-sock' DOCKER_CONTEXT='default' VSCODE_SSH_ASKPASS_COUNTER='14' docker 'exec' '-i' '-u' 'root' '-e' 'VSCODE_REMOTE_CONTAINERS_SESSION=c2909e18-9ccb-4e7f-9ffc-a2aed511465e1620332517761' '73ba0ca7a6a532509c5d66df05fbfd39d8174e93661432cdbb28933efd49c768' '/root/.vscode-server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node' '-e' '
[4554 ms] [20:22:02] Extension host agent started.
[4580 ms] Installing extensions...
[4750 ms] Start: Run in container: command -v git &gt;/dev/null 2&gt;&amp;1 &amp;&amp; git config --global credential.helper '!f() { /root/.vscode-server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node /tmp/vscode-remote-containers-b989d5aac79afe5555725461b56f804a3d10bef0.js $*; }; f' || true
[4755 ms] 
[4756 ms] 
[4931 ms] Port forwarding 65417 &gt; 38293 &gt; 38293 stderr: Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
[4932 ms] Port forwarding 65417 &gt; 38293 &gt; 38293 stderr: Remote close with error
[4955 ms] Port forwarding 65417 &gt; 38293 &gt; 38293: Local close
[4956 ms] Port forwarding 65417 &gt; 38293 &gt; 38293 terminated by extension with code 1 and signal null.
</code></pre>
<p>Any ideas what's gooing wrong? The commit from lecture 1 worked.</p>
<p>I already checked all hosts files from windows, wsl and the dev-container, all contain the <code>localhost 127.0.0.1</code> entry.</p>
<p>I also opened a cli in the dev container and startded node with <code>/root/.vscode-server/bin/cfa2e218100323074ac1948c885448fdf4de2a7f/node</code> and it also fails</p>
<pre><code>&gt; dns.lookup('localhost', {hints: dns.ADDRCONFIG|dns.V4MAPPED}, console.log)
GetAddrInfoReqWrap {
  callback: [Function: log],
  family: 0,
  hostname: 'localhost',
  oncomplete: [Function: onlookup]
}
&gt; Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
    at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:131:14) {
  errno: -3007,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'localhost'
</code></pre>
<p>for another hostname it works:</p>
<pre><code>&gt; dns.lookup('www.google.de', {hints: dns.ADDRCONFIG|dns.V4MAPPED}, console.log)
GetAddrInfoReqWrap {
  callback: [Function: log],
  family: 0,
  hostname: 'www.google.de',
  oncomplete: [Function: onlookup]
}
&gt; null 142.250.184.227 4
</code></pre>
<p>It is definitly this commit in plutus because if I checkout the one before it suddenly works again:</p>
<pre><code>SHA-1: 5dbd3b833b40217cb1a63d4f52351ae8876ba86c

* adds a non-root user for use in the devcontainer (#2956)

* adds a non-root user for use in the devcontainer

* remove un-needed files

* .cabal folder permissions for volume mapping
</code></pre>
 4333: <p>This is a follow-up to the answer from wutzebaer.</p>
<p>The Cardano team has since patched the repository to address the issue.
They did not, however, revert the problem file to its previous working state. Instead they re-introduced the file using a different method and with different contents. Namely, the new <code>nsswitch.conf</code> file only contains <code>hosts: dns file</code></p>
<p>Apparently, this seems to have solved the problem for many, but there are still some cases where it is failing.</p>
<p>The workaround that wutzebaer posted still works, but I have a few improvements:</p>
<ol>
<li><p>The <code>nsswitch.conf</code> file only needs to contain.</p>
<pre><code>hosts: file dns 
</code></pre>
<p>Note that the order is <code>file dns</code>, not <code>dns file</code></p>
<p>The reordering of these properties is the new fix that needs to be made officially.</p>
</li>
<li><p>The <code>nsswitch.conf</code> file should be stored in the project where it can be committed to the repository, not in the user's home directory. In this way, the project remains self-contained and not dependent on any user-specific environment.</p>
</li>
</ol>
<h4>The new instructions:</h4>
<ol>
<li>create <code>&lt;project folder&gt;/.devcontainer/nsswitch.conf</code>
with the contents:
<pre><code>hosts: file dns
</code></pre>
</li>
<li>Update the devcontainer.json to mount the nsswitch.conf in the container.
<pre><code>{
    &quot;name&quot;: &quot;Plutus Starter Project&quot;,
    &quot;image&quot;: &quot;docker.io/inputoutput/plutus-starter-devcontainer:v1.0.10&quot;,

    &quot;remoteUser&quot;: &quot;plutus&quot;,

    &quot;mounts&quot;: [
        // This shares cabal's remote repository state with the host. We don't mount the whole of '.cabal', because
        // 1. '.cabal/config' contains absolute paths that will only make sense on the host, and
        // 2. '.cabal/store' is not necessarily portable to different version of cabal etc.
        &quot;source=${localEnv:HOME}${localEnv:USERPROFILE}/.cabal/packages,target=/home/plutus/.cabal/packages,type=bind,consistency=cached&quot;,
        &quot;source=${localWorkspaceFolder}/.devcontainer/nsswitch.conf,target=/etc/nsswitch.conf,type=bind,consistency=cached&quot;,
    ],

    &quot;settings&quot;: {
       // Note: don't change from bash so it runs .bashrc
        &quot;terminal.integrated.shell.linux&quot;: &quot;/bin/bash&quot;
    },

    // IDs of extensions inside container
    &quot;extensions&quot;: [
        &quot;haskell.haskell&quot;
    ],
}
</code></pre>
</li>
</ol>
<p>For bonus points, note that I have also modified the other mount configuration
<code>&quot;source=${localEnv:HOME}${localEnv:USERPROFILE}/.cabal/packages,target=/home/plutus/.cabal/packages,type=bind,consistency=cached&quot;</code></p>
<p>changing <code>source=${localEnv:HOME}/.cabal/packages</code></p>
<p>to <code>source=${localEnv:HOME}${localEnv:USERPROFILE}/.cabal/packages</code></p>
<p>This is because the HOME environment variable is not a standard variable in Windows, although many people may have it defined due to various (often 'nix-like) software installs. Microsoft's recommendation is to pair <code>${localEnv:HOME}${localEnv:USERPROFILE}</code> since HOME is only valid for Linux and USERPROFILE is only valid for Windows.</p>
<p>In my case, the HOME variable is not defined, so spinning up the container would give me mount errors because it was looking for <code>/.cabal/packages</code> instead of <code>C:\Users\FuzzyLogic/.cabal/packages</code></p>
 7: <p>Ok, I found the issue, someone removed the nsswitch file here: <a href="https://github.com/input-output-hk/plutus/commit/5dbd3b833b40217cb1a63d4f52351ae8876ba86c" rel="nofollow noreferrer">https://github.com/input-output-hk/plutus/commit/5dbd3b833b40217cb1a63d4f52351ae8876ba86c</a></p>
<p>The file tells the system to lookup the hosts file, but without the file, it won't.</p>
<p>So, I just opened a my wsl-ubuntu and created the file in my home folder:</p>
<pre><code>vi ~/nsswitch.conf
</code></pre>
<p>and put the content</p>
<pre><code>passwd:    files mymachines systemd
group:     files mymachines systemd
shadow:    files

hosts:     files mymachines dns myhostname
networks:  files

ethers:    files
services:  files
protocols: files
rpc:       files
</code></pre>
<p>Now, I changed the devcontainer.json so it mounts the file:</p>
<pre><code>{
    &quot;name&quot;: &quot;Plutus Starter Project&quot;,
    &quot;image&quot;: &quot;plutus-devcontainer:latest&quot;,

    &quot;remoteUser&quot;: &quot;plutus&quot;,

    &quot;mounts&quot;: [
        // This shares cabal's remote repository state with the host. We don't mount the whole of '.cabal', because
        // 1. '.cabal/config' contains absolute paths that will only make sense on the host, and
        // 2. '.cabal/store' is not necessarily portable to different version of cabal etc.
        &quot;source=${localEnv:HOME}/.cabal/packages,target=/home/plutus/.cabal/packages,type=bind,consistency=cached&quot;,
        &quot;source=${localEnv:HOME}/nsswitch.conf,target=/etc/nsswitch.conf,type=bind,consistency=cached&quot;,
    ],

    &quot;settings&quot;: {
        // Note: don't change from bash so it runs .bashrc
        &quot;terminal.integrated.shell.linux&quot;: &quot;/bin/bash&quot;
    },
    
    // IDs of extensions inside container
    &quot;extensions&quot;: [
        &quot;haskell.haskell&quot;
    ],
}
</code></pre>
<p>Now I'm back in business</p>
