usabilityhub / rails-erb-loader

Embedded Ruby (.erb) webpack loader for Ruby projects.
MIT License
103 stars 28 forks source link

Default runner path should be portable #52

Open jonhue opened 6 years ago

jonhue commented 6 years ago

After adding the ERB loader and adding the .erb file extension to my application pack, I am getting the following error:

ERROR in ./app/webpack/packs/application.js.erb
Module build failed: Error: spawn bin/rails ENOENT
    at _errnoException (util.js:1024:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
 @ multi (webpack)-dev-server/client?http://localhost:3035 ./app/webpack/packs/application.js.erb

it is also happening with the sample hello_erb.js.erb pack.

rhys-vdw commented 6 years ago

Oh sorry @jonhue, I missed this. ENOENT means that there is no bin/rails executable to use. You'll need to work out which directory your rails/ruby executable exists in and configure the loader to use the correct path. I've got a couple of examples there you can use as reference. Let me know if you need more guidance.

rhys-vdw commented 6 years ago

I've marked this as "enhancement" because this error could be caught and a more practical instruction (like the comment I gave above) provided instead.

rhys-vdw commented 6 years ago

it is also happening with the sample hello_erb.js.erb pack.

What is that?

jonhue commented 6 years ago

The webpacker gem generates it when installing the ERB loader.

jonhue commented 6 years ago

@rhys-vdw

Modifying runner & dependenciesRoot does not appear to solve the problem. I tried each of them with up to four ../. Relative to which file should these paths be? The configuration? The .js.erb files?

jonhue commented 6 years ago

Here is a sample app that reproduces the problem: https://github.com/jonhue/test_app

jonhue commented 6 years ago

runner: 'ruby bin\\rails runner' fixed the problem for me.

rhys-vdw commented 6 years ago

Ah. Windoze! We should be using path.join for the default path.

rhys-vdw commented 6 years ago

Are you sure you need the leading ruby though? bin/rails should be an executable.

jonhue commented 6 years ago

@rhys-vdw I don't know why, but I need it.