Do you want to request a feature or report a bug?
BUG
What is the current behavior?
Running webpack's script inside Rails project in Windows 10 x64 doesn't work properly. Same goes for rake webpacker:compile or webpack-watcher. To fix the first issue (bin/webpack) I deleted NODE_PATH=#{NODE_MODULES_PATH} from the exec (line 38)
It seems that the environment must be set before the exec for Windows
If the current behavior is a bug, please provide the steps to reproduce.
For first one:
$ ./bin/webpack
./bin/webpack:38:in `exec': Invalid argument - NODE_PATH=E:/buk/node_modules E:/buk/node_modules/.bin/webpack --config E:/buk/config/webpack/development.js (Errno::EINVAL)
from ./bin/webpack:38:in `block in <main>'
from ./bin/webpack:37:in `chdir'
from ./bin/webpack:37:in `<main>'
Second one:
$ rake webpacker:compile
Webpacker is installed ๐ ๐ฐ
Using E:/buk/config/webpack/paths.yml file for setting up webpack paths
Compiling webpacker assets ๐
C:/RailsInstaller/Ruby2.3.0/bin/rake: No such file or directory - NODE_ENV=production ./bin/webpack
rake aborted!
NoMethodError: undefined method `success?' for nil:NilClass
Third one:
$ bin/webpack-watcher
bin/webpack-watcher:9:in `exec': Exec format error - ./webpack --watch --progress --color (Errno::ENOEXEC)
from bin/webpack-watcher:9:in `block in <main>'
from bin/webpack-watcher:8:in `chdir'
from bin/webpack-watcher:8:in `<main>'
Tasks: TOP => webpacker:compile
(See full trace by running task with --trace)
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Node.js version: 7.8
Webpack version: 2.3.2
Windows 10 x64
This issue was moved from webpack/webpack#4661 by @sokra. Orginal issue was by @jarrieta86.
Related issue with rails webpacker:install on Windows. To be able to run rails webpacker:install in an existing app on Windows 10 x64, I had to change the install.rake exec command from "./bin/rails app:template..." to just "rails app:template..."
exec "rails app:template LOCATION=#{WEBPACKER_APP_TEMPLATE_PATH}"
I can now install and run other webpacker commands successfully. Not sure if this helps :\
@rodoneill Did you dig deeper into this issue? Perhaps, if you can make a PR to fix the issue :)
I had to change the install.rake exec command from "./bin/rails app:template..." to just "rails app:template..."
./bin/rails is only available on linux right? If using rails app:template solved it, then this is a non-issue?
cc @rodoneill @jarrieta86
The above patch lets me run webpacker install on Windows, and should work on all platforms.
It does mean that if you run Rails with one version of Ruby, the same version of Ruby will be used to run nested commands. Previously, the version of Ruby specified in the #! line at the top of the file was used (a feature common to Unix shells, but not present on Windows).
It seems this issue has been closed in error, as only the webpacker:install command appears to have been fixed, but bin/webpack* have not. AFAICT, the issue is that VAR=value some_command is not valid cmd syntax, and the exec form in use goes through the shell, which is cmd in the windows case. I believe the correct fix is to use the version that does not go through cmd:
newenv = { "NODE_PATH" => NODE_MODULES_PATH }
cmdline = [WEBPACK_BIN, "--config", WEBPACK_CONFIG] + ARGV
Dir.chdir(APP_PATH) do
exec newenv, *cmdline
end
@fsateler Thanks ๐ Want to make a PR for this?
https://github.com/rails/webpacker/pull/361 here I use @rubys method to fix the other shell commands in the install scripts. Otherwise the yarn dependencies aren't actually added.
I'm not sure this issue should be closed. I'm still getting the same error when loading webpacker from the Github repository in my Gemfile.
@fny Did you upgrade the config files after updating from master?
Gemfile
gem 'webpacker', github: 'rails/webpacker'
(update/replace all files prompted)
bundle update webpacker
bundle exec rails webpacker:install
Just tried that and it made no difference. I still see the following error when I try to start the tests:
ActionView::TemplateError:
Exec format error -- ./bin/webpack
I see the Exec format error when I try to run the dev server to: ./bin/webpack-dev-server
Note this is with a repository that's already working without any issue on my 'nix machines.
ruby ./bin/webpack-dev-server you are running this from command line?
Not with ruby prefixed.
On Jul 25, 2017 5:41 PM, "Gaurav Tiwari" notifications@github.com wrote:
ruby ./bin/webpack-dev-server you are running this from command line?
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rails/webpacker/issues/245#issuecomment-317881167,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAVH1KRis8esufYh0YKYLnl3RHnr8QYWks5sRmEUgaJpZM4M3n_M
.
Most helpful comment
It seems this issue has been closed in error, as only the webpacker:install command appears to have been fixed, but
bin/webpack*have not. AFAICT, the issue is thatVAR=value some_commandis not valid cmd syntax, and theexecform in use goes through the shell, which is cmd in the windows case. I believe the correct fix is to use the version that does not go through cmd: