platformio / platformio-vscode-ide

PlatformIO IDE for VSCode: The next generation integrated development environment for IoT
https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide
Apache License 2.0
1.18k stars 188 forks source link

Does not work in Github Codespaces #2665

Open Glavin001 opened 2 years ago

Glavin001 commented 2 years ago

Problem

When opening PlatformIO Home:

image

VSCode extension appears to load from 127.0.0.1 instead of the GitHub Codespaces URL.

Solution

Check for CODESPACES=true and CODESPACE_NAME environment variables.

Applicable Code

I think this comes from:

let _HTTP_HOST = '127.0.0.1';

I'll try to fork and contribute when I can. Any advice would be greatly appreciated!

ivankravets commented 2 years ago

You can change this value in settings. See screenshot below

Screen Shot 2021-09-02 at 12 41 02
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. Please provide more details or it will be closed if no further activity occurs. Thank you for your contributions.

pwnept commented 2 years ago

Any updates or plans for this?

yhur commented 1 year ago

Hi @ivankravets

The #4431 may be slightly different from this, but may be hopefully resolved by the resolution for this issue.

For the clarification, what I did was

  1. installed the code-server on RPi
  2. Downloaded the PIO from marketplace and uploaded to RPi
  3. Accessed the code-server with Safari
  4. Installed the PIO manually with the VSIX file
  5. Restarted the code-server

And as I stated, I can use the PIO/code-server to develop for esp8266 Arduino successfully. That's great and thank you for that. This seems the core part of PIO is working.

What's missing is the PIO Home pages. I changed the HTTP_HOST to 0.0.0.0 also, but the PIO home page is not coming.

I always appreciate the work of you and your team. Thanks.

neilenns commented 1 year ago

I just hit this as well, and I expect others will now that Codespaces is generally available in the free tier of GitHub.

mikethebee commented 1 year ago

I just hit this as well, and I expect others will now that Codespaces is generally available in the free tier of GitHub.

As GitHub have been prompting me to try Codespaces/VSC and I normally use PIO locally on a separate linux box, I have just come across the this issue too. Changing host in setting times out rather than refused when using 127. on a PC within a Chrome Browser. Any suggestions?

konkrog commented 1 year ago

Also came across this issue trying to use PlatformIO on Github CodeSpaces... any fixes planned for this?

ghost commented 1 year ago

Any fixes planned for this?

Bob2345de commented 2 months ago

Any solutions for this?

bilogic commented 2 weeks ago
  1. On my code-server's terminal, I see this process running python -m platformio -c vscode home --port 45334 --host 127.0.0.1 --session-id xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --shutdown-timeout 3600 --no-open
  2. It is listening only to 127.0.0.1 of the server, but the VSCode on our client is trying to connect to the client's 127.0.0.1 and there-in lies the problem
  3. @ivankravets Can the python command be configured from VSCode?

Thanks!

bilogic commented 2 weeks ago
Screen Shot 2021-09-02 at 12 41 02

After changing this to the process's machine's IP address, and restarting the machine, it now runs as python -m platformio -c vscode home --port 45334 --host 172.1.1.1 --session-id xxxxxxxxxxxxxxxxxxxxxxxxxx --shutdown-timeout 3600 --no-open

And now, clicking on PlatformIO's PIO Home > Open gives me a blank page instead of the error. From my client, I was able to connect to the IP and port and confirm it runs a HTTP server.

So, on my terminal, I ran pio home, and this opened up a new browser tab in my client which now shows the usual PIO Home page.

Question now is, can PIO also upload to my client's COM5: much like how ESPHome https://web.esphome.io/ is able to flash a chip via browser (Chrome)?

bilogic commented 2 weeks ago

Here are my conclusions:

  1. Executing pio home runs a process like this python /home/dv1/.platformio/penv/bin/pio home and the port is automatically captured by code-server on the server and forwarded to the client, that is the reason why I was able to load the usual PIO Home page in my client's browser
  2. I believe a fix is needed to get code-server to also automatically forward the port after PIO starts the python -m platformio -c vscode home --port 45334 --host 172.1.1.1 --session-id xxxxxxxxxxxxxxxxxxxxxxxxxx --shutdown-timeout 3600 --no-open process
  3. As far as I can tell, PIO currently cannot upload to the client's com ports (this is a show stopper), would need to see how ESPHome does it
  4. I'm not sure if codespaces/vscode.dev allow us to start a python process on their servers, so it might never be possible to run PIO there, but uploading compiled firmware to any client connecting to code-server via Chrome is likely possible