LoginSignup
6
3

More than 5 years have passed since last update.

rubyプロジェクトのbin/console, bin/setup はバイナリじゃなくスクリプトだった

Posted at
bundle gem sample_sample

でrubyプロジェクトを作成するとこんな感じになります。スクリーンショット 2016-10-15 1.57.55 PM.jpg

このbin配下には、console , setup があって

スクリーンショット 2016-10-15 2.11.30 PM.jpg

./bin/console

を実行するとirbが

2.3.0 :001 > 

一方

./bin/setup

を実行するとbundle installが動きます。

bundle install
+ bundle install
Resolving dependencies...
Using rake 10.5.0
Using bundler 1.11.2
Using sample_project 0.1.0 from source at `.`
Bundle complete! 3 Gemfile dependencies, 3 gems now installed.
Bundled gems are installed into ./vendor/bundle.

# Do any other automated setup that you need to do here

というのも
BundlerでRubygemsとGitHubに公開してみる
にて、

bin/setupはbundle installを実行するもので、その他のセットアップ処理を追加する場合は、こちらを利用しましょう。

とあり、どうやってやるんだ??と思って調べていたところ

Ruby on Rails 4.2 リリースノート

bin/setupスクリプトが導入されました。これはアプリケーションの初期設定時に設定を自動化するためのコードの置き場所となります。

とあり、やっとここで

vim ./bin/setup

すると

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here

ここに追加すればいいんですね!

ちなみに./bin/console

#!/usr/bin/env ruby

require "bundler/setup"
require "sample_project"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "irb"
IRB.start

IRBやってるだけ!!!!

6
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3