简体   繁体   中英

How do I set environment variables in Capistrano 3?

In Capistrano 2, you could do something like this:

set :default_environment, {
  'PATH' => '$PATH:/opt/rubies/ruby-2.1.1/bin'
}

Is there an equivalent in cap 3?

use:

set :default_env, {
  'PATH' => 'PATH=$PATH:/opt/rubies/ruby-2.1.1/bin'
}

as of at least capistrano 3.1

Perhaps a bit late but...

Capistrano 3 uses a specia syntax for environment

on roles :app do
  with some_env: "foobar" do
    ...
  end
end

In the above example, within the with/end block capistrano sets the environment variable SOME_ENV to "foobar"

see https://github.com/capistrano/sshkit#users-working-directories-environment-variables-and-umask

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM