You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Instructions on Getting Started with WindowsΒ #195
See the post below. If you have new findings, please comment. We'll then integrate your findings into the post and remove the comment to reduce noise. Thanks!
Edit: upon demand, I've cleaned up most of the outdated replies.
Reacted by Fernando Alex Helwanger, Joshua Harms, Marc SolΓ Nadal, Jarle Stabell, Johann Hubert Sonntagbauer, Nikoloz Buligini, Oleg Lustenko, Richard Torruellas, Rainer Lopez, Haroen Viaene and 22 more
Reacted by Wojciech Bilicki, Leonard Souza, Adam Lane, Lek Huda and Jared Ni
Reacted by Benjamin San Souci, Wojciech Bilicki, Dawid Jankowiak, Jeremias Blendin, Leonard Souza, GεζεΌε, Viktor Nareiko, Adam Lane, Robbie Frost, Bart Lens and 1 more
First. A very warm welcome. We're really glad you are here! We've been waiting for you! And I bring you good news:
Reason works 100% on Windows
BuckleScript (bs-platform) is verified to work well on Windows.
It's the editor tooling (mainly, Merlin not working in Windows environment with VSCode Reason extension) that's lacking.
but there's a working workaround by running Merlin on Windows 10 WSL
all features (live errors, code lens, code completion, auto formatting) work as expected.
exception is go-to definition/error line in message panel doesn't work yet
a very minor thing and it might be fixed eventually
bsb-native, BuckleScript's bsb build system altered to compile to native code (using ocamlc/ocamlopt), works on windows and can be installed through npm like npm install bsansouci/bsb-native\#2.1.1
Workarounds
Solution 1: Ocaml/Reason on WSL (recommended)
What running a Reason project on WSL mean?
Project will live on Windows 10 WSL environment, like a VM, but well integrated into Windows,
project files are kept in Windows file system (like C:/somewhere/xxx, etc). But project dependencies, tools are linux based and should be installed/built/used on WSL (not Windows Command Prompt). Editing can be done on Windows as usual. Basically, instead of using Windows Command Prompt, you'll be using WSL's Bash.
On Windows Command Prompt (not WSL), do: npm install -g ocaml-reason-wsl
Now that it is installed, skip to "Configure Editor" topic bellow.
Optional:
To remove batch shortcuts to solve conflict between unix command versions and windows, like having a Windows native bs-platform in Windows environment (not WSL version), do:
npm uninstall -g ocaml-reason-wsl
This won't affect Reason/Ocaml installation in WSL because the script has run already. It only removes Windows shortcuts to applications in WSL environment. But then bash -ci is required for executing any application from WSL in Windows Command Prompt.
To enable auto-format, add: "editor.formatOnSave": true
To enable bucklescript errors, set: "reason.diagnostics.tools": ["merlin", "bsb"]
To set bash as default terminal, add: "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe"
Test It
Create/choose a folder. An example: C:\projects\
On WSL:
Change directory to folder, like: cd /mnt/c/projects/
Then create a sample project:
bsb -init demoapp -theme basic-reason
cd demoapp
npm install
npm run start
Open VSCode in this new folder: C:\projects\demoapp
Troubleshooting
Make sure VSCode is 64-bit.
VSCode is executed in Windows environment and has to be opened on folder location exactly where .merlin file is located. Executing command bsb (like bsb -make-world) generates .merlin file. bsb has to be executed in WSL to create .merlin file with unix path style (instead of Windows style path).
All project tools/dependencies must be linux based and executed on WSL environment, including installing (npm install), compiling/building (bsb -make-world), tests (jest). Mixing windows and linux environment is not recommended.
Test Merlin's application:
On Windows Command Prompt try command:
bash -ci 'ocamlmerlin -version'
Output must be:
The Merlin toolkit version 2.5.4, for Ocaml 4.02.3
On WSL' bash try command:
ocamlmerlin -version
Output must be:
The Merlin toolkit version 2.5.4, for Ocaml 4.02.3
If it fails, there is an installation problem.
If you have installed ocaml-reason-wsl over Windows's NPM first, make sure to remove it.
On CMD (not WSL): npm -g uninstall ocaml-reason-wsl
WSL supports multiple environments and you need to make sure you have the correct Ubuntu environment chosen.
To check if you have any older / legacy WSL environment active:
wslconfig /list /all
If Ubuntu isn't default. Pick it as default environment with command:
wslconfig /setdefault Ubuntu
Optional: To scrap a legacy WSL environment, run:
lxrun /uninstall /full
Dangerous tip - For the record: Once to workaround some odd errors, like not being able to Launch Ubuntu from Microsoft Store, had to manually remove WSL environment, found it at:
Problem: If WSL initially works fine and when running bucklescript on watch mode WSL crashes unexpectedly, or closes or becomes unresponsive, and closing WSL window and reopening won't start the Bash prompt.
Workaround: Restart your computer and try to open Bash again.
Make sure to keep your Windows and WSL's Ubuntu updated.
WSL version is tied to Windows version. For having latest WSL fixes it's necessary Windows insiders build.
There is a campaign to solve root issue. Would be nicer solving root issue instead of workaround of the workaround.
On success
Report it. Come to Discord. Tweet. Spread the word. Show your friends how awesome you are for having the cutting edge Reason working in Windows. Your love is appreciated. S2
On trouble, failure, broken heart
Come to Discord, and let's talk! We can usually help you out.
For Windows WSL issues use #editorsupport channel.
Reacted by Yawar Amin, Hal Wayland (Martin MikuΕ‘Γ‘t), Javier ChΓ‘varri, Fernando Alex Helwanger, Cheng Lou, Kyle Davis, Russ Powers, Oleg Lustenko, bryphe, Johann Hubert Sonntagbauer and 35 more
Reacted by Rainer Lopez, Dawid Jankowiak, Hal Wayland (Martin MikuΕ‘Γ‘t), Tom Aylott, Chris Paton, Dyesse YUMBA, Nico Hartto, arial, Samantha, Leonard Souza and 9 more
This is a development post for keeping notes, tracking issues to when time is due improve official user guide post above. It has been split to lower the noise.
Work In Progress - Current Status
Notes:
Merlin.2.5.5 is known to work well with old-protocol. Merlin.3.0.5 might work from WSL too but there are issues in Windows native.
Only a path translation fix for VSCode extension is missing but the update is automatic and the fix is coming next release.
Solution: Windows Native without Merlin w/ BSB errors
How it would work
Instead of running Merlin on Windows native, it is possible to have BSB errors piped into VSCode, solving the diagnosis part provided by Merlin, but not the autocomplete, jump-to-definition.
Refmt:
For refmt, it is possible to use bsrefmt that comes with bs-platform, under node_modules/bs-platform/bin/bsrefmt. This is BuckleScript's vendor refmt, pinned at 1.13.7 (for the new syntax3, it's node_modules/bs-platform/bin/refmt3.exe. Just make your editor point to it.
BuckleScript Refmt3.exe works in Windows native when Path is set in absolute. Like: "reason.path.refmt": "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\bs-platform\\lib\\refmt3.exe",
BSB errors is still on research.
For now, solution for "Windows Native" isn't ready. Because:
ReasonML's VSCode extension requires Merlin for working. Which leads to the case where either Merlin works on Windows (with windows paths in .merlin file) or Merlin has to be disabled. It's absence is not handled gracefully and shows errors. In a future release Merlin might be optional. Right now on Windows native neither can be done. (Having it working nor disable it.)
Workaround to using windows native without Merlin and getting rid of Merlin errors in VSCode extension: Setting ocamlmerlin-server to ocamlmerlin app name in VSCode config. It doesn't pop up any errors anywhere. But won't work (autocompletion, code lens, diagnostics) either. But it requires having ocamlmerlin-server (could be installed from Cygwin ENV).
Vim (vim-reason-plus on the LanguageClient-Neovim plugin)
Add how to check for updates & upgrade:
wsl environment.
merlin
reason
bs-platform
On Watch
VSCode extension
Merlin being optional working. (There is the optional but it is not known to work as expected. This is required for minimal (without Merlin) Windows native support.)
Fix translating paths between unix/windows (affects jumping to error location/file/position.)
If you know how to make this documentation better, reply here, shout at us or just fix it (if you can).
Thanks in advance for helping us make this documentation better.
ocaml 4.02.3 is severly outdated and I require ocaml 4.05 or greater. Is there a known solution to get merlin to work with WSL and VSCode with Ocaml >= 4.05 ? If yes, how? Simply switching to a newer ocaml version does not work.
Activity
superherointj commentedon Oct 8, 2017
Hello Windows user!
First. A very warm welcome. We're really glad you are here! We've been waiting for you! And I bring you good news:
Reason works 100% on Windows
workingworkaround by running Merlin on Windows 10 WSLnpm install bsansouci/bsb-native\#2.1.1Workarounds
Solution 1: Ocaml/Reason on WSL (recommended)
Project will live on Windows 10 WSL environment, like a VM, but well integrated into Windows,
project files are kept in Windows file system (like
C:/somewhere/xxx, etc). But project dependencies, tools are linux based and should be installed/built/used on WSL (not Windows Command Prompt). Editing can be done on Windows as usual. Basically, instead of using Windows Command Prompt, you'll be using WSL's Bash.Install Windows Subsystem for Linux (WSL)
wslconfig /list /alllxrun /uninstall /fullwslconfig /setdefault Ubuntuwslconfig /unregister Ubuntusudo apt-get updatesudo apt-get dist-upgradeInstall Reason & Tools
Pick between Manual vs Automated option:
Option - Automated NPM Install for OPAM method
npm install -g ocaml-reason-wslnpm uninstall -g ocaml-reason-wslbash -ciis required for executing any application from WSL in Windows Command Prompt.Option - Manual Install
On WSL (not Windows Command Prompt):
Install NPM/Node
node -vcurl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -sudo apt-get install -y nodejsmkdir ~/.npm-globalnpm config set prefix '~/.npm-global'echo export PATH=~\/.npm-global\/bin:\$PATH >> ~/.bashrcsource ~/.bashrcnpm install -g npm# Important!Install Reason & Reason-Tools (Merlin, Refmt...)
Pick a method "OPAM" or "Reason-CLI". And run commands on WSL:
npm install -g reason-cli@3.2.0-linuxsudo apt-get install -y build-essentialsudo apt-get install -y ocaml-nox opam m4opam initecho eval \$\(opam config env\) >> ~/.bashrcopam updateopam switch 4.02.3eval $(opam config env)opam updateopam install reasonopam install merlin.2.5.4# For Windows, Merlin 2.5.4 is stable and recommended.On WSL's Bash, Install BuckleScript globally
npm install -g bs-platformConfigure Editor
"reason.path.ocamlfind": "bash -ic ocamlfind",
"reason.path.ocamlmerlin": "bash -ic ocamlmerlin",
"reason.path.opam": "bash -ic opam",
"reason.path.rebuild": "bash -ic rebuild",
"reason.path.refmt": "bash -ic refmt",
"reason.path.refmterr": "bash -ic refmterr",
"reason.path.rtop": "bash -ic rtop"
"editor.formatOnSave": true"reason.diagnostics.tools": ["merlin", "bsb"]"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe"Test It
C:\projects\cd /mnt/c/projects/bsb -init demoapp -theme basic-reasoncd demoappnpm installnpm run startC:\projects\demoappTroubleshooting
64-bit.bsb(likebsb -make-world) generates.merlinfile.bsbhas to be executed in WSL to create .merlin file with unix path style (instead of Windows style path).bash -ci 'ocamlmerlin -version'The Merlin toolkit version 2.5.4, for Ocaml 4.02.3ocamlmerlin -versionThe Merlin toolkit version 2.5.4, for Ocaml 4.02.3ocaml-reason-wslover Windows's NPM first, make sure to remove it.npm -g uninstall ocaml-reason-wslwslconfig /list /allwslconfig /setdefault Ubuntulxrun /uninstall /fullC:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\On success
Report it. Come to Discord. Tweet. Spread the word. Show your friends how awesome you are for having the cutting edge Reason working in Windows. Your love is appreciated. S2
On trouble, failure, broken heart
superherointj commentedon Oct 25, 2017
Ignore this post if you are a newcomer.
Follow first @superherointj post!
This is a
developmentpost for keeping notes, tracking issues to when time is due improve official user guide post above. It has been split to lower the noise.Work In Progress - Current Status
Notes:
Solution: Windows Native without Merlin w/ BSB errors
How it would work
Instead of running Merlin on Windows native, it is possible to have BSB errors piped into VSCode, solving the diagnosis part provided by Merlin, but not the autocomplete, jump-to-definition.
Refmt:
refmt, it is possible to usebsrefmtthat comes with bs-platform, undernode_modules/bs-platform/bin/bsrefmt. This is BuckleScript's vendor refmt, pinned at 1.13.7 (for the new syntax3, it'snode_modules/bs-platform/bin/refmt3.exe. Just make your editor point to it."reason.path.refmt": "C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\bs-platform\\lib\\refmt3.exe",BSB errors is still on research.
For now, solution for "Windows Native" isn't ready. Because:
ocamlmerlin-servertoocamlmerlinapp name in VSCode config. It doesn't pop up any errors anywhere. But won't work (autocompletion, code lens, diagnostics) either. But it requires havingocamlmerlin-server(could be installed from Cygwin ENV).Solution: Docker
Still on Research. Attempts:
To-Do
On Watch
superherointj commentedon Dec 12, 2017
Fundraiser for better Editor Support in Windows (Without WSL)
Join effort! :)
reasonml/reason#1698
9 remaining items
matystl commentedon May 27, 2018
robkuz commentedon Jun 15, 2018
hey,
I am using Reason on Windows 10 (WSL) and I followed the instructions here - at least I think so
but I get this error
Intersting enough I have 2 other machines where this worked w/o problems. Does anybody see the error?
amsterdamharu commentedon Sep 19, 2018
None of this seems to be needed for Windows.
Just tried on Windows 10:
In another command prompt:
In vscode pressed control+p and pasted the command:
ext install jaredly.reason-vscodeLooks like it works as it should (did reload the vscode window after installing and setting Reason_language_server values in settings)
Jonas164 commentedon Dec 17, 2018
ocaml 4.02.3 is severly outdated and I require ocaml 4.05 or greater. Is there a known solution to get merlin to work with WSL and VSCode with Ocaml >= 4.05 ? If yes, how? Simply switching to a newer ocaml version does not work.
robkuz commentedon Dec 17, 2018
I got it running with installing X-Windows and running VSCode on WSL. However you better have a powerful machine. It ain't exactly fast
Jonas164 commentedon Dec 18, 2018
That does not seem much better than just using a Unix-VM. Both, X-Windows and a VM are not enjoyable on my laptop though
emileber commentedon Jan 23, 2020
@amsterdamharu as the project grows,
jaredly.reason-vscodeextension will eventually fail with "Command line is too long": jaredly/reason-language-server#262