When I run webpack, I get the following error:
webpack config /Users/nicholas/cs_projects/content-editor/config/webpack/development.js not found, please run 'bundle exec rails webpacker:install' to install Webpacker with default configs or add the missing config file for your custom environment.
This appears to be a webpacker error. Why this is affecting webpack, I have no idea.
Did you follow the instruction: please run 'bundle exec rails webpacker:install' to install Webpacker with default configs or add the missing config file for your custom environment.
Can you show us the repo and how you recreate this?
No. This is not a Rails specific issue. I’m trying to run webpack in a
completely non Rails, non Ruby context (writing an npm package). Running
bundle exec rails webpacker:install will do nothing.
On Tue, Jan 9, 2018 at 21:06 Bryan Lim notifications@github.com wrote:
Did you follow the instruction: please run 'bundle exec rails
webpacker:install' to install Webpacker with default configs or add the
missing config file for your custom environment.Can you show us the repo and how you recreate this?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/rails/webpacker/issues/1165#issuecomment-356477417,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHBFpxwusHJTAD-X9ismx9DKdKYkoG1Iks5tJBszgaJpZM4RYh2l
.
Webpacker is built in/for Ruby/Rails so don't think it will work outside of it.
If you’re using Bash, your shell may have cached bin/webpack from a Rails project as the location of the webpack executable. It does this to avoid relatively costly $PATH searches.
Are you using Bash? If so, add set +h to your ~/.bash_profile to disable hashing, then open a new shell.
Okay, I figured out the cause of the issue.
@gauravtiwari, I don't think you understood in the slightest my issue. I am NOT trying to use webpacker outside of Ruby or Rails, I am NOT even trying to use webpacker. I'm simply attempting to use Webpack, good, normal old Webpack, and your gem is breaking that.
@georgeclaghorn, thank you for that advice, made me remember that I can just look up the source of the executable with which webpack. Basically, webpacker installs two binstubs: webpack and webpack-dev-server. But guess what? That happens to be the exact commands that Webpack uses. Y'know, Webpack, the thing you guys are building on? So if you have the misfortune of installing Webpacker globally, which, I stupidly did, then you break Webpack. I'd highly suggest not doing that.
So yeah. Please don't name binstubs common executable names. It just creates a whole bunch of shadowing issues. Granted, I also have an npm issue at hand, but I do think naming your binstubs webpack and webpack-dev-server is asking for trouble. Why not webpacker and webpacker-dev-server?
@NicholasLYang Forgive me but this is what you wrote:
Comment1:
When I run webpack, I get the following error:
webpack config /Users/nicholas/cs_projects/content-editor/config/webpack/development.js not found, please run 'bundle exec rails webpacker:install' to install Webpacker with default configs or add the missing config file for your custom environment.
This appears to be a webpacker error. Why this is affecting webpack, I have no idea.
Comment2:
No. This is not a Rails specific issue. I’m trying to run webpack in a
completely non Rails, non Ruby context (writing an npm package). Running
`bundle exec rails webpacker:install` will do nothing.
I’m trying to run webpack in a
completely non Rails, non Ruby context (writing an npm package
I hope you understand that the above is not enough information to tell anything about the problem you are having.
Perhaps, consider uninstalling webpacker gem to remove executables from global namespace?
gem uninstall webpacker
@NicholasLYang Thank you for surfacing this issue. Your suggestions make sense. But, whether it was intended or not, it would be easy to interpret the wording of some of your comments as a bit harsh or, at best, unnecessarily sarcastic. Please consider the maintainers of this project are doing everything they can with what little time they have to help and respond to issues like yours and others as well.
@gauravtiwari, yes I uninstalled Webpacker. Didn't fix my issue, but at this point, that's not Webpacker's fault, so not going to post it here. I'm not entirely sure how "I'm trying to run webpack in a completely non Rails, non Ruby context" is ambiguous, since I didn't say "I'm trying to run webpacker in a completely non Rails, non Ruby context", which _would_ be rather confusing. Nonetheless, I do see that I was unnecessarily vague in my first post. I'll try to be more clear from now on. To clarify, I was attempting to run Webpack, the Javascript library for bundling, but Webpacker, the Ruby wrapper for the Javascript library, was interfering with it.
@rossta Fair point, I'm sorry. I find it very frustrating that a tool that came with Rails is breaking a fair portion of my JavaScript projects. More than a little harmful to productivity. Thank you for all the work you guys put into making Rails great.
I have this same issue how can i fix it?
gem uninstall webpacker
@NicholasLYang
I had the same problem. I was trying out Webpacker in another branch and upon switching back out of that branch, your original error message appeared. a quick which webpack found it in /user/nik/.rvm/gems/ruby-2.4.1@sync/bin/webpack. A gem uninstall webpacker, which also prompted for removal of these two executables, did the trick. Hope that helps
Hello everyone - I've been primarily developing with Ruby/Rails for the past year and encountered the same problem. When I run which webpack it shows as a .gem in my user directory. Would I need to run gem uninstall webpacker in this directory then reinstall it under the directories where my Ruby projects are at in order to avoid getting this error for non-Ruby projects in the future?
Edit: I was able to resolve my issue so this does not need a response.
Is there a way to reset the global reference after uninstall? I uninstalled, but now my webpack projects ignore the webpack entry in their package.jsons and instead fails, stating that the /Users/me/ruby-x.x.x/bin/webpack doesn't exist.. It is completely loudacris, in my humble opinion, to override the global webpack installation with a ruby gem and for the same reason I'll not use webpacker again.
@ViggoV The global executables are removed in latest release. You would need to update binstubs after update, please see changelog.
bundle update webpacker
yarn add @rails/webpacker
bundle exec rails webpacker:binstubs # should replace old exe
I think I'm stuck in purgatory. When I try the steps above, I still run into the following when trying to run webpack
2: from /Users/philipjohnson/.rbenv/versions/2.5.0/bin/webpack:23:in `<main>'
1: from /Users/philipjohnson/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/philipjohnson/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem webpacker (>= 0.a) with executable webpack (Gem::GemNotFoundException)
@pjatx Have you updated the gem to the latest version? (make sure it's has new version specified in Gemfile)
@gauravtiwari Yeah, this is actually not a rails project as other posters have mentioned.
I did uninstall webpacker, then ran into this and did the following with no success:
I didn't, however, specify a version of webpacker. Should I try the above again doing so?
@pjatx Ahh, sorry totally forgot.
Is it possible you might have multiple versions of webpacker installed in different ruby versions?
@gauravtiwari Yeah it's definitely possible - I use rbenv to as my Ruby version manager
Curious, "this is actually not a rails project" May I know which ruby project is this? @pjatx
update: ok, got you. You used webpacker and it breaks your webpack.
@ytbryan It's not a ruby project either - it's all javascript / templates.
This is because you still have the webpacker shim installed by rbenv in your shell's $PATH: /Users/philipjohnson/.rbenv/versions/2.5.0/bin/webpack
First you need to uninstall Webpacker as it seems to have been installed globally: gem uninstall -a webpacker.
Then, if not already deleted, you can safely remove it: rm /Users/philipjohnson/.rbenv/versions/2.5.0/bin/webpack
Thanks @renchap that finally fixed my issue!
Any chance that the rails app's bin/webpack can have a different name so as not to conflict? This one has hit me as well, and many others.
Yep, this was fixed in 3.3.0: https://github.com/rails/webpacker/blob/3-x-stable/CHANGELOG.md#330---2018-03-03 and PR: https://github.com/rails/webpacker/pull/1286
Most helpful comment
Okay, I figured out the cause of the issue.
@gauravtiwari, I don't think you understood in the slightest my issue. I am NOT trying to use webpacker outside of Ruby or Rails, I am NOT even trying to use webpacker. I'm simply attempting to use Webpack, good, normal old Webpack, and your gem is breaking that.
@georgeclaghorn, thank you for that advice, made me remember that I can just look up the source of the executable with
which webpack. Basically, webpacker installs two binstubs: webpack and webpack-dev-server. But guess what? That happens to be the exact commands that Webpack uses. Y'know, Webpack, the thing you guys are building on? So if you have the misfortune of installing Webpacker globally, which, I stupidly did, then you break Webpack. I'd highly suggest not doing that.So yeah. Please don't name binstubs common executable names. It just creates a whole bunch of shadowing issues. Granted, I also have an npm issue at hand, but I do think naming your binstubs
webpackandwebpack-dev-serveris asking for trouble. Why notwebpackerandwebpacker-dev-server?