Opened 5 years ago
Last modified 5 years ago
#5986 new defect
Can't open wsl path from OMEdit under Windows
Reported by: | Andreas Heuermann | Owned by: | Adeel Asghar |
---|---|---|---|
Priority: | normal | Milestone: | 2.0.0 |
Component: | OMEdit | Version: | v1.16.0-dev |
Keywords: | Windows WSL | Cc: |
Description
Under newer Windows 10 builds the Windows Subsystem for Linux (WSL) is included into the Windows Explorer. Similar to every file on your local drive you can navigate to your files inside a WSL distribution.
When I try to open any file with OMEdit that is inside the WSL directory OMEdit is looking at the wrong location.
For example when I have a file test.mo
in my home directory of a Ubuntu 18.04 WSL I can access it from inside the WSL at /home/myUserName/test.mo
and from the Windows Explorer at \\wsl$\Ubuntu-18.04\home\myUserName/test.mo
.
In OMEdit I can navigate to the file with the Explorer but then I get following error:
Error has occured while loading the file/library /Ubuntu-18.04/home/myUserName/test.mo. Unable to load the file/library. The file /Ubuntu-18.04/home/myUserName/test.mo not found.
\\wsl$
is available already for WSL1 since Windows 10 1903.
Change History (7)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Or it could be Qt File API fails to read such paths.
@AnHeuermann can you try loadFile
from a mos script?
comment:3 by , 5 years ago
Calling it from command line with a .mo file seems to work:
C:\home\adrpo33\dev\OpenModelica>.\build\bin\omc.exe \\wsl$\Ubuntu\home\adrpo33\testing\Simple_NoAnnotations.mo class Simple_NoAnnotations "Simple state machine" Integer i(start = 0); stateMachine state1 state state1 output Integer state1.i; output Integer state1.j(start = 10); equation state1.i = 2 + previous(i); state1.j = -1 + previous(state1.j); end state1; state state2 output Integer state2.i; equation state2.i = -1 + previous(i); end state2; equation transition(state1, state2, i > 10, false, true, false, 1); transition(state2, state1, i < 1, false, true, false, 1); initialState(state1); end state1; equation i = if activeState(state1) then state1.i else if activeState(state2) then state2.i else previous(i); end Simple_NoAnnotations;
comment:4 by , 5 years ago
Yes, it's working from Windows command prompt
C:\Users\Andreas>"C:\Program Files\OpenModelica1.16.0-dev-64bit\bin\omc.exe" \\wsl$\Ubuntu-18.04\home\aheuermann1\test.mo class M Real x; equation x = 0.5 * der(x); end M;
but if I try to run following script callWSLTest.mos
loadFile("\\wsl$\Ubuntu-18.04\home\aheuermann1\test.mo"); getErrorString();
from CMD I get
D:\workspace\Testitesttest\ticket5986>"C:\Program Files\OpenModelica1.16.0-dev-64bit\bin\omc.exe" callWSLTest.mos [D:/workspace/Testitesttest/ticket5986/callWSLTest.mos:1:9-1:17:writable] Warning: Lexer treating \ as \\, since \U is not a valid Modelica escape sequence. [D:/workspace/Testitesttest/ticket5986/callWSLTest.mos:1:9-1:30:writable] Warning: Lexer treating \ as \\, since \h is not a valid Modelica escape sequence. false ""
comment:5 by , 5 years ago
Adding two extra backslashes and using only /
seems to work though
loadFile("\\\\wsl$/Ubuntu-18.04/home/aheuermann1/test.mo"); getErrorString();
and I can simulate without problems.
comment:7 by , 5 years ago
Milestone: | 1.16.0 → 2.0.0 |
---|
I looked a bit into this and it seems like this is not possible to achieve with the existing Qt API. We are using QFileDialog::getOpenFileNames which allows browsing WSL files with \\wsl$
but strips \\wsl$
from the output string.
It might be because we translate backwards slashes to forward slashes for all the path and file operations.