Skip to content

Conversation

@sugitak
Copy link

@sugitak sugitak commented Sep 23, 2015

About

This pull request adds :before option on Command, which let us run other preparation command beforehand.
Typical usage is to run source ~/.bashrc before running a command.

Problem

When I run Capistrano, I always run into the environment variable problem. I just want to read ~/.bashrc to set my $PATH, but I have to set it in my config/deploy.rb.

Adding environments variable is not always a good way. Situations I have experienced is:

  • Ruby is installed via rbenv, which means I can't run bundle exec rake unless I read ~/.bash_profile
  • Environment variables includes confidential information, so they should only be in the production servers, not in deployment codes or in deploy server

Usage

Example from the test:

irb(main):001:0> puts Command.new(:touch, 'somefile', user: 'bob', env: {a: 'b'}, in: '/var', before: 'source ~/.bashrc').to_command
cd /var && umask 007 && ( export A="b" ; sudo -u bob A="b" -- sh -c 'source ~/.bashrc ; /usr/bin/env touch somefile'

@sugitak
Copy link
Author

sugitak commented Sep 23, 2015

Used in pratical situation, there seems to be some problems left... sorry. I should be fixing the problems.

  • prerun commands takes the default_env, and the main command can't receive the env
  • want to set default_prerun, but running prerun commands before every command may break the behavior

@leehambley
Copy link
Member

Would this be better solved with the more general solution I proposed in #280 ?

@leehambley
Copy link
Member

@sugitak you didn't respond to my query 6 months ago about whether the proposed solution in #280 was viable, please report back, and/or close this issue.

@leehambley leehambley closed this Mar 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants