0

I've been stuck on this error for weeks.

When I trying to include bootstrap gems in my application.css file, it MIGHT give the error of "Stack level too deep"

From what I googled pointed out the root issue of this was because of double defined method "image_url" both in sprockets and bootstrap-sass.

Here's my error log:

ActionView::Template::Error (stack level too deep
  (in /Users/jason/.rvm/gems/ruby-2.0.0-p247@drwho/bundler/gems/bootstrap-rails-7ae5424fa38b/app/assets/stylesheets/twitter/bootstrap.scss)):
  sprockets (2.2.2) lib/sprockets/context.rb:196

Now, I have updated bootstrap-sass to the latest version and the error gone for a while... Next time I do "bundle install", the error poped up again. I also tried the different bootstrap gem: "anjlab-bootstrap" the results are the same.

The strangest thing is:

I was trying to reproduce this error by creating a new empty rails app and use the same Gemfile, as a matter of fact, I copied almost every files to the new projects includes "app", "config", "lib", "public", "Gemfile" and "Gemfile.lock"

And no error in the new project. I happily push the new project to Github. Next day, when I on my office computer, I git clone the new project, do the bundle install. And guess what.... the same error poped up AGAIN.

Here my repo(the new and should be working) for the reference

git@github.com:jasonlu/drwho.git

I'm thinking the problem might be on my rvm. I have also tried to reinstall entire rvm and got no luck.

Could anyone help?

madth3
  • 7,275
  • 12
  • 50
  • 74
Jason Lu
  • 31
  • 3

1 Answers1

1

Well, here is a crazy idea. Probably, you have non-deterministic load order of files in your project. Here is an example:

# file2.rb
def f; puts "In #{__FILE__}"; end

# file1.rb
def f; puts "In #{__FILE__}"; end

# test.rb
Dir.glob('file*.rb').each { |x| require x }
f

Possible output:

machine1> ruby test.rb
In file1.rb

# copy *.rb to a different machine
machine2> ruby test.rb
In file2.rb

See also this (not directly related) answer: Does Dir.glob guarantee the order?

Community
  • 1
  • 1
DNNX
  • 6,215
  • 2
  • 27
  • 33