News:

alphaMELTS 2.3 standalone & for MATLAB/Python is now open source and available on GitHub (https://github.com/magmasource/alphaMELTS).
alphaMELTS 1.9 is available at the legacy download and information site.
For news of all MELTS software see the MELTS Facebook page.

Main Menu

Run easyMelts in the Windows Subsystem for Linux

Started by Paula, November 23, 2020, 06:43:28 AM

Previous topic - Next topic

Paula

For 64-bit Windows 10, it is possible to enable the 'Windows Subsystem for Linux' (WSL) and use the run the Linux version of easyMelts instead of, or as well as, the native Windows version. One reason you might want to do that is for improved interoperability between easyMelts, alphaMELTS 2 and alphaMELTS for MATLAB/Python (see Fixing line ending issues with file-format.command). Another is if display of the native Windows version of easyMelts is tiny on a high-resolution screen and you are not comfortable with editting the registry to fix it.

You will need to install an X server. We recommend X410 for simplicity, and because is has build in support for HiDPI screens. It is a paid app with a nominal price of ~$50, but is seemingly always on sale so the price is actually closer to $10. To install X410 you will need a Microsoft account. There is a free trial option or you can buy it if you have a payment option set up. Open the Microsoft Store and search for 'X410'. See Howto entries on the Choung Networks site for more details.

As of the Windows 10 May 2020 Update, it is possible to enable the WSL 2 (here). You can get more information on how to do this in Microsoft's Windows Subsystem for Linux Installation Guide for Windows 10. Whereas the original WSL was a compatibility layer that used Windows system tools underneath, WSL 2 uses virtualization. This potentially improves system performance; see the WSL 1 vs WSL 2 comparison. Note that it is a bit more involved to get easyMelts running in WSL 2 than WSL 1, but X410 does most of the hard work for you (see how to use X410 with WSL 2).

Enable the WSL, and install ubuntu

  • Open Settings (click either the Start button in the bottom LH corner or the Notification icon in the bottom RH corner; then click the cog icon). Type 'Windows features' in the search box and then select 'Turn Windows features on or off'. Scroll down and check the box beside 'Windows Subsystem for Linux'; click OK and reboot.
  • Open the Microsoft Store and search for 'ubuntu'. Choose 'Ubuntu', or 'Ubuntu 20.04', and select 'Get'.
  • Select 'Launch'. You will be prompted to enter a username and password for Linux. The username is case sensitive; it may, or may not, be the same as your Windows username but you should avoid spaces or special characters in it. The password should be different to your Windows password; you will need to enter it when installing or updating software at the Linux command line.
Set up the ubuntu command line
  • Note that you can use ubuntu commands and Linux software to modify your regular files on Windows. In general is better if you do not use Windows programs to modify the ubuntu files (by which we mean the ubuntu system files and the files in your ubuntu home space). This is particularly true for WSL 1, but on either WSL 1 or 2 it is easier to make regular backups if you keep all your working files in your usual Windows folders. You can set up links so that you can access them from the command line:
    Quote
    cd
    ... this just ensures that you are in your ubuntu home directory
    ln -sf /mnt/c/Users/your_windows_username/Downloads .
    ... the space between 'Downloads' and '.' is required
    ... if you copy and paste the command then use the left arrow and delete to replace 'your_windows_username' with the actual name of the folder that your Windows files are stored in
    ... if the 'your_windows_username' folder has spaces in its name you need to put a '\' before each one e.g:
    ln -sf /mnt/c/Users/your\ windows\ username/Downloads .
    You can now switch to the folder by typing 'cd Downloads'. If you don't want the link to be called 'Downloads' then replace '.' with your choice of link name e.g. 'MyFiles'. 'ln' stands for 'link'; '-s' is for 'symbolic', so if you delete the link you do not delete the original file (much like Windows shortcuts); '-f' is for 'force', which makes no difference at this point but should you change your mind about where you want the 'MyFiles' link to point to, then is required to overwrite the original.
  • Substitute 'Downloads' and repeat the above for any other folders that you would like to be able to access from the command line while running easyMelts, such as 'Documents' or 'Desktop'.
Set up easyMelts
This sets up the DISPLAY variable that easyMelts will need. It also makes a 'bin' folder, which is short for 'binary' and is a folder where we will put a link (shortcut) to easyMelts, so that you can run easyMelts from anywhere on the system. On a clean Ubuntu 20.04 installation (or other flavors of WSL) the 'bin' folder should be added to your Linux PATH automatically when you restart the WSL. Open ubuntu, if it is not already open:
Quote
cd
... this just ensures that you are in your ubuntu home directory
mkdir bin
... which means make a directory called 'bin' (where 'directory' is what is called 'folder' on Windows)
echo $DISPLAY
This last command just prints the existing DISPLAY variable, if any. If you are on WSL 1, the DISPLAY variable needs to be ":0" (or "localhost:0" should also work) so type:
Quote
echo "export DISPLAY=:0" >> ~/.profile
... where there is no space after the '.'; a file beginning with with '.' is a hidden file in Linux
If you are on WSL 2, the command is a little more complicated. You can add the DISPLAY variable set up with:
Quote
echo "export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0" >> ~/.profile
... note the '\' after the equals sign is required if you are using the command line in this way
See below for variations if you are on something other than Ubuntu 20.04. The next step sets up a link to easyMelts. Assuming easyMelts is in your Download folder:
Quote
cd ~/bin
... '~' is shorthand for your home space on ubuntu
ln -sf ../Downloads/easyMelts .
... see the 'Set up the ubuntu command line' section for an explanation of the 'ln' command; note that '..' means up one directory level
exit
... this closes ubuntu; when you next open it the .profile settings file will be read and acted upon
Since we added the 'bin' folder to the PATH you will be able to open easyMelts from any folder by typing 'easyMelts'. (Without these settings you would need to navigate to the folder containing easyMelts and type './easyMelts', where '.' means the current directory.)

Start X410 by double-clicking. Test easyMelts by typing 'easyMelts' at the command line. If the display is still very small, x410 has an option to fix the scaling. Scroll down to the 'Built-in DPI Scaling: section of Running X410 on HiDPI Screens. You will probably be able to use 'High Quality' for easyMelts.

You will not need to repeat all these steps next time. Just select 'Ubuntu' from the Windows Terminal program, navigate to the folder where your input (.melts) files are, and type 'easyMelts'.

Any problems, please let me know,
Paula

Paula

#1
If you are on Fedora Remix or Arch Linux WSL then you need to substitute "~/.bash_profile" for "~/.profile" in the above instructions.

If you get an error like "easyMelts: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory":

  • If you are on Ubuntu 18.04 you need to type "sudo apt install mesa-utils" at the command line.
  • If you are on ArchLinux you need to type "sudo pacman -Syu mesa-demos" at the command line.
  • If you are on Fedora remix, just make sure you have updated to the latest version.

Paula

If you intend to use alphaMELTS 2 or other command line tools in the WSL then it is worth checking out the 'Windows Terminal' program and Visual Studio Code.

  • Return to the Microsoft Store and install 'Windows Terminal'. From now on you should be able to copy commands in these instructions (using Ctrl+C) and then paste them to the Windows Terminal command line by with Ctrl+Shift+V.
  • Open Windows Terminal, if it is not already open. If you click the 'V' drop-down menu 'Ubuntu' (or 'Ubuntu-20.04') should be one of the options.
  • You can install VS Code by typing:
    Quote
    sudo apt install code
    VS Code integrates with the Windows desktop automatically. You don't even need to have X410 running to be able to use it.
  • Sometimes Windows Terminal will map Ctrl+C and Ctrl+V to copy and paste (in addition to Ctrl+Shift+C and Ctrl+Shift+V, respectively). You should probably disable that so that Ctrl+C can be used to break out if a program hangs or gets in a loop. In Windows Terminal, go to Settings in the drop-down menu. If you installed VS Code the settings will open in that, but if not you may be asked to choose a text editor e.g. Notepad to edit the settings. Scroll to the bottom. Comment out ('//') or edit the lines under 'keybindings'. For example, you might replace "ctrl+c" and "ctrl+v" with "alt+c" and "alt+v" respectively:
    Quote
    ... e.g. replace
    { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" }'
    { "command": "paste", keys: "ctrl+v" },

    ... with
    //{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" }'
    //{ "command": "paste", keys: "ctrl+v" },

    ... or
    { "command": {"action": "copy", "singleLine": false }, "keys": "alt+c" }'
    { "command": "paste", keys: "alt+v" },