vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Working with multiple devcontainers cannot start one devcontainer: SyntaxError: Unexpected end of JSON input

Open juanboterotech opened this issue 1 year ago • 6 comments

Trying to use two devcontainers (React and Django) for one project and got an error with each container, found the error previously reported here https://github.com/microsoft/vscode-remote-release/issues/8624

I applied that solution, in my case just changed the local volume in the docker command:

docker run -it --rm -v ~/.vscode-server:/vscode ubuntu rm -rf /vscode/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd/

That works for React devcontainer for a moment, the Django container still shows the error when try to reopen:

 Start: Run in container: cat '/home/vscode/.vscode-server/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd/product.json'
[6011 ms] SyntaxError: Unexpected end of JSON input
        at JSON.parse (<anonymous>)
        at Kz (c:\Users\juanp\.vscode\extensions\ms-vscode-remote.remote-containers-0.362.0\dist\extension\extension.js:225:1273)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async Oue (c:\Users\juanp\.vscode\extensions\ms-vscode-remote.remote-containers-0.362.0\dist\extension\extension.js:221:4028)
        at async Nl (c:\Users\juanp\.vscode\extensions\ms-vscode-remote.remote-containers-0.362.0\dist\extension\extension.js:201:4302)
        at async bpe (c:\Users\juanp\.vscode\extensions\ms-vscode-remote.remote-containers-0.362.0\dist\extension\extension.js:275:6649)
        at async MN (c:\Users\juanp\.vscode\extensions\ms-vscode-remote.remote-containers-0.362.0\dist\extension\extension.js:278:5396)
[6012 ms] /home/vscode

My enviroment is:

  • VSCode Version: 1.89.0
  • Local OS Version: Windows 11
  • Remote OS Version: Ubuntu WSL
  • Remote Extension/Connection Type: Containers/WSL/Server

I have a docker-compose.yml file which define the containers with some services.

version: '3'
services:
  backend:
    container_name: backend
    image: mcr.microsoft.com/devcontainers/python:1-3.9-bullseye
    volumes:
      - .:/workspace:cached
    # Other configuration options for the Python container
    command: sleep infinity
    links:
      - frontend
    environment:
      - TZ=Etc/GMT-5
    networks:
      - mnet

  frontend:
    container_name: frontend
    image: mcr.microsoft.com/devcontainers/typescript-node:0-14
    volumes:
      - .:/workspace:cached
    # Other configuration options for the TypeScript container
    command: sleep infinity
    environment:
      - TZ=Etc/GMT-5
    networks:
      - mnet

  postgres-db:
    container_name: postgres-db
    image: postgres:16
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=dbuser
      - POSTGRES_PASSWORD=dbpwd
      - POSTGRES_DB=mydb
    networks:
      - mnet
    ports:
      - 5432:5432
  rabbitmq:
    container_name: rabbitmq
    image: rabbitmq:3.9
    volumes:
      - rabbitmq-data:/var/lib/rabbitmq
    environment:
      - RABBITMQ_DEFAULT_USER=radmin
      - RABBITMQ_DEFAULT_PASS=rpassword
    ports:
      - 5672:5672
      - 15672:15672
    networks:
      - mnet

volumes:
  db-data:
  rabbitmq-data:

networks:
  mnet:
    driver: bridge

Also, there is a folder called .devcontainer and inside there is two folders, one called backcontainer which has the devcontainer.json file, the same with the other folder called frontcontainer. .devcontainer/backcontainer/devcontainer.json

{
    "name": "Backend",
    "dockerComposeFile": ["../../docker-compose.yml"],
    "service": "backend",
    "shutdownAction": "none",
    "workspaceFolder": "/workspace/backend"
}

.devcontainer/frontcontainer/devcontainer.json

{
    "name": "Frontend",
    "dockerComposeFile": ["../../docker-compose.yml"],
    "service": "frontend",
    "shutdownAction": "none",
    "workspaceFolder": "/workspace/frontend"
}

juanboterotech avatar May 04 '24 06:05 juanboterotech

When i deleted the containers and started again setting up the project, I have no problem with the first devcontainer i choose to run, I mean, after delete and rebuild and open the frontcontainer it runs without problem but the backcontainer fails; and the same when i start the backcontainer first the frontcontainer fails.

juanboterotech avatar May 04 '24 16:05 juanboterotech

Downgrade the VSCode from version 1.89 (April 2024) to version 1.88 (March 2024) and both devcontainers starts. Also I disabled the automatic updates with this method: https://code.visualstudio.com/docs/supporting/FAQ#_how-do-i-opt-out-of-vs-code-autoupdates

juanboterotech avatar May 04 '24 17:05 juanboterotech

I applied that solution, in my case just changed the local volume in the docker command:

docker run -it --rm -v ~/.vscode-server:/vscode ubuntu rm -rf /vscode/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd/

There is a typo in this, it should be -v vscode:/vscode. Can you retry with that?

Make sure you remove the existing containers before retrying.

chrmarti avatar May 06 '24 07:05 chrmarti

I applied that solution, in my case just changed the local volume in the docker command: docker run -it --rm -v ~/.vscode-server:/vscode ubuntu rm -rf /vscode/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd/

There is a typo in this, it should be -v vscode:/vscode. Can you retry with that?

Make sure you remove the existing containers before retrying.

I had to use .vscode-server/ because i don't have vscode folder and inside bin folder and got this error when try ls -l

ls: cannot access '/vscode/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd/': No such file or directory

juanboterotech avatar May 07 '24 01:05 juanboterotech

-v ~/.vscode-server:/vscode mounts the local ~/.vscode-server folder into the container. The Dev Containers extension doesn't use that, removing something there shouldn't affect the outcome. 🤔

Is there a /home/vscode/.vscode-server/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd folder in the container showing the error? Does it have a product.json or any other files and what's in the product.json?

chrmarti avatar May 07 '24 07:05 chrmarti

It seems that devcontainers copy the .vscode-server folder from host to /home/vscode/ folder in the container. When devcontainer fails to start in VSCode IDE the container starts anyway, then I can enter to the container and see its files and so on, but the file /home/vscode/.vscode-server/bin/b58957e67ee1e712cebf466b995adf4c5307b2bd/product.json is empty at that moment, When the first devcontainer is running the product.json has content.

juanboterotech avatar May 07 '24 15:05 juanboterotech

Keep downgraded version 1.89 (April 2024) and worked fine, now updated to 1.90 and got a Segmentation fault problem when try to open the second container: 2951 ms] Start: Run in Host: docker exec -i -u node -e SHELL=/bin/bash -e VSCODE_AGENT_FOLDER=/home/node/.vscode-server -w /home/node/.vscode-server/bin/89de5a8d4d6205e5b11647eb6a74844ca23d2573 f6c256c30cd3ab2c6966c61a93ed0faa4e233d7156807fef19425b26ea9e58c7 /home/node/.vscode-server/bin/89de5a8d4d6205e5b11647eb6a74844ca23d2573/bin/code-server --log debug --force-disable-user-env --server-data-dir /home/node/.vscode-server --use-host-proxy --telemetry-level all --accept-server-license-terms --host 127.0.0.1 --port 0 --connection-token-file /home/node/.vscode-server/data/Machine/.connection-token-89de5a8d4d6205e5b11647eb6a74844ca23d2573 --extensions-download-dir /home/node/.vscode-server/extensionsCache --start-server --disable-websocket-compression --skip-requirements-check [3023 ms] Segmentation fault [3035 ms] Command failed: /home/node/.vscode-server/bin/89de5a8d4d6205e5b11647eb6a74844ca23d2573/bin/code-server --log debug --force-disable-user-env --server-data-dir /home/node/.vscode-server --use-host-proxy --telemetry-level all --accept-server-license-terms --host 127.0.0.1 --port 0 --connection-token-file /home/node/.vscode-server/data/Machine/.connection-token-89de5a8d4d6205e5b11647eb6a74844ca23d2573 --extensions-download-dir /home/node/.vscode-server/extensionsCache --start-server --disable-websocket-compression --skip-requirements-check [3036 ms] Segmentation fault [3036 ms] Exit code 139 [12970 ms] Extensions cache, remote removals: None [72983 ms] Extensions cache, remote removals: None [132992 ms] Extensions cache, remote removals: None

juanboterotech avatar Jun 06 '24 02:06 juanboterotech

@juanboterotech Could you use https://github.com/microsoft/vscode-bisect to find the first VS Code Insiders version that has the segmentation fault?

That tool will start one VS Code Insiders version at a time and you can then check if the segmentation fault occurs and tell the tool the result.

/cc @deepak1556

chrmarti avatar Jun 06 '24 07:06 chrmarti

Was about to try that @chrmarti , before, removed again the vscode-server folder from wsl user home and restart vscode. Now it seem that is working fine.

Thank you.

juanboterotech avatar Jun 06 '24 17:06 juanboterotech