Capistrano: Can I set an environment variable for the whole cap session?

后端 未结 5 800
遇见更好的自我
遇见更好的自我 2020-11-29 02:29

I\'ve got a staging server with both standard Ruby and Ruby Enterprise installed. As standard Ruby refuses to install a critical gem, I need to set $PATH so that ruby/gem/r

5条回答
  •  被撕碎了的回忆
    2020-11-29 02:51

    I needed to set an environment variable for a specific task to work. The "run" command allows you to pass options which include :env:

    run "cmd", :env => { 'name' => 'value' }
    

    In my case, I wanted to add the environment variable to a task that I didn't write, so I used default_run_options which is used by all invocations of run. I added this to the top of my Capfile:

    default_run_options[:env] = { 'name' => 'value' }
    

提交回复
热议问题