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.

Config: Testing for Windows doesn't work when using a Linux subsystem

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
rhys-vdwcommented, Jun 3, 2018

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:

module.exports = {
  test: /\.erb$/,
  enforce: 'pre',
  exclude: /node_modules/,
  use: [{
    loader: 'rails-erb-loader',
    options: {
      // Set this in each environment.
      runner: process.env.RAILS_ERB_LOADER_RUNNER,
    }
  }]
}

Just for my curiosity: Why is it that bin/rails runner fails in the Linux subsystem? Is it not executable?

0reactions
rhys-vdwcommented, Jun 9, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

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