Cannot adjust $0 without breaking rake #3332

Closed
tal opened this Issue Oct 14, 2011 · 3 comments

Projects

None yet

2 participants

@tal
tal commented Oct 14, 2011

The assets rake tasks re-run themselves after fixing the environment variables. This makes it impossible to change $0 at all. It's a variable so the code shouldn't assume that it's remained the same.

@drogus
Member
drogus commented Mar 31, 2012

@Talby can you post an example on what you're trying to achieve and what does exactly fail?

@tal
tal commented Mar 31, 2012

@drogus If in my own app i set $0 to something manually, and then try and do the example rake task if fails since $0 != the command used to run the rake task.

@drogus
Member
drogus commented May 12, 2012

@Talby I've looked into this and the reason is that assets:precompile tries to rerun some of the tasks. I've managed to fix part of the problem and opened a pull request for sprockets-rails.

What assets:precompile essentially does is running 2 other tasks:

rake assets:precompile:primary
rake assets:precompile:nondigest # only if you use digests

If you would like to avoid using $0, you can just run those 2 tasks with proper env vars:

rake assets:precompile:primary RAILS_ENV=production RAILS_GROUPS=assets
rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets

If you do that, rake tasks should not be rerun with $0 usage.

I'm closing this issue, since this is a problem with sprockets-rails. My pull request will fix the problem with running those 2 tasks, but after it's applied you will still need to set RAILS_ENV and RAILS_GROUPS env variables in order to avoid restarting - this will not be likely fixed soon.

@drogus drogus closed this May 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment