Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformIO IDE extension does not work on code-server v3.0.1 from Docker Hub #1448

Closed
r0zzy5 opened this issue Mar 23, 2020 · 27 comments
Closed
Labels
bug Something isn't working extension The issue needs to be fixed in the extension
Milestone

Comments

@r0zzy5
Copy link

r0zzy5 commented Mar 23, 2020

I am trying to install the PlatformIO IDE extension on a code-server v3.0.1 instance hosted in a docker container. I am running Docker Desktop on Windows 10 Pro and accessing code-server using Chrome 80. The extension seems to install fine using the extension manager in code-server, but when I try to open the PlatformIO Home tab, Chrome reports that 127.0.0.1:8010 did not send any data and therefore the PlatformIO Home page is not shown:

PlatformIO error

I am using the following Dockerfile:

FROM codercom/code-server:3.0.1

USER root

RUN apt-get update && apt-get install -y python3 python3-distutils \
	&& rm -rf /var/lib/apt/lists/*

USER coder

EXPOSE 8010

ENTRYPOINT ["dumb-init", "fixuid", "-q", "/usr/local/bin/code-server", "--host", "0.0.0.0", "--auth", "none", "."]

And the following docker-compose.yml:

version: '3.3'
services:
    code-server-platformio:
        image: r0zzy5/code-server-platformio
        ports:
            - '8080:8080'
            - '8010:8010'
        volumes:
            - './src:/home/coder/project'
@x-cubed
Copy link

x-cubed commented Apr 4, 2020

I've had a quick look at this.

platformio starts a server listening on 127.0.0.1:8010. This is because it usually only needs to be accessible on the same machine when running on the desktop. The catch is that this can't be exposed by Docker, as Docker only maps through to non-loopback addresses.

platformio home supports a --host argument to get it to listen on another interface, so it can be started with --host=0.0.0.0 so that it can be exposed by Docker.

Not sure what the right fix is though. Should platformio know that it's running in a server environment, or should there be some special logic in code-server to handle it?

It'd be nice to get it working out of the box without any custom Dockerfiles involved.

@r0zzy5
Copy link
Author

r0zzy5 commented Apr 7, 2020

@x-cubed, I agree it would be best if this could "just work" without any custom Dockerfiles.

However for the time being, where would I configure my platformio home to launch using the --host argument?

@kylecarbs
Copy link
Member

We could fix this with the addition of our #1453 feature.

Thoughts @code-asher ?

@code-asher
Copy link
Member

Yeah, seems like we could just access it at <domain>/proxy/8010. I didn't see an option for changing the URL it tries to open though so I'm not sure how we'd make that work. Maybe it's possible to detect a webview opening on 127.0.0.1:port and change it to the proxy domain instead.

@nhooyr nhooyr added the bug Something isn't working label Apr 17, 2020
@justurn
Copy link

justurn commented May 27, 2020

Just got this to run on my system will leave this for anyone it may help...

In the PIO terminal on code-server use the command 'pio home --host x.x.x.x --port 8010' where x.x.x.x is the IP of the docker then bridge the docker port to the host like @r0zzy5 showed. You should then have access to the PIO webgui through http://y.y.y.y:8010 where y.y.y.y is the docker host IP

@nhooyr nhooyr added extension The issue needs to be fixed in the extension and removed needs-investigation labels Dec 7, 2020
@plckr
Copy link

plckr commented Mar 18, 2021

Any update on this?

@jsjoeio
Copy link
Contributor

jsjoeio commented Mar 19, 2021

@ricreis394 do the solutions above not work for you? If not, we can take a look into this again.

@plckr
Copy link

plckr commented Mar 19, 2021

@jsjoeio when I click to open PlatformIO Home Page, the UI tries to load a frame which is pointer to 127.0.0.1:, which obviously cannot load.

The commands used in command line are as follows:
pio home --host <internal_docker_ip> --port 8010
pio home --host localhost --port 8010

These 2 above loads something, but not completely, using the subsubdomain port like: 8010.code.example.com

@jsjoeio
Copy link
Contributor

jsjoeio commented Mar 19, 2021

Ah okay! Hmm..I am not familiar with PlatformIO.

Would it be possible for you to provide reproduction steps using the latest version of code-server? If you need an example, look at our bug report template.

With that, I'd be happy to take a closer look for you.

@plckr
Copy link

plckr commented Mar 19, 2021

OS/Web Information

  • Web Browser: Google Chrome Version 89.0.4389.90 (Official Build) (64-bit)
  • Local OS: Windows 10
  • Remote OS: linuxserver (maybe alpine?)
  • Remote Architecture: x86-64
  • code-server --version: 3.9.1 e0203f2

Steps to Reproduce

  1. Have subsubdomain reverse proxy configuration for code-server, like <port>.code-server.example.com
  2. Install PlatformIO extension
  3. Go to PlatformIO sidebar section, click PIO Home -> Open

Expected

It should appear the PIO Home webpage

Actual

Appears 127.0.0.1 refused to connect.

Screenshot

platformio

Notes

when I click to open PlatformIO Home Page, the UI tries to load a frame which is pointer to 127.0.0.1:, which obviously cannot load.

The commands used in command line are as follows:
pio home --host <internal_docker_ip> --port 8010
pio home --host localhost --port 8010

These 2 above loads something, but not completely, using the subsubdomain port like: 8010.code.example.com

This issue can be reproduced in VS Code: No

@jsjoeio
Copy link
Contributor

jsjoeio commented Mar 22, 2021

Awesome! Thanks so much for the detailed repro steps @ricreis394 - we'll take a look at this in the next milestone/sprint!

EDIT: meant to tag you @ricreis394😅

@jsjoeio jsjoeio added the needs-investigation This issue needs to be further investigated label Mar 22, 2021
@jsjoeio jsjoeio modified the milestones: v3.9.3, On Deck Mar 22, 2021
@tbhova
Copy link

tbhova commented Mar 23, 2021

+1 to this issue.

The bug mentions a reverse proxy, but I don't think is necessary to repro. I can repro this behind my Traefik reverse proxy or at <server_local_ip>:port. I did not test whether localhost works because my server is headless.

I have a Dockerfile here that installs PlatformIO automatically and reproduces the issue.

@RoboMagus
Copy link

I've been struggling with the same issue for a while as well. What worked for me is quite a blunt method, but I've done a global replace for all occurrences of '127.0.0.1' in the platformio-core directory (/config/.platformio) with '0.0.0.0'.
This together with the exposed 8010 port as in @tbhova's Dockerfile and fixing this port to that value in the platformio-ide settings (Platformio-ide: Pio Home Server Http Port) solved it for me.

Well, I wouldn't like say solved as it's a nuisance that there's no easy interface for setting the ip address to be used for communicating with the pio-core as part of the platformio extension...

@yqboy
Copy link

yqboy commented Apr 23, 2021

There is such a setting option in platformio.platformio-ide-2.3.2/package.json
image

I tried it in docker and it worked

@jsjoeio
Copy link
Contributor

jsjoeio commented Apr 23, 2021

That's awesome to hear - thanks for sharing @yqboy!

@RoboMagus let us know if you get a chance to try using that setting option and see if it fixes your issue

@RoboMagus
Copy link

That setting @yqboy mentions is actually a fix of mine that got merged ;)
I'm working on getting it working behind a reverse proxy as well though...

@jsjoeio
Copy link
Contributor

jsjoeio commented Apr 23, 2021

Oh HA! Totally missed it. Nice :D

Okay well keep us posted.

@utya
Copy link

utya commented Jun 8, 2021

Please explain me, What should i do to config code server with working platformIO. Now i use caddy, and don't know how to configure

@RoboMagus
Copy link

RoboMagus commented Jun 8, 2021

I currently use a Dockerfile as below to ensure the prerequisites are met for installing the PlatformIO plugin.

FROM ghcr.io/linuxserver/code-server

USER root

RUN apt-get update && \
    apt-get install -y --no-install-recommends python3 python3-distutils python3-dev python3-pip curl make && \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Then ensure that the PlatformIO settings in VScode are set correctly. I.e. set the IP to 0.0.0.0 instead of 127.0.0.1, and make the port static. I have it set to 8010. Then make sure this port is exported when starting the docker container (docker run [...] -p 8010:8010 [...]).

Do note though that only one instance can be opened and linked to PIO at any given time, as only one port can be set to static and each new session requires it's own port.

@utya
Copy link

utya commented Jun 8, 2021

@RoboMagus
make like this
docker run -d
--name=code-server
-e PUID=1000
-e PGID=1000
-e TZ=Europe/London
-e PASSWORD=pass #optional
-e HASHED_PASSWORD= #optional
-e SUDO_PASSWORD=password #optional
-e SUDO_PASSWORD_HASH= #optional
-e PROXY_DOMAIN=domain #optional
-p 8443:8443
-p 8010:8010
-e DOCKER_MODS=linuxserver/mods:code-server-python3
-v /home/utya:/config
--restart unless-stopped
ghcr.io/linuxserver/code-server

change to 0.0.0.0, and doesn't work

@rdotts
Copy link

rdotts commented Jun 25, 2021

I'm was experiencing the same issues with effectively the same setup as @utya, except with a compose file. I also tried installing code-server without docker and had similar issues - with enough tinkering I was eventually able to access PIO directly at $LOCAL_IP:8010, but code-server refused to show anything in the extension window.

Just to be clear, my exact symptoms are:

  • Error message "127.0.0.1 refused to connect" when host was set to 127.0.0.1.
  • Black (blank?) frame when set to either $LOCAL_IP or 0.0.0.0
  • Occasionally seeing "Loading..." for a few seconds before the black frame - couldn't pin down what was changing to make that happen.
  • Setting the port to static or dynamic didn't seem to make a difference.
  • I had https enabled and working, and the strict SSL option was set to false.

@camelator
Copy link

any progress? here I have this message at start, don't know if it is related to this issue:
Error: Traceback (most recent call last):
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 69, in
main()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 61, in main
bootstrap()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 47, in bootstrap
pioinstaller.main.main()
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/pioinstaller/main.py", line 131, in main
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/click/core.py", line 1137, in call
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/...

Error: Traceback (most recent call last):
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 69, in
main()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 61, in main
bootstrap()
File "/root/.platformio/.cache/tmp/get-platformio-1.0.3.py", line 47, in bootstrap
pioinstaller.main.main()
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/pioinstaller/main.py", line 131, in main
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/pioinstaller.zip/click/core.py", line 1137, in call
File "/root/.platformio/.cache/tmp/.piocore-installer-ksc1gu9y/tmp65x7o7wh/...

@jsjoeio
Copy link
Contributor

jsjoeio commented Oct 28, 2021

any progress? here I have this message at start, don't know if it is related to this issue:

I am not familiar with this extension or how it works, but if you can write out full repro steps (assume I know nothing...), then I can take a look faster

@chrishdx
Copy link

chrishdx commented Nov 20, 2021

hi, I have found a solution, but I don't use Docker but Ubuntu directly but should be applicable to a Docker container. Since Platformio sits in an iframe it doesn't work properly if it doesn't refer to 127.0.0.1 I used a caddy server as a proxy and in the visx the pio home server starts at 0.0.0.0 but in the iframe it is taken from the package json and referring to https but always +50 ie the Pio server starts on port 8010 but in the iframe there is https: // IP: 8060 / session / so you can refer to 8010 via the caddy file and there is no mixed content. However, I took a static entry for the session key because I use several PCs. With a dynamic one, "Not found" was always displayed

hi, ich habe eine Lösung gefunden allerdings nutze ich keinen Docker sondern direkt Ubuntu sollte aber auf einen Docker Container anwendbar sein. Da Platformio in einen Iframe sitzt funktioniert es nicht richtig wenn es nicht auf 127.0.0.1 verweist ich habe einen Caddyserver als Proxy genutzt und in der visx startet der pio Home Server auf 0.0.0.0 aber im Iframe wird er eintrag aus der Package json genommen und auf https verwiesen jedoch immer +50 d.h. der Pio Server startet auf Port 8010 aber im Iframe steht dann https://IP:8060/session/ so kann man dann über die Caddyfile von 8060 auf 8010 verweisen und es ist kein gemischter Inhalt. Allerdings habe ich beim Sessionkey einen Statischen Eintrag genommen da ich mehrere PC's verwende bei einem Dynamischen kam immer "Not found"

Bildschirmfoto
platformio-ide alpha.zip

@tbhova
Copy link

tbhova commented Apr 10, 2022

My dockerfile posted above has stopped working.

If I connect a terminal to the code-server container and run

cd /usr/lib/code-server
code-server --install-extension platformio.platformio-ide --force

I get the error logs:

Installing extensions...
Extension 'platformio.platformio-ide' not found.
Make sure you use the full extension ID, including the publisher, e.g.: ms-dotnettools.csharp
Failed Installing Extensions: platformio.platformio-ide

It looks like these code-server docs explain why MS' extension marketplace isn't used and suggest Open VSX.

PlatformIO has this tracking issue to add itself to Open VSX.

I'm going to continue following these issues, but I'm likely going to switch to a VSCode VM.

@melwinek
Copy link

Has anyone been able to get PlatformIO running in docker in code-server?

@code-asher
Copy link
Member

code-asher commented Jul 11, 2024

Closing this out since from what I can tell, this is an extension issue? Instead of using 127.0.0.1 I think they need to use asExternalUri or something like that. But if there is something we need to change in code-server let me know and we can reopen.

It reproduces in Codespaces as well, so it does seem to be an issue with the extension and/or VS Code core.

@code-asher code-asher removed the needs-investigation This issue needs to be further investigated label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working extension The issue needs to be fixed in the extension
Projects
None yet
Development

No branches or pull requests