ActiveFlagのテストでrequire 'set'が必要かもという問題。

人によって結果が違うのなぜかな〜という状態だったんですが、(実行していただいた方々ありがとうございます)

bundler 2.2.8でrequire 'set'がなくなったのが原因だそうです。

https://github.com/kenn/active_flag/pull/19#issuecomment-1025093171

Image from Gyazo

この行。

https://github.com/rubygems/rubygems/pull/4297/files#diff-04ae823e98259f697c78d2d0b4eab0ced6a83a84a986578703eb2837d6db1a32L4

ほぼ標準といえるようなgemから依存がなくなるとこういうことが起きるんですね。setについて他のライブラリでも似たようなこと起きてるかもしれません。環境を示すときはbundlerのバージョンも示した方がいいんだなと勉強になりました。

一時期は乱立したgemのgeneratorをbundle gemがほぼ統一。travisのファイルが入ってたり、Code of Conductが入ったり、rspecかminitestか選べたりといろいろ新しくなってました。

% bundle gem google-search_rank
Creating gem 'google-search_rank'...
Do you want to include a code of conduct in gems you generate?
Codes of conduct can increase contributions to your project by contributors who prefer collaborative, safe spaces. You can read more about the code of conduct at contributor-covenat.org. Having a code of conduct means agreeing to the responsibility of enforcing it, so be sure that you are prepared to do that. For suggestions about how to enforce codes of conuct, see bit.ly/coc-enforcement. y/(n): y
Do you want to license your code permissively under the MIT license?
This means that any other developer or company will be legally allowed to use your code for free as long as they admit you created it. You can read more about the MIT license at choosealicense.com/licenses/mit. y/(n): y
Do you want to generate tests with your gem?
Type 'rspec' or 'minitest' to generate those test files now and in the future. rspec/minitest/(none): minitest
      create  google-search_rank/Gemfile
      create  google-search_rank/.gitignore
      create  google-search_rank/lib/google/search_rank.rb
      create  google-search_rank/lib/google/search_rank/version.rb
      create  google-search_rank/google-search_rank.gemspec
      create  google-search_rank/Rakefile
      create  google-search_rank/README.md
      create  google-search_rank/bin/console
      create  google-search_rank/bin/setup
      create  google-search_rank/CODE_OF_CONDUCT.md
      create  google-search_rank/LICENSE.txt
      create  google-search_rank/.travis.yml
      create  google-search_rank/test/minitest_helper.rb
      create  google-search_rank/test/test_google/search_rank.rb
Initializing git repo in /Users/komagata/code/google-search_rank

一回選択したら設定ファイルに書かれるみたいです。

% cat ~/.bundle/config 
---
BUNDLE_GEM__COC: true
BUNDLE_GEM__MIT: true
BUNDLE_GEM__TEST: minitest

もちろん僕はminitestちゃん!

gemは問題無くできるものの、CIがエラー。

$ bundle exec rake
/home/vagrant/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:143:in `block in replace_gem': rake is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /home/vagrant/.rvm/gems/ruby-1.9.2-p290/bin/rake:18:in `
' Done. Build script exited with: 1

よく見ればちゃんと書いてある。

# gemspec:
s.add_development_dependency 'rake', '~> 0.9.2.2'
s.add_development_dependency 'rdoc', '~> 3.11'

Tracis-CIでrakeとrdoc使うからdevelopment_dependencyには入れとかなきゃいけない。

Using Capistrano with rvm and bundler.

rvm

# config/deploy.rb:
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))

require 'rvm/capistrano'

set :rvm_ruby_string, 'ruby-1.8.7-p352@kowabana' # Add gemset name if you want to use gemset.
set :rvm_type, :user # If rvm didn't installed to system wides.

bundler

# config/deploy.rb:
require 'bundler/capistrano'

It's all. When run cap deploy:update, Capistrano install gem in shared/bundle.