1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

direnvの導入

Last updated at Posted at 2019-09-29

目的

リポジトリごとの環境変数を管理するためにdirenvの導入手順に
ついて備忘録を書いておく。

詳細な部分は本体のリポジトリを参照すること
https://github.com/direnv/direnv

バイナリの導入

https://github.com/direnv/direnv/releases
にアクセスして最新のバイナリを取得する。

direnvバイナリの取得と導入
$ wget https://github.com/direnv/direnv/releases/download/v2.20.0/direnv.linux-amd64
$ chmod +x direnv.linux-amd64
$ sudo mv direnv.linux-amd64 /usr/local/bin/direnv

.bashrcへの記述追加

.bashrcの末尾に以下の記述を追加

.bashrc
eval "$(direnv hook bash)"

リポジトリに.envrcファイルを準備する

.envrcファイルの作成
$ touch .envrc

あとは.envrc内部で必要な環境変数を定義する。

有効化

.envrcファイルの存在するディレクトリにアクセスすると警告が表示されるので、
direnv allowで環境変数の読み込みを許可する。

.envrcファイルの読み込み許可
$ direnv allow
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?