Config: Testing for Windows doesn't work when using a Linux subsystem
See original GitHub issueI am compiling with webpack in the Ubuntu subsystem of Windows. This is my generated erb-loader config:
module.exports = {
test: /\.erb$/,
enforce: 'pre',
exclude: /node_modules/,
use: [{
loader: 'rails-erb-loader',
options: {
runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner'
}
}]
}
The problem is here: runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner'
.
While this works in Windows, it does not in the subsystem as it does not recognize it as Windows.
Replacing the runner option with runner: 'ruby bin/rails runner'
solves the problem locally but breaks production on a linux server.
Is there a way I can distinguish development from production?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
Troubleshooting Windows Subsystem for Linux | Microsoft Learn
Open Control Panel -> Programs and Features -> Turn Windows Feature on or off -> Check Windows Subsystem for Linux or using the...
Read more >Work in Windows Subsystem for Linux with Visual Studio Code
This tutorial walks you through enabling Windows Subsystem for Linux (WSL) and running Visual Studio Code in WSL using the WSL extension.
Read more >The Ultimate Guide to Windows Subsystem for Linux ...
Learn how to natively work within Linux on Windows 10 with Windows Subsystem for Linux (WSL in Windows) in this HUGE guide!
Read more >No network access from WSL/Ubuntu · Issue #7141 - GitHub
Tried creating one, but it won't connect: unidentified network. I've got two machines side-by-side with fresh installs of windows, updated, no ...
Read more >No internet connection on WSL Ubuntu (Windows Subsystem ...
Note if you're connecting via VPN I don't think this will work - I also haven't tested in the office with Coronavirus, it's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to be clear - rails-erb-loader does nothing smart with the runner command at present. Since the loader doesn’t require rails (can use ruby directly) I don’t think there’s a way to generalize.
Perhaps a solution like this makes sense:
Just for my curiosity: Why is it that
bin/rails runner
fails in the Linux subsystem? Is it not executable?Hey @jonhue if you do find a nice solution you’re invited to tackle #52. It wont make a difference in the case of webpacker though since it’s overriding the defaults. Perhaps if #52 is closed the webpacker default runner could be set to
undefined
so it just takes the default from this project.