From: Stefano Crocco Date: 2008-03-19T20:10:09+09:00 Subject: Re: using system to echo "hello world" gives SystemStackError On Wednesday 19 March 2008, Thufir wrote: > I can't fathom this error regarding the stack: > > thufir@arrakis:~/sun_tutorial$ > thufir@arrakis:~/sun_tutorial$ cat build.rb > require 'compile' > > > compile > thufir@arrakis:~/sun_tutorial$ > thufir@arrakis:~/sun_tutorial$ cat compile.rb > def compile > system(echo compile) > end > thufir@arrakis:~/sun_tutorial$ > thufir@arrakis:~/sun_tutorial$ ruby build.rb > ./compile.rb:2: warning: parenthesize argument(s) for future version > ./compile.rb:2:in `compile': stack level too deep (SystemStackError) > from ./compile.rb:2:in `compile' > from build.rb:4 > thufir@arrakis:~/sun_tutorial$ > thufir@arrakis:~/sun_tutorial$ > > > > > thanks, > > Thufir When you first call the 'compile' method, ruby tries to execute the line system(echo compile) which is interpreted as: system(echo(compile)) Now ruby needs to evaluate the arguments to the system method. It sees a single argument, that is the return value of the echo method called with the result of a call to the compile method. The first thing it needs to do is get the return value of the compile method. But the compile method calls the compile method again, and so on, which causes infinite recursion and the error message you see. A simpler example is this: def my_method my_method end Of course, this also cause an infinite recursion and a SystemStackError. Back to your compile method. My guess is that you wanted to execute the shell command echo with argument 'compile'. If this is true, you need to pass a string to system: system("echo compile") I hope this helps Stefano