question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot execute rubocop in WSL from Windows

See original GitHub issue

The file name of rubocop in WSL is rubocop, same as Linux. However, when VSCode is installed in Windows, configuration.ts tries to use rubocop.bat. So that, the extension cannot find the executable rubocop in WSL from VSCode in Windows.

Error message my_path_to_rubocop_in_wsl/rubocop.bat is not executable

I need an additional configuration to use WSL. We can execute a file in WSL from Windows:

C:\> wsl my_path_to_rubocop_in_wsl/rubocop

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

8reactions
timkrinscommented, May 25, 2018

I use a workaround with a .bat file that I can reference in the vscode settings:

@echo off
bash.exe -c "~/.rvm/gems/ruby-2.5.0/wrappers/rubocop %*"

(I use rvm inside WSL, but you should be able to adjust for your own environment) Inspired by https://hackernoon.com/wsl-hacks-making-atom-linters-work-with-windows-subsystem-for-linux-c86d42eaf09e

4reactions
reminjpcommented, May 26, 2018

It works! My rubocop.bat looks like this. (I use rbenv.)

@echo off
wsl ~/.rbenv/shims/rubocop $^(echo '%*' ^| sed -e 's^|\\^|/^|g' -e 's^|\^([A-Za-z]\^)\:/\^(.*\^)^|/mnt/\L\1\E/\2^|g'^)

In the end, I needed to convert Windows path in args into WSL path.

https://gist.github.com/aseering/a06219e74c7f96ccea5ec65d5b2483b5

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error on config Rubocop for VSCODE in WSL2 - Stack Overflow
Show activity on this post. A last try: create a bash script in windows to point to rubocop. Then in VSCODE: "ruby. rubocop....
Read more >
Ruby rubocop on WSL : r/bashonubuntuonwindows - Reddit
Has anyone successfully installed rubocop on WSL (ubuntu)? I've tried every suggestion on every stackoverflow post but no success.
Read more >
WSL2: Run anything in project from wsl-host with wsl-sdk : RUBY ...
RUBY-27748 Cannot run docker-compose in rubymine on Windows 10 using wsl2 ... RUBY-27816 Rubocop not picking up .rubocop.yml in project directory under WSL....
Read more >
My rspec problem: When your code is correct but RuboCop ...
So I've set up my development environment in a WSL Bash shell on my Windows 10 PC. I try to test code using...
Read more >
Configuring WSL for ruby - Glenn Sarti
While still in Beta, this allows Windows to run native ubuntu binaries on Windows, that is, running Linux as a subsystem on Windows....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found