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

时间:2016-09-25 05:32:37

标签: ruby-on-rails devise capistrano capistrano3

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

export DEVISE_TOKEN_AUTH_SECRET_KEY="secrethere"

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

cap production deploy

我得到了

Devise.secret_key was not set

任何想法为什么?

1 个答案:

答案 0 :(得分:2)

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/

从最后一个链接,我们看到~/.bashrc可能有用。