Webpacker: Binstubs installed into wrong directory

Created on 6 Nov 2017  路  9Comments  路  Source: rails/webpacker

I'm experiencing a similar problem to @monad-y in #990. The regression appears to be introduced in version 3.0.2 with #833. When running bundle exec webpacker:install for the first time, I'm getting a message like

Skipped webpack and webpack-dev-server since they already exist.
If you want to overwrite skipped stubs, use --force.

even when files do not exist at ./bin/webpack or ./bin/webpack-dev-server under the Rails root.

Here's a Dockerfile that demonstrates a repro

FROM ruby:2.3.5-alpine

RUN apk update && apk add --no-cache build-base nodejs sqlite-dev
RUN npm install -g yarn
RUN gem install rails

WORKDIR /app

RUN rails new /app
RUN sed -i "s/gem 'tzinfo-data'.*//" Gemfile
RUN bundle
RUN echo "gem 'tzinfo-data'" >> Gemfile
RUN echo "gem 'webpacker', '~> 3.0'" >> Gemfile
RUN bundle

RUN bundle exec rails webpacker:install

CMD bundle exec rails webpacker:check_binstubs

Build the image and run the container

$ docker build -t bug .
$ docker run --rm -ti bug
Webpack binstubs not found.
Have you run rails webpacker:install ?
Make sure the bin directory or binstubs are not included in .gitignore
Exiting!

If you get into the container, you'll find that no files were written to /app/bin/webpack or /app/bin/webpack-dev-server, but instead executables are available at /usr/local/bundle/bin/webpack and /usr/local/bundle/bin/webpack-dev-server.

In other words, the installation process creates executables alongside other gem executables (like rails and rake), but the task webpacker:check_binstubs seems to expect files in the ./bin subdirectory of the Rails root.

If you modify the Dockerfile to install webpacker 3.0.1 instead of 3.0.2 (current latest), the binstubs are installed into the ./bin subdirectory of the Rails root.

RUN echo "gem 'webpacker', '= 3.0.1'" >> Gemfile
$ docker run --rm -ti bug
$ echo $?
0

I think the intent of #833 was to install the webpack and webpack-dev-server scripts in the ./bin subdirectory, not alongside other gem executables. If that's the case, then I think #990 should be closed in favor of a PR that fixes the place where the binstubs are installed.

Most helpful comment

Alright I see, going to take a closer look at this later today 馃憤

All 9 comments

Closing. Merged #990 馃憤

@gauravtiwari I actually expected that PR to not be merged. The README for the project still references binstubs being available at ./bin/webpack and ./bin/webpack-dev-server, but those binstubs are not being installed anymore.

Alright I see, going to take a closer look at this later today 馃憤

@gauravtiwari are the binstubs now being installed?

@sadelokiki Yes it should, unless you have modified binstubs path, see: http://bundler.io/v1.10/bundle_binstubs.html

Hey guys, so I am having the same issue as described above when running rails webpacker:install:react. I also get the message that my binstubs are not present. How did you manage to fix it?

@gavargas22 What version of webpacker are you using? Please could you try latest master.

gem 'webpacker', github: 'rails/webpacker'

@gauravtiwari It seems that solved my issue, using the latest master. Thanks for your help!

馃憤 Same issue when using BUNDLE_BIN in my bundler config, master branch (https://github.com/rails/webpacker/commit/a61f8fe3964e4ed06829118d1f706f12a95008ab) sorted me out.

In this particular case (and perhaps the others?) it wasn't that the stubs were installed in the wrong place so much as they were being looked for in the default location when installed elsewhere by bundler.

Was this page helpful?
0 / 5 - 0 ratings