Stack Level Too Deep Error (can't seem to figure it out)

Hi all,

I am running into a weird issue where my application is giving me a
stack level too deep error. I can’t seem to find where my code is
throwing this error. On the machine I developed this code on, this
error does not show up when I run rails s but when I move the code to
another system to run it this error shows up.

The system that this code runs fine on is a mac os x machine running
lion with rvm (ruby 1.9.2), rails 3.0.10.

The system that is giving me this error it is a ubuntu 10.11 using
passenger 3.0.11, apache2, rvm (ruby 1.9.2) and rails 3.0.10.

When I create a vanilla rails app on the ubuntu system, this error
does not show.

When I hit my application from the web, no matter which view I hit I
get the following error:

Showing /home/rails30/apps/vell/app/views/homes/index.html.erb where
line # raised:

stack level too deep

Extracted source (around line #):

Rails.root: /home/rails30/apps/vell
Application Trace | Framework Trace | Full Trace

activesupport (3.0.10) lib/active_support/core_ext/class/attribute.rb:
81

the development log shows:

Completed 500 Internal Server Error in 282ms

ActionView::Template::Error (stack level too deep):

Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
_trace.erb (1.9ms)
Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
_request_and_response.erb (93.8ms)
Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
template_error.erb within rescues/layout (107.0ms)

Anyone have any ideas on how I can figure out what is causing this
error? I have tried poking around but Im afraid I just can’t seem to
find it.

On 17 December 2011 07:40, Vell removed_email_address@domain.invalid wrote:

line # raised:

Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
_request_and_response.erb (93.8ms)
Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
template_error.erb within rescues/layout (107.0ms)

Anyone have any ideas on how I can figure out what is causing this
error? I have tried poking around but Im afraid I just can’t seem to
find it.

I don’t have a specific solution, but you could try using the Gemfile
from the failing app with your vanilla app so that the same gems are
used. If that breaks the vanilla app then you can find the gem that
causes the problem.

Colin

Hi Vell, good to hear you’ve got your site working! The error you are
getting is caused by Rails getting stuck in an endless loop with the
resulting stack overflow. You are probably redirecting from your page to
your controller which is redirecting to the same page which is
redirecting to the controller … redirect apparently doesn’t always do
what it says (i.e. redirect the browser), sometimes it just redirects
within the controller (if I remember correctly - I had a similar problem
a few weeks ago).

-----Oprindelig meddelelse-----
Fra: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] P vegne af Vell
Sendt: 17. december 2011 08:41
Til: Ruby on Rails: Talk
Emne: [Rails] Stack Level Too Deep Error (can’t seem to figure it out)

Hi all,

I am running into a weird issue where my application is giving me a
stack level too deep error. I can’t seem to find where my code is
throwing this error. On the machine I developed this code on, this error
does not show up when I run rails s but when I move the code to another
system to run it this error shows up.

The system that this code runs fine on is a mac os x machine running
lion with rvm (ruby 1.9.2), rails 3.0.10.

The system that is giving me this error it is a ubuntu 10.11 using
passenger 3.0.11, apache2, rvm (ruby 1.9.2) and rails 3.0.10.

When I create a vanilla rails app on the ubuntu system, this error does
not show.

When I hit my application from the web, no matter which view I hit I get
the following error:

Showing /home/rails30/apps/vell/app/views/homes/index.html.erb where
line # raised:

stack level too deep

Extracted source (around line #):

Rails.root: /home/rails30/apps/vell
Application Trace | Framework Trace | Full Trace

activesupport (3.0.10) lib/active_support/core_ext/class/attribute.rb:
81

the development log shows:

Completed 500 Internal Server Error in 282ms

ActionView::Template::Error (stack level too deep):

Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
_trace.erb (1.9ms)
Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
_request_and_response.erb (93.8ms)
Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
template_error.erb within rescues/layout (107.0ms)

Anyone have any ideas on how I can figure out what is causing this
error? I have tried poking around but Im afraid I just can’t seem to
find it.


You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to removed_email_address@domain.invalid.
To unsubscribe from this group, send email to
removed_email_address@domain.invalid.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

I honestly don’t know - I got the same error a few weeks ago when trying
to correct an old Rails site, catching a few undefined objects and
sending the user an appropriate response. I tracked the problem down to
a redirect in a controller where the redirect was sending the
application into a loop - when I removed it and tackled the undefined
object problems in the views (which was much more cumbersome) the stack
overflow error went away!

-----Oprindelig meddelelse-----
Fra: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] P vegne af Colin L.
Sendt: 17. december 2011 10:56
Til: removed_email_address@domain.invalid
Emne: Re: [Rails] Stack Level Too Deep Error (can’t seem to figure it
out)

On 17 December 2011 09:10, Brynjolfur T. removed_email_address@domain.invalid
wrote:

Hi Vell, good to hear you’ve got your site working! The error you are getting is
caused by Rails getting stuck in an endless loop with the resulting stack
overflow. You are probably redirecting from your page to your controller which is
redirecting to the same page which is redirecting to the controller … redirect
apparently doesn’t always do what it says (i.e. redirect the browser), sometimes
it just redirects within the controller (if I remember correctly - I had a similar
problem a few weeks ago).

Would you not expect to see a vaild line number in the error message and
a much longer stack trace in that case?

Colin

I am running into a weird issue where my application is giving me a stack level
too deep error. I can’t seem to find where my code is throwing this error. On the
machine I developed this code on, this error does not show up when I run rails s
but when I move the code to another system to run it this error shows up.

the development log shows:
actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/
To unsubscribe from this group, send email to
removed_email_address@domain.invalid.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to removed_email_address@domain.invalid.
To unsubscribe from this group, send email to
removed_email_address@domain.invalid.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


gplus.to/clanlaw


You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to removed_email_address@domain.invalid.
To unsubscribe from this group, send email to
removed_email_address@domain.invalid.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

On 17 December 2011 09:10, Brynjolfur T. removed_email_address@domain.invalid
wrote:

Hi Vell, good to hear you’ve got your site working! The error you are getting is
caused by Rails getting stuck in an endless loop with the resulting stack
overflow. You are probably redirecting from your page to your controller which is
redirecting to the same page which is redirecting to the controller … redirect
apparently doesn’t always do what it says (i.e. redirect the browser), sometimes
it just redirects within the controller (if I remember correctly - I had a similar
problem a few weeks ago).

Would you not expect to see a vaild line number in the error message
and a much longer stack trace in that case?

Colin

stack level too deep

_request_and_response.erb (93.8ms)
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


You received this message because you are subscribed to the Google G. “Ruby
on Rails: Talk” group.
To post to this group, send email to removed_email_address@domain.invalid.
To unsubscribe from this group, send email to
removed_email_address@domain.invalid.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


gplus.to/clanlaw

I just moved the Gemfile to the vanilla app and ran bundle install.
Fired up the application using rails s and the application came up
fine. I even created a new scaffold to test that I can hit a
controller and that seems to be working fine as well.

So I guess it has to be my code. I guess I will have to keep poking
around to see where I can find it but its like doing it with a
blindfold on.

On 17 December 2011 16:17, Vell removed_email_address@domain.invalid wrote:

I just moved the Gemfile to the vanilla app and ran bundle install.
Fired up the application using rails s and the application came up
fine. I even created a new scaffold to test that I can hit a
controller and that seems to be working fine as well.

So I guess it has to be my code. I guess I will have to keep poking
around to see where I can find it but its like doing it with a
blindfold on.

What happens if you copy the config folder from the failing one onto
the vanilla one I wonder. Start a temporary local git repository for
the vanilla app so you can easily get back to a working one once you
get it to fail.

Colin

lion with rvm (ruby 1.9.2), rails 3.0.10.
Showing /home/rails30/apps/vell/app/views/homes/index.html.erb where
81
Rendered /home/vmcilwain/.rvm/gems/ruby-1.9.2-p290/gems/
I don’t have a specific solution, but you could try using the Gemfile
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


gplus.to/clanlaw

Brynjolfur,

All of my research leads me to believe that the problem is with an
endless loop somewhere. The problem that I have with this scenario is
that I am not getting this problem on my development system. Its only
happing on this ubuntu system that I have just set up.

If I run rails s on my development system my application works
correctly. No errors of any type. But when I move the application to
this ubuntu system, and use rails s I get this error. That in itself
is whats got me scratching my head. Could it be their is a permissions
problem somewhere that is causing this error?

Thats really the problem I am having is that I don’t have a large
stack trace and nothing to point me in the general area of the issue.
As it stands right now, The only re-direct I am doing is in my routes
folder where I am doing the initial root :to => but when I remove
that or even go to any controller method directly, this error shows
up. Again that is what confuses me, Its not one controller method but
ALL controller methods that throws this error.

Colin,

Because I am using the same gems on both systems I would think that it
wouldn’t be a gem problem. I would have thought having the gem file
would make it so that I have exactly the same gems no matter what
system I am on. However, I will move the gem file to the vanilla app
just to see what happens. I would be very curious to see if the
problem shows up there.

On Dec 17, 11:21am, Colin L. removed_email_address@domain.invalid wrote:

What happens if you copy the config folder from the failing one onto
the vanilla one I wonder. Start a temporary local git repository for
the vanilla app so you can easily get back to a working one once you
get it to fail.

Colin

Good idea. I created my git repository and moved my config file over.
I changed the name at the top of the config file so I wouldn’t get an
unknown constant error and commented out the “root :to =>” line since
it didnt exist in the application. Aside from that the application
worked fine with no issues.

On 17 December 2011 16:34, Vell removed_email_address@domain.invalid wrote:

So I guess it has to be my code. I guess I will have to keep poking
Good idea. I created my git repository and moved my config file over.
I changed the name at the top of the config file so I wouldn’t get an
unknown constant error and commented out the “root :to =>” line since
it didnt exist in the application. Aside from that the application
worked fine with no issues.

That surprises me a little. Keep moving other stuff over I suppose,
eventually you will either have it all working or you will find the
problem.

Could it be to do with the path to the app? Unusual characters or
folder name?

Did you re-compile the assets after you moved it
bundle exec rake assets:precompile

Colin

On Dec 17, 11:31am, Colin L. removed_email_address@domain.invalid wrote:

On 17 December 2011 16:17, Vell removed_email_address@domain.invalid wrote:

I just moved the Gemfile to the vanilla app and ran bundle install.
Fired up the application using rails s and the application came up
fine. I even created a new scaffold to test that I can hit a
controller and that seems to be working fine as well.

I presume that you did copy gemfile.lock to the second machine and did
bundle install there.

I didn’t think I needed to copy the gemfile.lock to the mac os x
machine since they are both the same file. As for the vanilla app, I
only copied the gemfile not the gemfile.lock.

On 17 December 2011 16:17, Vell removed_email_address@domain.invalid wrote:

I just moved the Gemfile to the vanilla app and ran bundle install.
Fired up the application using rails s and the application came up
fine. I even created a new scaffold to test that I can hit a
controller and that seems to be working fine as well.

I presume that you did copy gemfile.lock to the second machine and did
bundle install there.

By the way, it makes it easier to follow the thread if you do not top
post. Insert your reply at appropriate points in the previous
message. Thanks.

Colin

On Dec 17, 11:41am, Colin L. removed_email_address@domain.invalid wrote:

around to see where I can find it but its like doing it with a
I changed the name at the top of the config file so I wouldn’t get an
unknown constant error and commented out the “root :to =>” line since
it didnt exist in the application. Aside from that the application
worked fine with no issues.

That surprises me a little. Keep moving other stuff over I suppose,
eventually you will either have it all working or you will find the
problem.

Could it be to do with the path to the app? Unusual characters or folder name?
The path to the app is about a simple as it gets. Even the app name
itself is simple. Just one word with no underscores or special
characters. Aside from the symlink in /var/www that apache2 uses to
get to the app everything else is pretty direct.

Did you re-compile the assets after you moved it
bundle exec rake assets:precompile

I did not re-compile assets, I wasn’t aware that I needed to do such a
thing when moving an app. I am very new to rails 3 and have mostly
done my development in rails 2. I will certainly give that a shot and
see if that is the source of my issue.

On Dec 17, 11:41am, Colin L. removed_email_address@domain.invalid wrote:

around to see where I can find it but its like doing it with a
I changed the name at the top of the config file so I wouldn’t get an
Did you re-compile the assets after you moved it
bundle exec rake assets:precompile

My attempt to run bundle exec rake assets:precompile gave me an error:

rails30@fangorn:~/apps/vell$ bundle exec rake assets:precompile
rake aborted!
Don’t know how to build task ‘assets:precompile’

(See full trace by running task with --trace)

On 17 December 2011 16:50, Vell removed_email_address@domain.invalid wrote:


My attempt to run bundle exec rake assets:precompile gave me an error:

Sorry, I don’t think that was introduced till rails 3.1. So no need to
do that.

Colin

On Dec 17, 11:59am, Colin L. removed_email_address@domain.invalid wrote:

bundle install there.

When I moved the application from one system to the other, I moved the
entire application folder so that copied the gem.lock file as well as
everything else that was on my development system. It was a folder
copy from one system to the other.

Copy gemfile.lock from the working machine and run bundle install again.

I have copied the gemfile.lock to the vanilla app and re ran bundle
install again and the app still works without issue. I am now working
on moving the migration files over then the models and controllers to
see if that breaks.

On 17 December 2011 17:14, Vell removed_email_address@domain.invalid wrote:

When I moved the application from one system to the other, I moved the
entire application folder so that copied the gem.lock file as well as
everything else that was on my development system. It was a folder
copy from one system to the other.

Did you run bundle install after copying it? If not, try that. That
will make sure all the right gems are available.

Colin

On Dec 17, 12:23pm, Colin L. removed_email_address@domain.invalid wrote:

will make sure all the right gems are available.
Yes I did run bundle right after moving the application over. My
steps for the copy were as follows:

zipped the application on my mac
scp’d the zip file to the ubuntu system
unzipped the file in my ~/apps
corrected the permissions (used a vanilla app to see what the
permissions were)
ran bundle
ran rails -s
connected to localhost:3000
app reports stack too deep error

On my mac, just running rails -s on the app and it comes up without
any issue.

On 17 December 2011 18:18, Vell removed_email_address@domain.invalid wrote:

copy from one system to the other.
corrected the permissions (used a vanilla app to see what the
permissions were)
ran bundle

I presume you mean bundle install here.

ran rails -s
connected to localhost:3000
app reports stack too deep error

On my mac, just running rails -s on the app and it comes up without
any issue.

I am out of ideas then I think. Back to replacing the vanilla app a
bit at a time until it fails.
As a side issue it would really have been better to clone the git repo
on the new machine rather than copying the whole lot. I wonder
whether you have something in tmp/cache or somewhere else that is
confusing it on the new system. If you end up copying everything over
to the vanilla app and it then works then it must be something like
that.

Colin

On Sat, 2011-12-17 at 11:02 +0100, Brynjolfur T. wrote:

I honestly don’t know - I got the same error a few weeks ago when trying to
correct an old Rails site, catching a few undefined objects and sending the user
an appropriate response. I tracked the problem down to a redirect in a controller
where the redirect was sending the application into a loop - when I removed it and
tackled the undefined object problems in the views (which was much more
cumbersome) the stack overflow error went away!


I vaguely recollect that I had this same error reported to me when I
used a mismatched rubygems version.

try something like

sudo gem install rubygems -v="1.4.2
sudo gem uninstall rubygems #remove anything higher than 1.4.2
sudo update_rubygems

and see if that helps

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.