You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My workflow is simple I have 2 files open at the same time (one in the left and one in the right), the one in the left is a CPP file, I press F5 to build and run it, then I expect an output file (the one in the right) to be automatically updated with the results. However this doesn't work when I run the program in WSL and the output file is in the local directory instead of WSL. If the output file is inside of the WSL directory instead of my local directory it works fine.
Open Ubuntu terminal and go to your local folder: cs /mnt/c/PathToYourFileInYourLocalComputer
For example for mine: cd /mnt/c/Users/Diego1149/Documents/Programs
Open VSCode from the Ubuntu terminal in my local folder: "code ."
Setup environment as showed in previous picture (I'm in Source, press F5 and expect to see the results in output reflected as soon as the program is done running, but it doesn't auto refresh the file.
Setting up the environment should be very quick and simple:
Instal C/C++ extension.
#define INF 1000000000
#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define FORC(cont, it)
for (decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define pb push_back
#define _
if (argc == 2 && ((string)argv[1]) == "USE_IO_FILES")
freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector vi;
typedef vector vii;
typedef vector vvi;
typedef tree<int, // key
null_type, // value
less, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;
/*
How to use ordered_set:
ordered_set X;
X.insert(1);
X.find_by_order(1); // This gives an iterator.
X.order_of_key(-5); // Lower bound, 0 based position.
*/
int main(int argc, char *argv[]) {
_;
printf("Modify this string and press F5, output file should update automatically, but it doesn't.");
return 0;
}
`
in.txt (this can be left empty, just drag and drop it to the right of Source)
out.txt (this can be left empty, just drag and drop it to the right of Source and below in.txt)
Does this issue occur when all extensions are disabled?: I didn't try since I see WSL is an extension, however only extensions I have are: "Remote - WSL" and "C/C++"
Some more details: If I reopen the output file it has the right contents, also if I do "File: Revert File" on the output file the contents get updated. Also if I have the output file in the same window as Source and I click on it it gets updated to have the right contents, this seems to only happen if they are on different partitions of the screen.
The text was updated successfully, but these errors were encountered:
Got closed as a duplicate; however, when I installed insiders version (1.54) with WSL extension 0.54.0 it still doesn't update automatically, I still need to alt+tab out and into it.
At the core of this are the missing file events in WSL from mounted drives. microsoft/WSL#4739
We tried to work around it in microsoft/vscode-remote-release#3959, but this causing performance issues.
We will wait for improvments in WSL.
Steps to Reproduce:
My workflow is simple I have 2 files open at the same time (one in the left and one in the right), the one in the left is a CPP file, I press F5 to build and run it, then I expect an output file (the one in the right) to be automatically updated with the results. However this doesn't work when I run the program in WSL and the output file is in the local directory instead of WSL. If the output file is inside of the WSL directory instead of my local directory it works fine.
For example for mine: cd /mnt/c/Users/Diego1149/Documents/Programs
Setting up the environment should be very quick and simple:
Instal C/C++ extension.
Override ".vscode/tasks.json" file with the following:
{ "type": "shell", "label": "C/C++: g++ build active file", "command": "/usr/bin/g++", "args": [ "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true } }
Override ".vscode/launch.json", with the following:
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "g++ - Build and debug active file", "type": "cppdbg", "request": "launch", "program": "${fileDirname}/${fileBasenameNoExtension}", "args": ["USE_IO_FILES"], "stopAtEntry": false, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "C/C++: g++ build active file", "miDebuggerPath": "/usr/bin/gdb" } ] }
Create a folder inside of the main folder you opened (in my case Programs/Subfolder) and add 3 files:
Source.cpp
`#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define INF 1000000000
#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define FORC(cont, it)
for (decltype((cont).begin()) it = (cont).begin(); it != (cont).end(); it++)
#define pb push_back
#define _
if (argc == 2 && ((string)argv[1]) == "USE_IO_FILES")
freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector vi;
typedef vector vii;
typedef vector vvi;
typedef tree<int, // key
null_type, // value
less, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;
/*
How to use ordered_set:
ordered_set X;
X.insert(1);
X.find_by_order(1); // This gives an iterator.
X.order_of_key(-5); // Lower bound, 0 based position.
*/
int main(int argc, char *argv[]) {
_;
printf("Modify this string and press F5, output file should update automatically, but it doesn't.");
return 0;
}
`
in.txt (this can be left empty, just drag and drop it to the right of Source)
out.txt (this can be left empty, just drag and drop it to the right of Source and below in.txt)
Does this issue occur when all extensions are disabled?: I didn't try since I see WSL is an extension, however only extensions I have are: "Remote - WSL" and "C/C++"
Some more details: If I reopen the output file it has the right contents, also if I do "File: Revert File" on the output file the contents get updated. Also if I have the output file in the same window as Source and I click on it it gets updated to have the right contents, this seems to only happen if they are on different partitions of the screen.
The text was updated successfully, but these errors were encountered: