Set Multiple Environmental Variables On Invocation of Rake Task

空扰寡人 提交于 2019-12-23 09:03:02

问题


I can invoke a Rake task and set a single environmental variable like this:

$ ONE=1 rake temp:both

But how do I set two environmental variables?

This doesn't work:

 $ ONE=1 TWO=2 rake temp:both 

This works, but is confusing to read:

$ ONE=1 rake temp:both TWO=2 

How can I pass more than one env before the call to rake?


回答1:


Agree with @Ernest; it should work. Here's a sample...

Sample rake task to echo vars:

task :echo_env do
  puts "VAR1: #{ENV['VAR1']}"
  puts "VAR2: #{ENV['VAR2']}"
end

Execute task:

VAR1=first VAR2=second bundle exec rake echo_env

Output:

VAR1: first
VAR2: second


来源:https://stackoverflow.com/questions/21564642/set-multiple-environmental-variables-on-invocation-of-rake-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!