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 3 years have passed since last update.

ローカル環境で環境変数を使ったBasic認証が通らない件

Last updated at Posted at 2021-06-04

タイトルの通りである。application_controller.rbにユーザー名とパスワードを直接設定してた時は問題なく動作したんだが、.zshrcの中で環境変数を利用して設定した途端に動作しなくなった。クッキーやキャッシュを削除したりブラウザを変えたり訳もなくファイルの中身を編集したりしたんだが決してうまくいかなかった...

結論

こちらの方の記事に全てが書いてありました。もう自分の方で書くことは何もありません...(笑)

前提条件

  • macOS Catalina ( 10.15.7 )
  • Visual Studio Code.app( 1.56.2 )
  • Terminal.app ( 2.10 )
  • Rails ( 5.2.6 )

※執筆時のバージョン

本題

要は、vim ~/.zshrcでファイルを編集した後に、source ~/.zshrcでリロードして定義した環境変数を使えるようにするのだが、rails sでサーバーを起動するターミナルで*.zshrcが更新されてなけりゃ結局のところそれらは無いに等しい。サーバー起動用のターミナルが既に存在しているという事は、言い換えればログインシェルである『zsh』が既に一度実行された事を意味する。そのため編集したファイルに環境変数が追加されているのなら、それらを反映させる必要があるのでsourceコマンドを使ってもう一度.zshrc*を実行する必要があるのである。

参考記事

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?