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

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

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

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

Confusion opened this issue May 23, 2014 · 43 comments

Comments

@Confusion
Copy link

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
Copy link

shaneog commented May 29, 2014

👍

1 similar comment
@blackjid
Copy link

👍

@tisba
Copy link

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
Copy link

👍

1 similar comment
@janraasch
Copy link

👍

@hejhugo
Copy link

hejhugo commented Jun 16, 2014

👍 😄

@jweslley
Copy link

👍

@jweslley
Copy link

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
Copy link
Member

I'm using the same technique as @jweslley

@janraasch
Copy link

Same here :)

@ivanovv
Copy link

ivanovv commented Jul 26, 2014

👍

@rdetert
Copy link

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
Copy link

maletor commented Oct 30, 2014

👍

1 similar comment
@sarkis
Copy link

sarkis commented Oct 30, 2014

👍

@nicolasgarnil
Copy link

👍

@BilalBudhani
Copy link

This would be nice to have.

@ydkn
Copy link

ydkn commented Dec 18, 2014

👍

1 similar comment
@kevmimcc
Copy link

👍

@davestephens
Copy link

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

@Confusion
Copy link
Author

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
Copy link
Member

@kirs has the final say :)

@mustmodify
Copy link

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

@tisba
Copy link

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
Copy link

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
Copy link

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
Copy link
Member

kirs commented Jan 12, 2015

Any thoughts?

@blackjid
Copy link

👍

@indirect
Copy link

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
Copy link
Member

kirs commented Jan 14, 2015

@indirect thanks!

@kirs
Copy link
Member

kirs commented Jan 22, 2015

capistrano-bundler 1.1.4 without auto binstubs generation released.

@kirs
Copy link
Member

kirs commented Jan 22, 2015

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

@unabl4
Copy link

unabl4 commented Jun 2, 2015

👍

@sunil-netsol
Copy link

👍 worked for me.

@b264
Copy link

b264 commented Aug 9, 2015

The solution from @jweslley also worked for me. 👍

@IFarhankhan
Copy link

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

@IFarhankhan
Copy link

IFarhankhan commented Feb 14, 2016

I mean the full documentation. I could not find it

@mattbrictson
Copy link
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

@IFarhankhan
Copy link

Hey thanks @mattbrictson

@u007
Copy link

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?

@IFarhankhan
Copy link

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

@waleedarshad
Copy link

(y)

@gregblass
Copy link

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
mikejohn857 added a commit to mikejohn857/angular-capistrano-project that referenced this issue Nov 25, 2022
dazralsky pushed a commit to dazralsky/capistrano that referenced this issue Aug 21, 2023
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