LoginSignup
25
27

More than 5 years have passed since last update.

mac でdirenv を使用する

Posted at

direnvの準備

  • direnvのインストール
    $ brew install direnv

  • ~/.bashrcに下記を追記
    eval "$(direnv hook bash)"

  • bashrc再読み込み
    $ source ~/.bashrc

direnvを使う

  • 使いたいプロジェクトのディレクトリに.envrcファイルを作成する
  • .envrcに使いたい環境変数を下記のように記述する
    export 環境変数名=値

  • .envrcを有効化する
    $ direnv allow .

  • .gitignoreに追記
    .envrc

.direnv例

export PGHOST=localhost
export PGDATABASE=railsapp_development
export PGDATABASE_TEST=railsapp_test
export PGUSER=
export PGPASSWORD=
export PGPORT=
export SECRET_KEY_BASE=hogehoge
25
27
0

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
25
27