Devise secret_key 未设置,即使它存在于配置文件中

Devise secret_key not set, even though it's present in profile

我的 ~/.profile 文件的第一行是:

export DEVISE_TOKEN_AUTH_SECRET_KEY="secrethere"

当我通过 SSH 登录到我的部署者帐户时,echo $DEVISE_TOKEN_AUTH_SECRET_KEY 会正常打印密钥。但是,当 运行

cap production deploy

我明白了

Devise.secret_key was not set

知道为什么吗?

Capistrano 以非登录、非交互方式建立连接 shell。它不会自动评估各种主页脚本。

这里描述了 Capistrano 如何建立连接:http://capistranorb.com/documentation/advanced-features/ptys/

此处描述了在各种 shell 模式下评估哪些文件:https://github.com/rbenv/rbenv/wiki/Unix-shell-initialization#bash

此处显示了其他一些设置环境变量的方法:Capistrano: Can I set an environment variable for the whole cap session?

这里有一个重复的问题:https://superuser.com/questions/564926/profile-is-not-loaded-when-using-ssh-ubuntu

此问题的常见问题解答部分位于:http://capistranorb.com/documentation/faq/why-does-something-work-in-my-ssh-session-but-not-in-capistrano/

从最后一个 link,我们看到 ~/.bashrc 可能有效。