Skip to content

Loading…

Sprockets::FileOutsidePaths #214

Closed
elfassy opened this Issue · 18 comments

9 participants

@elfassy

keep getting this error even after removing the gem

 Sprockets::FileOutsidePaths
  ...activeadmin-0.3.0/app/assets/javascripts/active_admin/vendor.js isn't in paths

activeadmin/activeadmin#564 (comment)

@jackkinsella

+1. Breaks new Rails 3.1 apps since Jquery won't get loaded.

@jackkinsella

Correct by adding this to your Gemfile:

gem "sprockets", "2.0"

@aroop

You are seeing this error because of this commit fa0ca6d
This happens when sprockets is not able to find the file in Rails.application.config.assets.paths

@josh

Sorry, but the asset needs to be in assets.paths. This was always the case. It was just silently breaking before.

@josh josh closed this
@trevorturk

I'm running into this problem, too. In my case, at least, I can reproduce it by (a) requesting /assets/application.js in my Rails app, (b) changing my app to use a new rbenv-gemset, (c) running bundle install etc, and (c) requesting the asset again.

I think the root problem is that you can have stale assets cached.

In my case, Sprockets is using:

#<ActiveSupport::Cache::FileStore:0x007fad490f3c20 @options={}, @cache_path="/Users/trevor/code/app/tmp/cache/assets/">

I've been toying around with workarounds like:

def expire_index!
  # Clear digest to be recomputed
  @digest = nil
  @assets = {}
  @cache.clear if @cache.respond_to?(:clear)
end

...but this results in the cache being cleared unnecessarily. You could clear the file cache manually if need be, I suppose. Maybe it's worth doing after a "touch tmp/restart.txt" or whatever.

I wonder if a solution would be to retry one time after FileOutsidePaths is raised, clearing the cache before trying again.

@trevorturk

Hey @josh -- sorry I didn't see your comment before posting mine. From what I can tell, this looks like a real issue. I think the cached assets can be stale. I'm not 100% sure I'm right, or if this is something Sprockets should care about. Let me know if my earlier comment helps explains things at all.

@josh

@trevorturk can you dump out Rails.application.assets.paths. I just looked at this jquery rails gem and it doesn't seem to be setting up any paths. No idea how this could possible work as it is. If somehow sprockets is getting an absolute reference to the asset without being scoped by some root that could cause the issue if the gem path changed after bundling.

@trevorturk
"/Users/trevor/Code/my_app/app/assets/images" 
"/Users/trevor/Code/my_app/app/assets/javascripts" 
"/Users/trevor/Code/my_app/app/assets/stylesheets" 
"/Users/trevor/Code/my_app/lib/assets/javascripts" 
"/Users/trevor/Code/my_app/lib/assets/stylesheets" 
"/Users/trevor/Code/my_app/vendor/assets/javascripts" 
"/Users/trevor/Code/my_app/vendor/assets/stylesheets" 
"/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/test123/bundler/gems/signal_id-4dc61ebcb30d/app/assets/images"
"/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/test123/bundler/gems/signal_id-4dc61ebcb30d/app/assets/javascripts"
"/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/test123/bundler/gems/signal_id-4dc61ebcb30d/app/assets/stylesheets"
"/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/test123/bundler/gems/file_icons-77bf38de3a00/lib/assets/images"
"/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/test123/bundler/gems/file_icons-77bf38de3a00/lib/assets/javascripts"
"/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/test123/bundler/gems/stacker-0201a5768a8f/lib/assets/javascripts"
"/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/test123/gems/jquery-rails-1.0.14/vendor/assets/javascripts"
@josh

Also a full backtrace would be nice.

@trevorturk

This is from my debugging as I was trying to figure out where things were being called:

AssetAttributes#logical_path

raise pathname.inspect

/Users/trevor/.rbenv/versions/1.9.3-preview1/lib/ruby/gems/1.9.1/gems/jquery-rails-1.0.14/vendor/assets/javascripts/jquery.js

raise Rails.application.config.assets.paths.inspect

/Users/trevor/Code/my_app/app/assets/images 
/Users/trevor/Code/my_app/app/assets/javascripts 
/Users/trevor/Code/my_app/app/assets/stylesheets 
/Users/trevor/Code/my_app/lib/assets/javascripts 
/Users/trevor/Code/my_app/lib/assets/stylesheets 
/Users/trevor/Code/my_app/vendor/assets/javascripts 
/Users/trevor/Code/my_app/vendor/assets/stylesheets 
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/bundler/gems/signal_id-4dc61ebcb30d/app/assets/images
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/bundler/gems/signal_id-4dc61ebcb30d/app/assets/javascripts
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/bundler/gems/signal_id-4dc61ebcb30d/app/assets/stylesheets
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/bundler/gems/file_icons-77bf38de3a00/lib/assets/images
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/bundler/gems/file_icons-77bf38de3a00/lib/assets/javascripts
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/bundler/gems/stacker-0201a5768a8f/lib/assets/javascripts
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/jquery-rails-1.0.14/vendor/assets/javascripts\"

raise caller.inspect

/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/base.rb:99:in `find_asset'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/environment.rb:72:in `find_asset'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/base.rb:110:in `[]'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/bundled_asset.rb:30:in `block in init_with'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/bundled_asset.rb:28:in `map'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/bundled_asset.rb:28:in `init_with'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/asset.rb:9:in `from_hash'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/caching.rb:13:in `asset_from_hash'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/caching.rb:42:in `cache_asset'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/environment.rb:82:in `build_asset'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/trail.rb:102:in `find_asset_in_path'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/base.rb:101:in `find_asset'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/environment.rb:72:in `find_asset'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/sprockets-2.0.1/lib/sprockets/server.rb:42:in `call'
/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/my_app/gems/rack-mount-0.8.3/lib/rack/mount/prefix.rb:26:in `call'

raise cache.inspect

RuntimeError: #<ActiveSupport::Cache::FileStore:0x007fad490f3c20 @options={}, @cache_path="/Users/trevor/Code/app/tmp/cache/assets/">

If you have specific things you wanna see, let me know.

@josh

"/Users/trevor/.rbenv/versions/1.9.3-preview1/gemsets/test123/gems/jquery-rails-1.0.14/vendor/assets/javascripts"

vs

"/Users/trevor/.rbenv/versions/1.9.3-preview1/lib/ruby/gems/1.9.1/gems/jquery-rails-1.0.14/vendor/assets/javascripts/jquery.js"

is strange

@trevorturk

@josh fixed this in 99fa4f1 :clap:

@francesc

Had the same problem, 2.0.2 fixed it. Thanks!

@gberenfield

I'm still seeing this in 2.0.2 but wonder if it's just my misunderstanding of sprockets in rails (3.1.1.rc2).

In my apps, I've setup dynamic javascript views as follows: For example, for a customer index view, I'll render app/views/customers/index.html.erb which contains a content_for(:head) call to include app/views/customers/headers.js.erb.

The headers.js.erb has a bunch of javascript that varies based on server-side calls (rails) and then renders the resulting js.

This all works fine with sprockets 2.0.0, where the headers.js.erb file is not parsed by sprockets (correct behavior for me).

In 2.0.2, I'm getting 'Sprockets::FileOutsidePaths in Customers#index' with this same setup. Sprockets is trying to parse the js file instead of the rails routing (I do have a Customer#header method and route defined).

So.. not sure if it's sprockets or my borked app design in light of the asset pipeline.

@firedev

I have the same issue with Rails 4 and Sprockets 2.11, but only when deploying using capistrano which drives me crazy:

    I, [2014-04-14T06:26:33.754964 #2686]  INFO -- : Writing /home/rails/apps/milk/releases/20140414062553/public/assets/application-057c26190914caece53b8898c1c24b06.js
DEBUG [11f3b433]    rake aborted!
DEBUG [11f3b433]    Sprockets::FileOutsidePaths: /home/rails/apps/milk/releases/20140414062553/vendor/bundle/ruby/2.1.0/gems/actionpack-4.1.0/lib/action_dispatch/journey/visualizer/fsm.css isn't in paths: /home/rails/apps/milk/releases/20140414062553/app/assets/images, /home/rails/apps/milk/releases/20140414062553/app/assets/javascripts, /home/rails/apps/milk/releases/20140414062553/app/assets/stylesheets, /home/rails/apps/milk/releases/20140414062553/vendor/assets/javascripts, /home/rails/apps/milk/releases/20140414062553/vendor/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/ckeditor_rails-4.3.4/lib/assets/javascripts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/ckeditor_rails-4.3.4/vendor/assets/images, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/ckeditor_rails-4.3.4/vendor/assets/javascripts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/ckeditor_rails-4.3.4/vendor/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/remotipart-1.2.1/vendor/assets/javascripts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/twitter-bootstrap-rails-2.2.8/app/assets/fonts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/twitter-bootstrap-rails-2.2.8/app/assets/images, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/twitter-bootstrap-rails-2.2.8/app/assets/javascripts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/twitter-bootstrap-rails-2.2.8/app/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/twitter-bootstrap-rails-2.2.8/vendor/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/font-awesome-rails-4.0.3.1/app/assets/fonts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/font-awesome-rails-4.0.3.1/app/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/neat-1.5.1/app/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/bourbon-3.1.8/app/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/mousetrap-rails-1.4.6/app/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/mousetrap-rails-1.4.6/vendor/assets/javascripts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/turbolinks-2.2.2/lib/assets/javascripts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/jquery-ui-rails-4.2.0/app/assets/images, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/jquery-ui-rails-4.2.0/app/assets/javascripts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/jquery-ui-rails-4.2.0/app/assets/stylesheets, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/jquery-rails-3.1.0/vendor/assets/javascripts, /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/coffee-rails-4.0.1/lib/assets/javascripts
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/asset_attributes.rb:53:in `logical_path'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:268:in `find_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:105:in `each'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:16:in `initialize'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `new'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `block in build_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:395:in `circular_call_protection'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:373:in `build_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/bundled_asset.rb:16:in `initialize'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `new'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `build_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:211:in `block in find_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:257:in `benchmark'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:210:in `find_asset'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:119:in `block in compile'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `each'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `compile'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:60:in `block (3 levels) in define'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/rake/sprocketstask.rb:146:in `with_logger'
DEBUG [11f3b433]    /home/rails/apps/milk/shared/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:59:in `block (2 levels) in define'
DEBUG [11f3b433]    Tasks: TOP => assets:precompile
DEBUG [11f3b433]    (See full trace by running task with --trace)
@waseem

I have the same issue with sprockets 2.11.0 and rails 4.2.4. @firedev Did you find any solution to this problem?

@firedev

Sorry I think it resolved by itself after numerous updates.

@waseem

@firedev Sure thank you.

If anyone bumps into this again, I was using Heroku to deploy my application. And to bypass this error, I compiled the assets locally and then pushed it to heroku and it worked.

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.