I’ve created a directory with some sub directories and in those nice little sub directories are some files.
I’d like to take that robust root directory and zip it up nicely into a .tgz file.
The code I have is tar cvzf('/Users/me/Desktop/things.tgz', '/Users/me/Desktop/')
Googling for the error undefined method ‘cvzf’ for main:Object hasn’t yielded anything
The error correctly described your problem: you’re calling a method called
cvzfwith the two file paths as arguments, however there is no such method in Ruby. (Ruby also doesn’t know whattaris, but the other error happens to be caught first)If all you want to do is call a shell command from within a Ruby script, just enclose the command in backquotes like this:
However that will only work if your system has the tar program. Otherwise you could try installing some Ruby gems that add tar capabilities to Ruby.