Skip to content

undefined method `environment' for nil:NilClass #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jcoyne opened this issue Mar 13, 2014 · 31 comments
Closed

undefined method `environment' for nil:NilClass #191

jcoyne opened this issue Mar 13, 2014 · 31 comments

Comments

@jcoyne
Copy link

jcoyne commented Mar 13, 2014

sstephenson/sprockets#537

The error occurs when sprockets is upgraded from 2.11.0 to 2.11.1 using Rails 4.

@josh says:

This is a sass-rails issue. It monkey patches private Sprockets classes. The fix will need to be made there.

@josh
Copy link
Contributor

josh commented Mar 13, 2014

/cc @rafaelfranca

@josh
Copy link
Contributor

josh commented Mar 13, 2014

This is going to be tricky to get working on sass 3.3. I think sass-rails will have to pin to 3.2 for now and use the old Sprockets::SassImporter tracking technique.

sirwolfgang referenced this issue in sstephenson/sprockets Mar 13, 2014
Make SassImporter safely marshalable
@josh
Copy link
Contributor

josh commented Mar 13, 2014

All of the glob stuff requires a dynamic reference to context which won't be possible if the importer reference needs to be marshable. A pretty annoying requirement by sass core. I'd probably guess they didn't realize this was the case but theres a ton of circular references that looped the importer into whatever instance is actually being cached.

@rafaelfranca
Copy link
Member

Right! I really wish we could remove our SassImporter and use sprocket's one but it will be hard without deprecating the glob importing.

@jcoyne
Copy link
Author

jcoyne commented Mar 13, 2014

Since current version of sass-rails is incompatible with sprockets 2.11.1, wouldn't the expedient fix be to release a patch version locked to sprockets 2.11.0?

@josh
Copy link
Contributor

josh commented Mar 13, 2014

Another approach for supporting globs would be to disable sass caching. That avoids all the marshaling problems. You'll still have sprockets caching to help keep things fast.

@rafaelfranca
Copy link
Member

Yes. I'm doing this right now. But I'm more concerned about the future of this project. I don't want to lock sprockets forever.

@jcoyne
Copy link
Author

jcoyne commented Mar 13, 2014

Excellent. Thanks @rafaelfranca.

@jforberg
Copy link

I get this too, whenever I try to import files. This is on a new project running vanilla everything.

@waterlink
Copy link

Thank you @rafaelfranca
With sprockets locked to <= 2.11.0 it works for me.

geniou added a commit to geniou/berliner-hoefe that referenced this issue Mar 13, 2014
had to fix sprokets for now:
rails/sass-rails#191
@rafaelfranca
Copy link
Member

4.0.2 released

@rafaelfranca
Copy link
Member

I really don't know how this continue this gem if Sprockets::SassImporter is public and I can't use context to make glob work.

We also can't just deprecate it because sprockets alone doesn't work with Rails features.

@josh
Copy link
Contributor

josh commented Mar 14, 2014

SassRails should define its own private SassImporter.

@josh
Copy link
Contributor

josh commented Mar 14, 2014

I'm more stumped to how to make glob importers work in Sass >= 3.3.

@spohlenz
Copy link

@josh What issues are you seeing specific to Sass 3.3? I haven't noticed any difference in behaviour between 3.2 and 3.3.

rafaelfranca added a commit to rails/rails that referenced this issue Mar 14, 2014
rafaelfranca added a commit to rails/rails that referenced this issue Mar 14, 2014
rafaelfranca added a commit to rails/rails that referenced this issue Mar 14, 2014
rafaelfranca added a commit to rails/rails that referenced this issue Mar 14, 2014
rafaelfranca added a commit to rails/rails that referenced this issue Mar 14, 2014
glebm added a commit to twbs/bootstrap-sass that referenced this issue Mar 14, 2014
tvdeyen added a commit to AlchemyCMS/alchemy_cms that referenced this issue Mar 17, 2014
tvdeyen added a commit to AlchemyCMS/alchemy_cms that referenced this issue Mar 17, 2014
amatriain added a commit to amatriain/feedbunch that referenced this issue Mar 17, 2014
Crunch09 added a commit to metaminded/tabulatr2 that referenced this issue Mar 26, 2014
protoswype pushed a commit to protoswype/shiny_ninja that referenced this issue Mar 26, 2014
@gracegimon
Copy link

While locking sprockets is working for Rails version 4.02. for Rails version 4.0.4 it isn't:

rails (= 4.0.4) ruby depends on
  sprockets (2.12.0)

@ivanreese
Copy link

@gracegimon locking sass-rails to 4.0.2 seem to work around this issue temporarily.

gem "sass-rails", "4.0.2"

Or if you prefer,

gem 'sass-rails', '~> 4.0.0', '>= 4.0.2'

@sharp
Copy link

sharp commented Apr 14, 2014

do not work with Rails 4.0.4

Bundler could not find compatible versions for gem "sprockets":
  In Gemfile:
    sass-rails (= 4.0.2) ruby depends on
      sprockets (<= 2.11.0, ~> 2.8) ruby

    rails (= 4.0.4) ruby depends on
      sprockets (2.12.0)

@dogweather
Copy link

Similar problem with Rails 4.1.0.

@robin850
Copy link
Member

@SharpV : You should rm Gemfile.lock and be sure to have sass-rails version 4.0.3. Then you can run bundle install without any problem normally.

@jinhianlee
Copy link

Thanks @robin850. I followed your instructions and bundle install works but I still get the original error _(undefined method environment' for nil:NilClass)_ when pre-compiling the asset pipeline on Heroku. Gem versions: ruby 2.1.1 sass 3.2.19(also tested withsass 3.3) sass-rails 4.0.3 rails 4.1.0` (ref: '968c581ea34b5236af14805e6a77913b1cb36238', branch: '4-1-stable')

Is there a 'known-good' combination of sass & sass-rails that works with Rail 4.1.0?

@dogweather
Copy link

Yep, through a lot of trial and error I found a working combination: https://gist.github.com/dogweather/11150333

That's simply my app's Gemfile and Gemfile.lock. Note that a bundle update still produces the error, but bundle install with these locked-in versions works.

@jinhianlee
Copy link

@dogweather Thanks, will give it a shot!

@MarkMurphy
Copy link

There seems to be a lot going on here can someone summarize the status of this issue, is anyone working it?

@rafaelfranca
Copy link
Member

This specific issue is already fixed. Make sure you use sass-rails 4.0.3.

@dogweather
Copy link

I'm sorry, I don't understand. It seems like, if we're using Rails 4.1, then we need to remember to lock sass-rails to 4.0.3. Otherwise, the dependencies can't be resolved. Is this right?

And so it seems like the issue isn't fixed: Sass-rails depends on an older version of sprockets while Rails depends on a newer version. Is this accurate? Is there a GitHub issue or branch where this is being worked on?

@rafaelfranca
Copy link
Member

No, it is not correct. In fact Rails 4.1.0 generates the Gemfile already using sass-rails 4.0.3. Also rails doesn't define a newer version of sprockets.

One thing that is correct is that we are depending on an older version of sprockets and we need to remove that. But this doesn't mean that sass-rails or rails is broken. It just means you have to be sure you are using the right version.

In the next weeks I hope I can remove this dependency freeze and release sass-rails 4.0.4.

@jkbailey
Copy link

+1 for fixing this

@msokk
Copy link

msokk commented May 16, 2014

+1

@reconstructions
Copy link

Is anyone fixing this?

@rafaelfranca
Copy link
Member

It is already fixed in the latest version

@rails rails locked and limited conversation to collaborators Jun 15, 2014
bishboria added a commit to alphagov/signon that referenced this issue May 14, 2015
A change in sprockets broke sass-rails in 4.0.0. See:

* rails/sass-rails#191
* sstephenson/sprockets#537
bishboria added a commit to alphagov/signon that referenced this issue Jun 1, 2015
A change in sprockets broke sass-rails in 4.0.0. See:

* rails/sass-rails#191
* sstephenson/sprockets#537
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests