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

Don't generate binstubs by default when using Rails 4? #45

Closed
Confusion opened this Issue May 23, 2014 · 43 comments

Comments

Projects
None yet
@Confusion

Confusion commented May 23, 2014

When using Rails 4, the default options result in this error being raised when running a command from bin in a deployed environment:

Looks like your app's ./bin/rails is a stub that was generated by Bundler.

In Rails 4, your app's bin/ directory contains executables that are versioned
like any other source code, rather than stubs that are generated on demand.

Here's how to upgrade:

  bundle config --delete bin    # Turn off Bundler's stub generator
  rake rails:update:bin         # Use the new Rails 4 executables
  git add bin                   # Add bin/ to source control

You may need to remove bin/ from your .gitignore as well.

When you install a gem whose executable you want to use in your app,
generate it and add it to source control:

  bundle binstubs some-gem-name
  git add bin/new-executable

I have in fact checked in a bin with executables generated by Rails, but they are not used, because by default bin is symlinked to shared/bin, containing executables with bundler-generated executables. Of course it is trivial to configure bundler such that this doesn't happen, but since everyone using Rails 4 needs to do that, it would be better to just do 'the right thing' out of the box.

Do you agree and are you interested in a pull request for this?

Edit:
Also see rails/rails#8974 and specifically rails/rails#8974 (comment)

@shaneog

This comment has been minimized.

Show comment
Hide comment
@shaneog

shaneog commented May 29, 2014

👍

@blackjid

This comment has been minimized.

Show comment
Hide comment
@blackjid

blackjid commented May 31, 2014

👍

@tisba

This comment has been minimized.

Show comment
Hide comment
@tisba

tisba Jun 2, 2014

Honestly, I won't change capistrano-bundlers default behavior here. But there should be a big section in the readme, describing this issue and how to fix it.

tisba commented Jun 2, 2014

Honestly, I won't change capistrano-bundlers default behavior here. But there should be a big section in the readme, describing this issue and how to fix it.

@tonytonyjan

This comment has been minimized.

Show comment
Hide comment
@tonytonyjan

tonytonyjan commented Jun 14, 2014

👍

@janraasch

This comment has been minimized.

Show comment
Hide comment
@janraasch

janraasch commented Jun 16, 2014

👍

@Poisoned

This comment has been minimized.

Show comment
Hide comment
@Poisoned

Poisoned commented Jun 16, 2014

👍 😄

@jweslley

This comment has been minimized.

Show comment
Hide comment
@jweslley

jweslley commented Jun 28, 2014

👍

@jweslley

This comment has been minimized.

Show comment
Hide comment
@jweslley

jweslley Jun 28, 2014

My solution for now... In config/deploy.rb file:

  • add line set :bundle_binstubs, nil
  • remove bin from linked dirs set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

jweslley commented Jun 28, 2014

My solution for now... In config/deploy.rb file:

  • add line set :bundle_binstubs, nil
  • remove bin from linked dirs set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
@mattbrictson

This comment has been minimized.

Show comment
Hide comment
@mattbrictson

mattbrictson Jun 28, 2014

Member

I'm using the same technique as @jweslley

Member

mattbrictson commented Jun 28, 2014

I'm using the same technique as @jweslley

@janraasch

This comment has been minimized.

Show comment
Hide comment
@janraasch

janraasch Jun 29, 2014

Same here :)

janraasch commented Jun 29, 2014

Same here :)

@ivanovv

This comment has been minimized.

Show comment
Hide comment
@ivanovv

ivanovv commented Jul 26, 2014

👍

@rdetert

This comment has been minimized.

Show comment
Hide comment
@rdetert

rdetert Aug 29, 2014

I also had to do what @jweslley recommended. Otherwise delayed job was not getting put in the bin directory.

rdetert commented Aug 29, 2014

I also had to do what @jweslley recommended. Otherwise delayed job was not getting put in the bin directory.

@maletor

This comment has been minimized.

Show comment
Hide comment
@maletor

maletor commented Oct 30, 2014

👍

@sarkis

This comment has been minimized.

Show comment
Hide comment
@sarkis

sarkis commented Oct 30, 2014

👍

@nicolasgarnil

This comment has been minimized.

Show comment
Hide comment
@nicolasgarnil

nicolasgarnil commented Oct 30, 2014

👍

@BilalBudhani

This comment has been minimized.

Show comment
Hide comment
@BilalBudhani

BilalBudhani Nov 18, 2014

This would be nice to have.

BilalBudhani commented Nov 18, 2014

This would be nice to have.

@ydkn

This comment has been minimized.

Show comment
Hide comment
@ydkn

ydkn commented Dec 18, 2014

👍

@kevmimcc

This comment has been minimized.

Show comment
Hide comment
@kevmimcc

kevmimcc commented Dec 31, 2014

👍

@davestephens

This comment has been minimized.

Show comment
Hide comment
@davestephens

davestephens Jan 7, 2015

...insert generic "worked for me too" comment here...

davestephens commented Jan 7, 2015

...insert generic "worked for me too" comment here...

@Confusion

This comment has been minimized.

Show comment
Hide comment
@Confusion

Confusion Jan 8, 2015

So I haven't ever implemented this, since (AFAIK) no one with commit permissions has given the thumbs up. I have no idea whether there is a reasonable chance of a contribution being merged.

Confusion commented Jan 8, 2015

So I haven't ever implemented this, since (AFAIK) no one with commit permissions has given the thumbs up. I have no idea whether there is a reasonable chance of a contribution being merged.

@leehambley

This comment has been minimized.

Show comment
Hide comment
@leehambley

leehambley Jan 8, 2015

Member

@kirs has the final say :)

Member

leehambley commented Jan 8, 2015

@kirs has the final say :)

@mustmodify

This comment has been minimized.

Show comment
Hide comment
@mustmodify

mustmodify Jan 9, 2015

@tisba: I would be interested in hearing the thinking behind why it works this way.

mustmodify commented Jan 9, 2015

@tisba: I would be interested in hearing the thinking behind why it works this way.

@tisba

This comment has been minimized.

Show comment
Hide comment
@tisba

tisba Jan 9, 2015

@mustmodify not sure what you are referring to… This issue is about to change the default behavior of capistrano-bundler

tisba commented Jan 9, 2015

@mustmodify not sure what you are referring to… This issue is about to change the default behavior of capistrano-bundler

@mustmodify

This comment has been minimized.

Show comment
Hide comment
@mustmodify

mustmodify Jan 9, 2015

Sorry I wasn't clear. When I deploy, it seems that capistrano replaces my bin directory, leaving me without the files in my repo. You said, "Honestly, I won't change capistrano-bundlers default behavior here." So I assume there is some good reason why you think the current behavior is appropriate. It may be a great reason that I just don't understand. Would you care to enlighten me / us?

mustmodify commented Jan 9, 2015

Sorry I wasn't clear. When I deploy, it seems that capistrano replaces my bin directory, leaving me without the files in my repo. You said, "Honestly, I won't change capistrano-bundlers default behavior here." So I assume there is some good reason why you think the current behavior is appropriate. It may be a great reason that I just don't understand. Would you care to enlighten me / us?

@tisba

This comment has been minimized.

Show comment
Hide comment
@tisba

tisba Jan 9, 2015

I only changed the set :linked_dirs to "fix" this issue with Rails:

set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

But I have another project that uses capistrano-bundler which is not a rails project. One solution could be some kind of auto detection magic to figure out if you are deploying a rails app (or capistrano-rails could do that).

tisba commented Jan 9, 2015

I only changed the set :linked_dirs to "fix" this issue with Rails:

set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

But I have another project that uses capistrano-bundler which is not a rails project. One solution could be some kind of auto detection magic to figure out if you are deploying a rails app (or capistrano-rails could do that).

kirs added a commit to kirs/capistrano that referenced this issue Jan 12, 2015

kirs added a commit to kirs/capistrano that referenced this issue Jan 12, 2015

kirs added a commit to kirs/capistrano that referenced this issue Jan 12, 2015

kirs added a commit that referenced this issue Jan 12, 2015

Don’t generate binstubs by default
Two reasons:
1) `bin/` is often checked out into repo
2) #45 (comment)
@kirs

This comment has been minimized.

Show comment
Hide comment
@kirs

kirs Jan 12, 2015

Member

Thanks to everyone. This is really an issue.

I'm going to make 2 things:

  1. bin/ won't be recommended to be symlinked in the deploy.rb template: capistrano/capistrano#1321
  2. binstubs won't be generated by default inside capistrano-bundler: #61
Member

kirs commented Jan 12, 2015

Thanks to everyone. This is really an issue.

I'm going to make 2 things:

  1. bin/ won't be recommended to be symlinked in the deploy.rb template: capistrano/capistrano#1321
  2. binstubs won't be generated by default inside capistrano-bundler: #61
@kirs

This comment has been minimized.

Show comment
Hide comment
@kirs

kirs Jan 12, 2015

Member

Any thoughts?

Member

kirs commented Jan 12, 2015

Any thoughts?

@blackjid

This comment has been minimized.

Show comment
Hide comment
@blackjid

blackjid commented Jan 12, 2015

👍

@indirect

This comment has been minimized.

Show comment
Hide comment
@indirect

indirect Jan 12, 2015

I also recommend this. The "official recommendation" is to run bundler binstubs delayedjob (or whichever gem) to create a single binstub for the gem you need, and commit that binstub into git. Capistrano shouldn't need to generate its own binstubs, and definitely shouldn't overwrite the Rails 4 generated binstubs.

indirect commented Jan 12, 2015

I also recommend this. The "official recommendation" is to run bundler binstubs delayedjob (or whichever gem) to create a single binstub for the gem you need, and commit that binstub into git. Capistrano shouldn't need to generate its own binstubs, and definitely shouldn't overwrite the Rails 4 generated binstubs.

@kirs

This comment has been minimized.

Show comment
Hide comment
@kirs

kirs Jan 14, 2015

Member

@indirect thanks!

Member

kirs commented Jan 14, 2015

@indirect thanks!

@kirs

This comment has been minimized.

Show comment
Hide comment
@kirs

kirs Jan 22, 2015

Member

capistrano-bundler 1.1.4 without auto binstubs generation released.

Member

kirs commented Jan 22, 2015

capistrano-bundler 1.1.4 without auto binstubs generation released.

@kirs

This comment has been minimized.

Show comment
Hide comment
@kirs

kirs Jan 22, 2015

Member

Both PRs are merged. Thanks for discussion. Can be closed now.

Member

kirs commented Jan 22, 2015

Both PRs are merged. Thanks for discussion. Can be closed now.

@kirs kirs closed this Jan 22, 2015

@unabl4

This comment has been minimized.

Show comment
Hide comment
@unabl4

unabl4 commented Jun 2, 2015

👍

@sunil-netsol

This comment has been minimized.

Show comment
Hide comment
@sunil-netsol

sunil-netsol Jul 15, 2015

👍 worked for me.

sunil-netsol commented Jul 15, 2015

👍 worked for me.

@b264

This comment has been minimized.

Show comment
Hide comment
@b264

b264 Aug 9, 2015

The solution from @jweslley also worked for me. 👍

b264 commented Aug 9, 2015

The solution from @jweslley also worked for me. 👍

@Frrank1

This comment has been minimized.

Show comment
Hide comment
@Frrank1

Frrank1 Feb 14, 2016

bundle --binstubs is any off you know what this do.

Frrank1 commented Feb 14, 2016

bundle --binstubs is any off you know what this do.

@Frrank1

This comment has been minimized.

Show comment
Hide comment
@Frrank1

Frrank1 Feb 14, 2016

I mean the full documentation. I could not find it

Frrank1 commented Feb 14, 2016

I mean the full documentation. I could not find it

@mattbrictson

This comment has been minimized.

Show comment
Hide comment
@mattbrictson

mattbrictson Feb 14, 2016

Member

@Frrank1 I think the only place in the official document where binstubs is explained is here: http://bundler.io/v1.11/man/bundle-exec.1.html

Member

mattbrictson commented Feb 14, 2016

@Frrank1 I think the only place in the official document where binstubs is explained is here: http://bundler.io/v1.11/man/bundle-exec.1.html

@Frrank1

This comment has been minimized.

Show comment
Hide comment
@Frrank1

Frrank1 commented Feb 14, 2016

Hey thanks @mattbrictson

@u007

This comment has been minimized.

Show comment
Hide comment
@u007

u007 Apr 1, 2016

i think this configuration should be the default config/deploy.rb
http://stackoverflow.com/questions/36347033/rails-5-console-not-working

what do you guys think?

u007 commented Apr 1, 2016

i think this configuration should be the default config/deploy.rb
http://stackoverflow.com/questions/36347033/rails-5-console-not-working

what do you guys think?

@Frrank1

This comment has been minimized.

Show comment
Hide comment
@Frrank1

Frrank1 Apr 25, 2016

@u007 it's the same solution as @jweslley and @mattbrictson suggested.

Frrank1 commented Apr 25, 2016

@u007 it's the same solution as @jweslley and @mattbrictson suggested.

@waleedarshad

This comment has been minimized.

Show comment
Hide comment
@waleedarshad

waleedarshad commented Jun 8, 2017

(y)

@gregblass

This comment has been minimized.

Show comment
Hide comment
@gregblass

gregblass Apr 16, 2018

Thank you @jweslley. After 2+ hours fighting to get my app to deploy with webpack, removing 'bin' from linked_dirs finally worked for me.

gregblass commented Apr 16, 2018

Thank you @jweslley. After 2+ hours fighting to get my app to deploy with webpack, removing 'bin' from linked_dirs finally worked for me.

ybushmanova added a commit to NUBIC/CRR that referenced this issue May 14, 2018

ybushmanova added a commit to NUBIC/CRR that referenced this issue May 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment