Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation under Bash on Ubuntu on Windows (WSL) has odd path resolution #164

Closed
brianly opened this issue Oct 24, 2017 · 5 comments
Closed

Comments

@brianly
Copy link

brianly commented Oct 24, 2017

I wanted to install on Windows 10. Thinking that ImageMagick might be a pain to install I tried installation under WSL. When I do this I find that install.sh resolves some odd installation directories:

brianly@Aotearoa:~$ curl -sf https://www.getlektor.com/install.sh | sh
()
Welcome to Lektor
()
This script will install Lektor on your computer.
()
Installing at:
  bin: /mnt/c/Go/bin
  app: /mnt/c/Go/lib/lektor
()
Continue? [Yn]

I have Go installed under Windows and it seems to want to install there. If I look at my $PATH variable under WSL it looks like it includes values from Linux and Windows:

brianly@Aotearoa:~$ $PATH
-bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program: No such file or directory

Running the find_user_paths() function independently under WSL I get:

>>> def find_user_paths():
...   rv = []
...   for item in os.environ['PATH'].split(':'):
...     if os.access(item, os.W_OK) \
...     and item not in rv \
...     and '/sbin' not in item:
...       rv.append(item)
...   return rv
...
>>> find_user_paths()
['/mnt/c/Users/brian/AppData/Local/Microsoft/WindowsApps', '/mnt/c/Go/bin', '/mnt/d/Sysinternals', '/mnt/c/Users/brian/AppData/Roaming/npm', '/mnt/d/SFBin/windows/docker']

I haven't done enough research to understand the expected behaviour with paths, but I see similar behavior on another computer running WSL under Windows 10.

@brianly
Copy link
Author

brianly commented Oct 24, 2017

It looks like it is possible to detect that you are running under Bash on Windows. This behaviour has been seen as a problem by others, and there is a registry setting to stop WSL combining Windows and Linux paths.

Would this project accept an update to install.sh that detected WSL and offered only Linux paths? My personal feeling is that end user software should try to be low friction for end users. Lektor was low friction on macOS, but not Windows for me.

@NgxDev
Copy link

NgxDev commented Nov 22, 2017

@brianly I've just found out, after banging my head against the wall a few times (not really), that there are 2 versions to that:

  1. If you've installed WSL the lxrun way:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss]
"AppendNtPath"=dword:00000000
  1. If you've installed WSL from the Windows Store (like I did):
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LxssManager]
"DistributionFlags"=dword:fffffffd

I've found them both courtesy of @benhillis
Just wanted to mention both, in case anyone reaches this and the first way doesn't work for them if they've installed WSL from the Store.

@nixjdm
Copy link
Member

nixjdm commented May 8, 2018

Would this project accept an update to install.sh that detected WSL and offered only Linux paths? My personal feeling is that end user software should try to be low friction for end users. Lektor was low friction on macOS, but not Windows for me.

@brianly I know this issues is a bit old, but for the record, I agree that we want installs to be as low friction as possible, and updates to the install.ps1 and install.sh files to that effect are great. I don't personally have Windows, or Windows experience that's at all recent though, so I'm labeling this as 'help wanted'.

@xlotlu
Copy link
Contributor

xlotlu commented Apr 23, 2020

@brianly / @MrCroft if you are still watching this, what would be a good location to install under in this setup?

The installer finds the first writable directory in $PATH (trying these first

# where to search for a writable bin directory on *nix.
and avoiding anything '/sbin').

My personal feeling is that end user software should try to be low friction for end users. Lektor was low friction on macOS, but not Windows for me.

If you have a predictable $HOME that should make things low-friction. That old find_user_paths() call you posted ends up being reordered according to POSIX_BIN_DIRS.

Using native windows python should also be low-friction.

Would this project accept an update to install.sh that detected WSL and offered only Linux paths?

@brianly if you still wanna fix this, the secret is in posix_find_bin_dir() in the code I linked. Ideally only a small tweak to POSIX_BIN_DIRS would do it, but also check the result of posix_find_lib_dir().

@xlotlu
Copy link
Contributor

xlotlu commented Jun 1, 2020

Closing this for lack of feedback. It's also been a long time since the report and the installer has been overhauled. If it's still an issue please reopen.

@xlotlu xlotlu closed this as completed Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants