Opened 4 years ago

Last modified 4 years ago

#5986 new defect

Can't open wsl path from OMEdit under Windows

Reported by: AnHeuermann Owned by: adeas31
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.moand 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 Changed 4 years ago by adrpo

It might be because we translate backwards slashes to forward slashes for all the path and file operations.

comment:2 Changed 4 years ago by adeas31

Or it could be Qt File API fails to read such paths.

@AnHeuermann can you try loadFile from a mos script?

comment:3 Changed 4 years ago by adrpo

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 Changed 4 years ago by AnHeuermann

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
""
Last edited 4 years ago by AnHeuermann (previous) (diff)

comment:5 Changed 4 years ago by AnHeuermann

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.

Last edited 4 years ago by AnHeuermann (previous) (diff)

comment:7 Changed 4 years ago by adeas31

  • Milestone changed from 1.16.0 to 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.

Note: See TracTickets for help on using tickets.