Webpacker: cannot run `./bin/webpack` use bundler v2

Created on 13 Feb 2019  路  10Comments  路  Source: rails/webpacker

As here said Bundler updated to v2 on January 2019.
When I installed bundler v2, I cannot run ./bin/webpack directly, and returns error like

$ ./bin/webpack
You must use Bundler 2 or greater with this lockfile.

BTW, bundle exec ./bin/webpack still works.

Most helpful comment

I was able to use bundler v2 by adding require 'bundler' right before the require 'bundler/setup' line in both, bin/webpack and bin/webpack-dev-server

All 10 comments

I was able to use bundler v2 by adding require 'bundler' right before the require 'bundler/setup' line in both, bin/webpack and bin/webpack-dev-server

That's not an issue with Webpacker. That's Bundler telling you that your Gemfile.lock file was created by Bundler v2, however the major version of Bundler you're using is less than 2.

https://github.com/bundler/bundler/blob/v2.0.1/lib/bundler/lockfile_parser.rb#L108

Run bundle --version to see which version of Bundler is on your PATH.

I ran into this issue with webpacker as well, full issue here: https://github.com/bundler/bundler/issues/6937

The solution is to add require 'bundler' as @consti mentions, or (once it's released) to upgrade to Ruby 2.6.2.

Ruby 2.5.3
Bundler 2.0.1
Webpacker 4.0.0-rc.7

No issues.

@jpickwell the issue only occurs if you have more than one version of bundler installed (under the same version of ruby). E.g. in your setup you can probably replicate the issue by doing a gem install bundler --version '< 2.0'.

@consti

$ gem list
...
bundler (2.0.1, default: 1.17.3)
...

@jpickwell if you have Bundler as a default gem I鈥檓 pretty sure you鈥檙e on 2.6, not 2.5

@connorshea, I don't have 2.6 installed. I did upgrade gem: gem update --system

A lot of projects are having this problem, this advice from Jekyll worked for me: https://github.com/jekyll/jekyll/issues/7463#issuecomment-451686361

So the solution presented in that comment is running gem update --system.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Eearslya picture Eearslya  路  3Comments

suhomozgy-andrey picture suhomozgy-andrey  路  3Comments

ilrock picture ilrock  路  3Comments

johan-smits picture johan-smits  路  3Comments

suhomlineugene picture suhomlineugene  路  3Comments