lektor / lektor-website

The main lektor website.
https://www.getlektor.com/
Other
160 stars 134 forks source link

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

Closed brianly closed 4 years ago

brianly commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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
  2. 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 commented 6 years ago

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 commented 4 years ago

@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 https://github.com/lektor/lektor-website/blob/1a059fa7007d92860b015bbdfb452bb0ceadcff4/assets/installer.py#L36 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 commented 4 years ago

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.