Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

system("tar -czf #{RAILS_ROOT}/tmp/export-result #{RAILS_ROOT}/tmp/export")

When I decompress the resulting file I get


I would like to just get:


How do I change my TAR call to accomplish this?


system("tar -czf #{RAILS_ROOT}/tmp/export.tgz --directory=#{RAILS_ROOT}/tmp export/")

share|improve this question
up vote 3 down vote accepted

This is how you do it,

tar cfz target.tgz --directory=TARGET_DIR subdir_list

In your case it would look like,

tar cfz target.tgz --directory=app/c3ec2057-7d3a-40d9-9a9d-d5c3fe3ffd6f/home/tmp export/
share|improve this answer
So, first I specify where I want to save the result 'target.tgz' then I specify where the contents are and what subdirs should be removed. Correct? – Nerian Feb 19 '11 at 13:28
This is an app hosted at Heroku, so the only place where I can write is RAILS_ROOT/tmp/ how do I write it so that target.tgz end up there? – Nerian Feb 19 '11 at 13:31
I did it: system("tar -czf #{RAILS_ROOT}/tmp/export.tgz --directory=#{RAILS_ROOT}/tmp export/") – Nerian Feb 19 '11 at 13:43
right! Good for you :-) – nik Feb 19 '11 at 18:27

Change to #{RAILS_ROOT} before compression and don't specify it in the source files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.