Skip to content

Commit

Permalink
Use wslpath to find the backend program
Browse files Browse the repository at this point in the history
If the wslpath command is in the PATH, then wslbridge relies on it to find
the backend. If it's not in the PATH, then it falls back on its own
X:\foo\bar ==> /mnt/x/foo/bar path conversion.

I tested using the /etc/wsl.conf file here:
https://blogs.msdn.microsoft.com/commandline/2018/02/07/automatically-configuring-wsl/

If the /windir directory didn't exist, then no /windir/c mount was created,
and wslbridge failed with this error message:

$ ./out/wslbridge
wslbridge error: failed to start backend process
note: backend error output: wslpath: C:\rprichard\proj\wslbridge\out\wslbridge-backend: No such file or directory

If the directory does exist, then wslbridge finds the /windir/c/...
backend path.

Fixes #22
  • Loading branch information
rprichard committed Feb 26, 2018
1 parent 1e011cb commit 06fb7ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2016 Ryan Prichard
Copyright (c) 2018 Google LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
Expand Down
5 changes: 5 additions & 0 deletions frontend/wslbridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,12 @@ int main(int argc, char *argv[]) {

// Prepare the backend command line.
std::wstring bashCmdLine;
bashCmdLine.append(L"$(if [ \"$(command -v wslpath)\" ]; then wslpath");
appendBashArg(bashCmdLine, backendPathWin);
bashCmdLine.append(L" || echo false; else echo");
appendBashArg(bashCmdLine, backendPathWsl);
bashCmdLine.append(L"; fi)");

if (debugFork) {
appendBashArg(bashCmdLine, L"--debug-fork");
}
Expand Down

0 comments on commit 06fb7ac

Please sign in to comment.