undefined method `environment' for nil:NilClass when importing Bootstrap
I ran in to this problem as well and it looks like an issue related to the latest version of sprockets and you can fix it as suggested by changing the Gemfile.lock, but if someone or something does a bundle update it's going to get broken again and I know some places don't like to check in Gemfile.lock until there's a push to stage.
If you use sass-rails better than 4.0.0 it will resolve the problem...
gem 'sass-rails', '~> 4.0.0'
The problem is solved and it will limit sprockets to 2.11. From the generated Gemfile.lock...
sass-rails (4.0.2)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0.0)
I ran into this exact problem today and managed to solve it.
Funny thing is that yesterday everything was fine (of which I have proof because I pushed a working version to Heroku before going to bed last night), but today things broke after I did bundle update
. So I went through the terminal output of that and noticed that the sprockets gem updated to 2.12.0. I then went back and realized that it was 2.11.0 yesterday. Hmm...
On a hunch, I edited my gemfile and added this line:
gem 'sprockets', '2.11.0'
Basically, to force bundler to install that specific version. I then did another bundle update
and voila! Things started working again.