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

PlatformIO IDE extension does not work with Remote Development using SSH #942

Open pbolduc opened 4 years ago

pbolduc commented 4 years ago

I am trying to use Remote Development using SSH with PlatformIO IDE. Remote Development using SSH is a preview feature, but would be great if this would work in the future.

https://code.visualstudio.com/docs/remote/ssh

I followed Scott Hanselman's blog to set up my environment, https://www.hanselman.com/blog/VisualStudioCodeRemoteDevelopmentOverSSHToARaspberryPiIsButter.aspx

My use case is I want to develop for the Raspberry PI using C/C++ and to use the awesome Platform IO to managed dependencies and build process.

PlatformIO IDE: 1.8.1

image

ivankravets commented 4 years ago

Could you run in this RPi terminal $ pio home --no-open? Do you see any errors?

pbolduc commented 4 years ago

There are no errors. I get

  ___I_
 /\-_--\   PlatformIO Home
/  \_-__\
|[]| [] |  http://127.0.0.1:8008
|__|____|_______________________

Open PIO Home in your browser by this URL => http://127.0.0.1:8008
PIO Home has been started. Press Ctrl+C to shutdown.

image

pbolduc commented 4 years ago

I had the window open since I took the screen shot above and the PIO Home screen and libraries show up...

ivankravets commented 4 years ago

Ah, yes! It will not work. You run PIO Home Server on the remote machine via SSH where PIO Home Backend points to localhost. You can open PIO Home in your standalone browser via http://your-rpi-ip:8008.

IBlackI commented 4 years ago

Is there any way to have the window in visual studio code point to a remote adress? This is also an issue when using Remote Developent through for example code-server

VishalDhayalan commented 4 years ago

I'm having the same problem when trying to get it to work on the Raspberry Pi. image The PIO home page never loads and I get this error: image

I also noticed the C/C++ extension that PIO depends on throws an error saying ARM is not supported: image

Any fix for this?

piccaso commented 4 years ago

As a workaround for the connection issue adding this to the ssh_config seems to work:

LocalForward 127.0.0.1:8010 127.0.0.1:8010

However, when i created a new Project named 'bpTest' it was created as ~/Documents/PlatformIO/Projects\bpTest where Projects\bpTest is a folder name.

Also C/C++ problem highlighting does not work.

So there is more to it than setting up port forwardung... Edit: After fixing the path manually C/C++ problem highlighting works and I cant find any other issue.

VishalDhayalan commented 4 years ago

As a workaround for the connection issue adding this to the ssh_config seems to work:

LocalForward 127.0.0.1:8010 127.0.0.1:8010

However, when i created a new Project named 'bpTest' it was created as ~/Documents/PlatformIO/Projects\bpTest where Projects\bpTest is a folder name.

Also C/C++ problem highlighting does not work.

So there is more to it than setting up port forwardung... Edit: After fixing the path manually C/C++ problem highlighting works and I cant find any other issue.

I didn't have any ssh problems, but could you please elaborate on how you fixed the path manually? And is this on an ARM architecture (such as the raspberry pi)? Thanks.

Turiok commented 4 years ago

Thx @VishalDhayalan.

Works for me :). In your ssh/config file, The description of your remote, you add the line from @VishalDhayalan : LocalForward 127.0.0.1:8010 127.0.0.1:8010 It'll forward the port between your host and remote. So VScode will displayed on localhost:8010 the localhost:8010 of your VM.

Turiok commented 4 years ago

Sadly, the window appear. But when I want to import a arduino project. I can't display my folder tree than one level.

$ ls -l workspace/
drwxrwxr-x  7 vagrant vagrant 4096 Feb  6 19:20 ESP32
drwxrwxr-x  9 vagrant vagrant 4096 Feb 22 12:28 MQTTnet

platformioError

Even If I want to see the content of folder in /tmp, doesn't work. If I open the webpage from host webbrowser it doesn't work. But If I open the webpage on guest webbrowser, it works

After searching, I found this : https://docs.platformio.org/en/latest/userguide/cmd_home.html#cmd-home Default host option is 127.0.0.1. So if you want used with outbound connection, you have to put 0.0.0.0. I tried launching this command :

pio home --host 0.0.0.0 --no-open

Now I can open the webpage with host webbrowser. But I have the same problem with the vscode image. I can't display my folder tree. I can't open project. Maybe a Windows/Linux path problem.

Error: {'code': -32000, 'message': 'Server error', 'data': {'type': 'FileNotFoundError', 'args': (2, 'No such file or directory'), 'message': "[Errno 2] No such file or directory: '/home/vagrant/Documents/PlatformIO/Projects/200303-200258-esp32dev\\\\platformio.ini'"}}
API Exception: {'type': 'FileNotFoundError', 'args': (2, 'No such file or directory'), 'message': "[Errno 2] No such file or directory: '/home/vagrant/Documents/PlatformIO/Projects/200303-200258-esp32dev\\\\platformio.ini'"}

Here my path :

╰─ ll ~/Documents/PlatformIO/Projects/200303-200258-esp32dev/
total 20K
drwxrwxr-x 2 vagrant vagrant 4.0K Mar  3 20:02 include
drwxrwxr-x 2 vagrant vagrant 4.0K Mar  3 20:02 lib
-rw-rw-r-- 1 vagrant vagrant  440 Mar  3 20:04 platformio.ini
drwxrwxr-x 2 vagrant vagrant 4.0K Mar  3 20:02 src
drwxrwxr-x 2 vagrant vagrant 4.0K Mar  3 20:02 test
Turiok commented 4 years ago

Hello again,

I think I found the problem :) So a summarize. I run vscode on windows host with remote ssh extension on a linux guest. platformio extension is installed on guest. After adding the port forwarding to my ssh config. (To make it work, we can launch pio with --host 0.0.0.0 to accept outbound config) I have the page but I can't navigate in my file system.

For me it's a problem of Windows/Linux useragent problem. What are my tests. I launch a new instance of pio on my guest

pio home --host 0.0.0.0 --port 8008 --no-open

I launch firefox on my host with guest ip. Same problem than vscode. But if I launch firefox on an other linux computer. Navigation works and folder creation too. Miracle :) I tried to install an extension on firefox to change useragent. The goal is to send an useragent with linux OS with my firefox on windows. I use the useragent modifier extension below. Change the useragent in the websocket connection and it works. https://add0n.com/useragent-switcher.html?version=0.3.4&type=install Now I don't know how to update vscode to change the user agent and the impact for this app

MBetters commented 4 years ago

Another issue in remote-SSH is that PIO Home --> New Project is showing host filesystem, not guest filesystem.

septatrix commented 3 years ago

However, when i created a new Project named 'bpTest' it was created as ~/Documents/PlatformIO/Projects\bpTest where Projects\bpTest is a folder name.

I do not exactly know what causes this. After looking a bit in the source code I was however able to find some places where we use the native fs module instead of the one provided by the VSCode API. This may lead to such problems. Even if it does not lead to problems the usage of the native module is discouraged anyways as it apparently runs in the editor process unlike most other stuff accessible over the vscode api. Currently I do not have a remote machine setup with which I could test this but I may be able to in a few days...

paloj commented 3 years ago

image

I have this same issue. Im using vscode locally on windows with ssh remote connection to mac mini m1 which has an arduino board attached to it.

hazza64 commented 3 years ago

I am also having this exact same issue, even though from memory it was working a while ago. Setup:

Opening the PIO Home screen shows nothing.

I was doing some research (but lost the links -_-) that suggests it may be an issue with it using the Windows Filesystem on the remote target (in this case Rasbian GNU/Linux). Seems like they're on it; issue linked here https://github.com/platformio/platformio-core/issues/3681

arpaterson commented 1 year ago

I have also run into this. Windows 11 VSCode+PlatformIO -> Remote SSH extension -> Jetson Orin developer kit -> Feather M4 Express Platform IO extension installed thru client VScode on both client (win11) and orin (ubuntu 20.04)

I'd like to be able to use either of two work flows:

Hsun1031 commented 1 year ago
  1. Use VS Code's SSH remote feature to access your computer remotely.
  2. Go to the PlatformIO Extensions settings and set the "PlatformIO-IDE: Pio Home Server Http Port" to a value such as 8080 in your user settings.
  3. Set the same port in the remote settings for Remote[ssh:www .example. com].
  4. To forward the port, press F1 and select "Ports: Focus on Ports View", then choose "Forward a Port" and add port 8080.
  5. Finally, you will be able to use PIO Home.
Brechtjeu commented 1 year ago

@Hsun1031 are you also able to create a new project this way? I cannot. Idon't see the remote filesystem and when I create the project, I get a folder at an unusable path with only half and installation (esp32 esp-idf framework)

Hsun1031 commented 1 year ago

@Brechtjeu I have tested that Ubuntu can connect to Ubuntu, but Windows cannot connect to Ubuntu.

luxk3 commented 12 months ago

Hello everybody, I was trying to solve a different issue, and I took a similar road to the one described here. I know my use-case is a bit different, but I wrote a short guide. I leave it here as reference, it might be helpful to somebody else.

https://github.com/luxk3/ubuntu_server_remote_dev_platformio

luxk3

d330447535 commented 3 weeks ago

Add the following code to solve the problem of not opening the page under SSH,View the api https://code.visualstudio.com/api/advanced-topics/remote-extensions#forwarding-localhost

const pageUrl = await vscode.env.asExternalUri( vscode.Uri.parse(pioNodeHelpers.home.getFrontendUrl({ start: startUrl, theme, workspace: extension.getEnterpriseSetting('defaultPIOHomeWorkspace'), })) );