Skip to content


Subversion checkout URL

You can clone with
Download ZIP


CanCan current version with Rails 3.1.0.beta1 generates error #372

anjolovic opened this Issue · 13 comments

6 participants



The following error occurs in the Rails 3.1.0.beta1 project as a result of CanCan's Gemfile dependency:

".rvm/gems/ruby-1.9.2-p180@rails3pre/gems/actionpack-3.1.0.beta1/lib/sprockets/railtie.rb:37:in block (2 levels) in <class:Railtie>': undefined methodcontext' for #Sprockets::Environment:0x00000102bd58a0 (NoMethodError)"

I am still not sure why this is the case. I may have to go into the rails code per se.

I've reinstalled the .rvm and all the gems system wide and nothing seemed to have worked getting rid off this particular error.

Note, though, switching to different gemset, i.e. Rails 3.0.7, CanCan works just wonderfully...:)


Thanks, I'll look into getting this fixed. If anyone has ideas please post here.


Ryan: The above error is caused by the sprockets beta 3 and 5 versions and not the CanCan. I think the community ought to make a note of that and if you are able to pass it along, that would be great? Thanks, -Alex


i had the same error. it was a sprocket one. needs to upgrade to beta4 at least(i upgraded to beta5)


Glad to hear someone else has had the same problem. However, sprocket's beta4 and beta5 do not seem to fix the problem. I am going to have to look into this problem again, despite the new beta5 release. Thanks for your note though.


strange. I've added the following to my gemfile:

gem 'rails',     :git => 'git://'  
gem 'sprockets',     :git => 'git://'  

It pulls the lates rails and latest sprockets from github. hope it helps


@gregmolnar, this does fixes the problem, but my sass is wacky. My sass's syntax has nothing to do with the output I am seeing in the browser. Switching to different sprockets version, such as beta1, sprockets seems to generate different output in the browser...


Ryan: I think you may close this issue. It really is unrelated to CanCan. Sorry to bother you in the first place. Thanks.



It seems it's not related to CanCan. I've got the same problem, after a fresh install of the gem Rails 3.1.0.beta1.
I'm using RVM and gemsets, I didn't add any gems to those specified by default in the Gemfile, no code started, I've just try to run a rails server after create my new app (and make a "bundle install" of course).

It doesn't work until I add edge Rails (without adding sprocket)
gem 'rails', :git => 'git://

Didn't tested yet with Sass...


@blakink, sass won't work. Sorry:( I've tried over and over by reinstalling the rails 3.1 beta with no avail of any help. I am still waiting for the resolution. Thanks for the update though.


Solution from
gem 'sprockets', '2.0.0.beta.2'


@andreif, thanks a lot for this update.

@anjolovic anjolovic closed this

I'm still having this exact problem. I can install it on my Mac, but when I try on my Ubuntu server I get the following:

Could not find gem 'sprockets (= 2.0.0.beta.2)' in git:// (at master). Source contains 'sprockets' at: 2.0.0.beta.13


it has nothing to do with cancan. in your gemfile set the sprocket version to 2.0.0.beta.13 than run bundle install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.