Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binstubs installed into wrong directory #995

Closed
cjlarose opened this issue Nov 6, 2017 · 9 comments
Closed

Binstubs installed into wrong directory #995

cjlarose opened this issue Nov 6, 2017 · 9 comments

Comments

@cjlarose
Copy link

cjlarose commented Nov 6, 2017

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.

@gauravtiwari
Copy link
Member

Closing. Merged #990 👍

@cjlarose
Copy link
Author

cjlarose commented Nov 6, 2017

@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.

@gauravtiwari
Copy link
Member

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

@sadelokiki
Copy link

@gauravtiwari are the binstubs now being installed?

@gauravtiwari
Copy link
Member

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

@gavargas22
Copy link

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?

@gauravtiwari
Copy link
Member

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

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

@gavargas22
Copy link

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

@elliotcm
Copy link

elliotcm commented Dec 9, 2017

👍 Same issue when using BUNDLE_BIN in my bundler config, master branch (a61f8fe) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants