Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I restore my Rails 4 binstubs?

I regenerated my binstubs at some point. It used to be that Spring worked flawlessly and after the first time I brought up a Rails console, the console would come up instantly.

Now it appears that Spring is no longer running.

When I type:

rails console

I get:

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

Loading development environment (Rails 4.2.3)
[1] pry(main)> 

If I type:

spring rails console

I get the same message, but instead of the console coming up I just get returned to the command line.

How can I get this command working the way it does in a new Rails app?

like image 205
AKWF Avatar asked Oct 22 '15 12:10

AKWF


3 Answers

I didn't want to delete my whole bin directory, and it was already added to git. So I just ran:

rake rails:update:bin

and the messages went away.

like image 63
AKWF Avatar answered Oct 20 '22 04:10

AKWF


bundle install --binstubs per https://bundler.io/v1.17/man/bundle-install.1.html

Note that "the --binstubs option is sticky, meaning Bundler will keep adding binstubs for new gems in the future when you run just bundle install". That config is stored under .bundle/config. Per https://coderwall.com/p/vhfxia/generate-only-the-binstubs-that-your-project-needs, it's recommended to bundle binstubs [gem_name] to install only the desired gem's binstubs instead.

like image 31
konyak Avatar answered Oct 20 '22 05:10

konyak


with rails 6: rails app:update:bin

like image 3
Dorian Avatar answered Oct 20 '22 05:10

Dorian