如何恢复我的Rails 4 binstubs?

时间:2015-10-22 12:50:54

标签: ruby-on-rails ruby-on-rails-4

我在某些时候重新生成了binstubs。曾经是Spring完美无缺地工作,在我第一次启动Rails控制台后,控制台会立即出现。

现在看来Spring已不再运行了。

当我输入:

rails console

我明白了:

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)> 

如果我输入:

spring rails console

我收到相同的消息,但是不是控制台出现了,我只是返回命令行。

如何在新的Rails应用程序中使用此命令?

3 个答案:

答案 0 :(得分:14)

我不想删除整个bin目录,它已添加到git。所以我跑了:

rake rails:update:bin

消息消失了。

答案 1 :(得分:1)

每个

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

请注意,“-binstubs选项具有粘性,这意味着在将来仅运行捆绑安装时,Bundler会继续为新的gem添加binstubs”。该配置存储在.bundle / config下。对于https://coderwall.com/p/vhfxia/generate-only-the-binstubs-that-your-project-needs,建议bundle binstubs [gem_name]仅安装所需的gem的binstub。

答案 2 :(得分:1)

使用导轨 6:rails app:update:bin