Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you add back set_default? #588

Closed
x-yuri opened this issue Nov 3, 2017 · 4 comments
Closed

Could you add back set_default? #588

x-yuri opened this issue Nov 3, 2017 · 4 comments

Comments

@x-yuri
Copy link

x-yuri commented Nov 3, 2017

Now I've got to do as follows:

require 'mina/multistage'   # invokes stage file (e.g., config/deploy/production.rb), which sets rails_env
require 'mina/rails'   # sets rails_env
invoke ARGV.first if fetch(:all_stages).include?(ARGV.first)   # invoke stage file again to set rails_env again
puts fetch(:rails_env)

With set_default it could be this way:

require 'mina/multistage'   # invokes stage file (e.g., config/deploy/production.rb)
require 'mina/rails'   # set_default's rails_env
puts fetch(:rails_env)

Is there any reason not to add set_default? Or set rails_env this way:

set :rails_env, 'production' unless set?(:rails_env)
@d4be4st
Copy link
Member

d4be4st commented Jan 26, 2018

you can use environment variables to override mina variables:

https://github.com/mina-deploy/mina/blob/master/docs/how_mina_works.md#variables

@d4be4st d4be4st closed this as completed Jan 26, 2018
@x-yuri
Copy link
Author

x-yuri commented Jan 26, 2018

You may specify additional variables in the KEY=value style, just like any other command line tools

Just like some Ruby tools do. Am I missing something? In Linux environment variables generally precede command name.

Is there any reason not to add set_default?

And most of all, how do environment variables address the issue? I'd like to store variables in stage files, but don't want to load stage file twice. It doesn't look good. And might actually break sometime.

@d4be4st
Copy link
Member

d4be4st commented Jan 26, 2018

Just like some Ruby tools do. Am I missing something? In Linux environment variables generally precede command name.

Yes, those are linux env variables and they can be before or after.

Is there any reason not to add set_default?

And most of all, how do environment variables address the issue? I'd like to store variables in stage files, but don't want to load stage file twice. It doesn't look good. And might actually break sometime.

Oh, i misread your issue, your issue is that mina/multistage and mina/rails set the same variable twice.
The fix for that is to require mina/multistage after the mina/rails which actually is the preferred way to do.

so

require 'mina/rails'   # set_default's rails_env
require 'mina/multistage'   # invokes stage file (e.g., config/deploy/production.rb)
puts fetch(:rails_env)

@x-yuri
Copy link
Author

x-yuri commented Jan 26, 2018

Could you please answer my question? Is there any reason not to add set_default?

And in any case, why don't we make mina/rails set rails__env only if unset? I can make a PR. This seems like a better solution:

set :rails_env, 'production' unless set?(:rails_env)

That way mina/multistage may always come first. No need for exceptions. It seems like a good idea for scripts (particularly, mina/rails) to take into account what was set before.

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

No branches or pull requests

2 participants