Assets not found - 404 Error #1810

Closed
mdoza opened this Issue Jun 21, 2011 · 74 comments

Comments

Projects
None yet

mdoza commented Jun 21, 2011

Ruby: 1.9.2-p180
Rails: 3.1.0.rc4

Before writing this up, I searched around the issues to see if it has already been reported, however I didn't find it. The issue is Rails 3.1.0.rc4 appears to be failing to supply assets to the remote web client. I have attempted this on two different development systems both with Ruby 3.0.1.rc4 installed. I created a simple scaffold to interface with the Person model. First visiting the Welcome Aboard page the rails.png logo does not get loaded with the following error:

Started GET "/assets/rails.png" for 70.134.91.77 at 2011-06-16 17:59:33 -0700
Served asset /rails.png - 404 Not Found (0ms)

ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):

Rendered /usr/local/rvm/gems/ruby-1.9.2-p180@railspre/gems/actionpack 3.1.0.rc4/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)

Then when visiting /people a similar error appears failing to load the CSS and Javascript files:

Started GET "/assets/application.js" for 70.134.91.77 at 2011-06-16 17:58:14 -0700
Served asset /application.js - 404 Not Found (0ms)

ActionController::RoutingError (No route matches [GET] "/assets/application.js"):

Rendered /usr/local/rvm/gems/ruby-1.9.2-p180@railspre/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.7ms)

Started GET "/assets/application.css" for 70.134.91.77 at 2011-06-16 17:58:14 -0700
Served asset /application.css - 404 Not Found (0ms)

ActionController::RoutingError (No route matches [GET] "/assets/application.css"):

Rendered /usr/local/rvm/gems/ruby-1.9.2-p180@railspre/gems/actionpack-3.1.0.rc4/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.5ms)

just had the same issue! appears something changed in sprockets, although I haven't looked to see what. I rolled back to Sprockets 2.0.0.beta.10 and everything worked again.

gem 'sprockets', '= 2.0.0.beta.10'

mdoza commented Jun 21, 2011

That makes sense, because it was working earlier. Let me know if you find out what broke, if you have time, i'm just curious.

Member

josh commented Jun 21, 2011

Guessing Rails.application.assets.paths is empty.

Can you try rails/3-1-stable or rails/master.

Contributor

sstephenson commented Jun 21, 2011

Has Rails been updated to use append_path instead of paths <<?

mdoza commented Jun 21, 2011

@josh tried 3-1-stable, works just fine. I guess this issue can be closed :)

FYI I had this same issue with rc3 and downgrading sprockets to beta.10 fixed the issue for me as well.

mdoza closed this Jun 22, 2011

Member

josh commented Jun 22, 2011

I'm going to yank beta.10 and republish it when the next Rails RC is released.

I presented SCSS last night at MontrealOnRails and this error put a damper in the live coding portion of my presentation.

That will teach me to use unstable products for a live demo.

mdoza commented Jun 22, 2011

@garyharan I hope you quickly found the fix to continue your presentation.

@zerobearing2 workaround worked for me as well. thanks. was butting my had against this, as it happened just as I moved to rails 3.1

Contributor

jimmycuadra commented Jul 2, 2011

Still seeing this issue with Rails 3.1.0.rc4 and Sprockets 2.0.0.beta.10.

mdoza reopened this Jul 3, 2011

I cant get it to work at all. Tried Rails 3.1.0.rc4, rc3 as well as a funny mix of Sprockets. Bit stuck at the moment now because I cant really do much work until this is running again.

mdoza commented Jul 5, 2011

@Stefano1990 I hate being stuck like that! However it's working fine with the 3-1-stable branch. You can throw :branch => '3-1-stable' at your rails gem in your Gemfile and bundle update. That should get you going.

Still doesnt work for me. It finds http://localhost:3000/assets/formtastic.css but http://localhost:3000/assets/all.css still gives routing error, aka 404.

Contributor

rhulse commented Jul 5, 2011

I seem to have no problems with a new app, however an existing app upgraded from 3.0 works fine with Rails RC4, but will not serve any image assets on 3-1-stable or Master. All using Sprockets beta 10. The CSS and JS files are fine, and the asset_path helper gives the correct path. The images are all served will the correct headers except post RC4 have 0 length. I suspect an interaction with another Gem, or some config thing but I have not made any progress on finding a solution.

Owner

spastorino commented Jul 7, 2011

This is currently working with 3-1-stable code. In case you have issues using 3-1-stable, add a comment here and I will reopen it.

spastorino closed this Jul 7, 2011

Contributor

rhulse commented Jul 7, 2011

Thanks. Manifest compilation work fine. The image asset thing has its own bug: #1822

@ghost

ghost commented Jul 26, 2011

Updating to 3.1.0.rc5 fixed it for me.

Updating to 3.1.0.rc5 fixed it for me.

+1

mdoza commented Jul 26, 2011

Yup, so far so good with 3.1.0.rc5.

et commented Jul 26, 2011

Same as last 3 people -- rc5 works.

I just updated to rc5 and it's works now

I did not have this issue in rc4, but now when I updated to rc5 I have same error messages as the original poster for the assets


Started GET "/assets/application.js" for 127.0.0.1 at Fri Jul 29 00:34:29 -0700 2011

ActionController::RoutingError (No route matches [GET] "/assets/application.js"):


Rendered /home/michael/.rvm/gems/jruby-1.6.2@railsrc5/gems/actionpack-3.1.0.rc5/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)

Switching back to rc4 and sprockets beta10 fixed the issue.

Owner

spastorino commented Jul 29, 2011

@msolovyov can you share with us an app that shows the issue? so we can reproduce it, thanks

I can't share the whole app but I can share some things:

I'm running jruby 1.6.2, haven't tried using 1.6.3

Is there a specific file or configuration that would help?

Here is my Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.0.rc4'

#deploy packager to create .war files
gem 'warbler'

#rails 3.1 Asset Pipeline
gem 'json'
gem 'sass'
gem 'coffee-script'
gem 'uglifier'
gem 'coffeebeans'



#rails js
gem 'jquery-rails'


gem 'neo4j', :git => 'git://github.com/andreasronge/neo4j.git'

gem "gritter"

#rails authentication gems

gem 'devise-neo4j', :git =>'git://github.com/benjackson/devise-neo4j.git'

gem "oa-oauth", :require => "omniauth/oauth", :git => 'git://github.com/intridea/omniauth.git'
gem 'jruby-openssl'
gem 'multi_xml'


gem 'will_paginate', :git => "git://github.com/akitaonrails/will_paginate.git", :branch => "rails3.1"

gem 'paperclip', :git => "git://github.com/thoughtbot/paperclip.git"
gem 'nokogiri', "1.5.0.beta.4"#:git => 'git://github.com/tenderlove/nokogiri.git'#'nokogiri-1.5.0.beta.4'#, :require => "nokogiri"

gem 'statsample'

group :test, :development do
  gem 'rspec'#, "2.6.0.rc6"
  gem 'rspec-mocks'#, "2.6.0.rc6"

  gem 'rspec-rails', "2.6.1.beta1"


  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
  gem 'guard', "0.5.0" #, "0.4.2.1"#:git => "git://github.com/guard/guard.git"
  gem 'guard-rspec'


  gem 'rb-inotify'
  gem 'libnotify'#, :require => false #if RUBY_PLATFORM =~ /linux/i


  gem 'guard-livereload'
  gem 'guard-bundler'
  gem 'spork', "0.9.0.rc8"

  # Pretty printed test output
  gem 'turn', :require => false



end



group :cucumber do
    gem 'capybara'
    #gem 'database_cleaner'
    gem 'cucumber-rails'
    gem 'cucumber'
    #gem 'spork'
    gem 'launchy'
end






gem 'aws-s3', :require => 'aws/s3'
gem 'mechanize'

gem "mocha", :group => :test


mdoza commented Jul 29, 2011

@msolovyov you are still using rc4 in that application (according to your Gemfile). I bet that's why you are still having the asset problem :)

No I have reverted back to rc4 so I can continue working on it ^.^

Switching that to rc5 and doing bundle update, then running any webserver(webrick/mizuno), I get the asset issue.

Owner

spastorino commented Jul 29, 2011

@msolovyov can you try to provide a minimum app which reproduces the error?. Try reducing the issue in your problem and come with a minimal thing please, otherwise is very hard for us to reproduce the issue

mdoza commented Jul 29, 2011

@msolovyov hehe, I was about to say there was no way you didn't catch rc4 in your Gemfile :) That is annoying that rc5 is having the same problem for you. I'm using Ruby 1.9.2 and rc5 without problems. When I have a chance today I will try rc5 with jRuby and see if I can reproduce your problem.

On Jul 29, 2011, at 5:46, msolovyovreply@reply.github.com wrote:

No I have reverted back to rc4 so I can continue working on it ^.^

Switching that to rc5 and doing bundle update, then running any webserver(webrick/mizuno), I get the asset issue.

Reply to this email directly or view it on GitHub:
#1810 (comment)

Here is a minimum app that reproduces the error: https://github.com/msolovyov/neorc5
You have to use jruby due to some gems using java libs.
Just tried jruby-1.6.3, same issue.

spastorino was assigned Jul 29, 2011

spastorino reopened this Jul 29, 2011

Owner

spastorino commented Jul 29, 2011

@msolovyov are you able to reproduce this issue using MRI also?

I haven't tried as my project relies on neo4j which relies on jruby.

Considering my project works fine using sprockets beta10 on rc4, but once I
switch over to sprockets beta12, it can't find the assets.

So it looks like it's a sprockets beta12 issue and not to do with the other changes in rc5.

On Fri, Jul 29, 2011 at 4:12 PM, spastorino <
reply@reply.github.com>wrote:

@msolovyov are you able to reproduce this issue using MRI also?

Reply to this email directly or view it on GitHub:
#1810 (comment)

I'm using ruby-1.9.2-p290 and was seeing this problem with rc4, upgrading to rc5 didn't help.

snitko commented Aug 1, 2011

I confirm, sprockets beta12 mess up the assets, they are not found. Rolling back to sprockets beta10 and rc4 fixes it for now. ree-1.8.7 here.

mdoza commented Aug 1, 2011

@ultrasaurus, @snitko, I just did a fresh rvm gem set install for rc5 and it is still coming out on top. Wonder what the issue is for you. @snitko are you using Ruby 1.9.2?

snitko commented Aug 1, 2011

No, I'm using ree-1.8.7.

Contributor

farski commented Aug 4, 2011

I'm also seeing this in rc5/beta12 and not in rc4/beta10. Both on 1.9.2p290

Contributor

JDutil commented Aug 5, 2011

When I updated my rc4/beta10 app to rc5/beta12 this also occurred w/ 1.9.2-p290. Appears to be sprockets to me since rc4/beta12 doesnt work either.

Contributor

JDutil commented Aug 5, 2011

Sprockets 2.0.0.beta.13 was released earlier today, and I still receive this error after upgrading.

Contributor

TheEmpty commented Aug 5, 2011

sprockets (2.0.0.beta.13) is working fine for me @JDutil, you did remember to restart your rails server after updating the gem correct?

Contributor

JDutil commented Aug 5, 2011

@TheEmpty Yea I did restart my server a couple times, and when I just checked again it still didn't work. However I just ran rails server and everything works fine. So I think my issue was with the pow web server, and not sprockets. Thanks for making me double check this to try out different web servers.

Owner

spastorino commented Aug 8, 2011

Can someone give a summary of what's the issue here?, if you're still getting one.
It's just JRuby? what about MRI? have you tried Rails 3-1-stable branch and sprockets master ?

mdoza commented Aug 8, 2011

For me the following works:

Ruby 1.9.2
Rails 3.1.rc5

and

Ruby 1.9.2
Rails 3.1-stable

  • matt

On Aug 7, 2011, at 20:41, spastorinoreply@reply.github.com wrote:

Can someone give a summary of what's the issue here?, if you're still getting one.
It's just JRuby? what about MRI? have you tried Rails 3-1-stable branch and sprockets master ?

Reply to this email directly or view it on GitHub:
#1810 (comment)

Owner

guilleiguaran commented Aug 8, 2011

@msolovyov I fixed your (not so) minimal app adding to config/application.rb:

require 'sprockets/railtie'

@ultrasaurus @snitko @farski @JDutil do you have

require 'rails/all'

or

require 'sprockets/railtie'

in your config/application.rb ?

Contributor

JDutil commented Aug 8, 2011

@guilleiguaran I had require 'rails/all in my config/application.rb

My real issue ended up being with the pow web server I believe which has since been resolved 37signals/pow#194

When I use rails rc5 and sprockets beta13 I don't have any issues unless I use the old version of pow.

Owner

spastorino commented Aug 8, 2011

Things are working for me even with JRuby in current 3-1-stable and sprockets master, possibly after I made config.action_dispatch.x_sendfile_header default to nil.
I've made a new app with a post scaffold and added two lines on application.html.erb in order to show the result of asset_path and image_tag.
Take a look at the app https://github.com/spastorino/asset_pipelining_test and test it on heroku http://empty-stream-704.herokuapp.com/posts.

I'm going to close this issue until someone is able to provide a steps which shows new issues :).

spastorino closed this Aug 8, 2011

Owner

guilleiguaran commented Aug 8, 2011

@spastorino agree, I think this issue still happening only to people that are upgrading from rc4 to rc5 and have missing lines in their configuration because there are changes in config files between those versions. I was able to reproduce it myself upgrading an app and it was the problem.

Contributor

farski commented Aug 9, 2011

Yep, requiring sprockets was the issue. Never saw that as a change between 4 and 5; sorry for the trouble.

Contributor

stefanpenner commented Aug 9, 2011

@burke ya it doesn't help either, if other dependencies no longer work on rc5. @josh whats the point of using bundler to control dependencies if you just yank frozen dependencies? If some other gem actually does depend on a later pre release of another gem, should that not be handled by the dependency resolution?

Contributor

burke commented Aug 9, 2011

I deleted my comment because it sounded too angry, but for context on @stefanpenner's, I was basically chastising @josh for pulling versions of gems that people are using. It provides no benefit, and just caused us two hours of work. Not impressed.

No description provided.

I am getting this issue with 3.1.0.rc5 and sprockets beta13. I'm running 1.9.2-p290

My application.rb starts with:

require File.expand_path('../boot', __FILE__)

require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"

Apologies for the double post. I never expected github to allow me to edit a comment to be blank.

Owner

guilleiguaran commented Aug 9, 2011

@tgandrews:

Add this require and try it again:

require 'sprockets/railtie'

@guilleiguaran - thanks that fixed it.

Owner

spastorino commented Aug 9, 2011

@burke are you having issues using Rails 3-1-stable and sprockets master?.
Everybody reported that is working now. Please let us know the issues.

Contributor

burke commented Aug 9, 2011

@spastorino We're not having any problems with 3-1-stable. We were just inconvenienced by sprockets beta10 being yanked, as we had a bunch of apps on an earlier RC of rails that depended on beta10.

We were planning on upgrading them all when 3.1 proper came out, but were instead forced to upgrade them all to rc5 today due to a combination of some idiosyncrasies in our infrastructure and a yanked sprockets gem.

There would absolutely have been workarounds for this; my point is just that gems should not be yanked unless they are actively harmful. It's not helpful in any case, as dependency resolution does the same thing better, and harmful in some.

jfreeze commented Aug 20, 2011

I'm experiencing this problem with rails (3.1.0.rc5) and sprockets (2.0.0.beta.13) for my images.

Started GET "/assets/images/rails.png" for 127.0.0.1 at 2011-08-20 11:12:21 -0500
Served asset /images/rails.png - 404 Not Found (2ms)

I'm using ruby-1.9.2-head.

All other assets load ok, just not the images.

Owner

spastorino commented Aug 20, 2011

@jfreeze can you test it with Rails 3.1.0.rc6? please

Owner

guilleiguaran commented Aug 20, 2011

@jfreeze are you testing in production environment?

jfreeze commented Aug 20, 2011

Ok, I'm not sure I understand the logic here, but images in assets/images have the url

/assets/image-name.png

But, images in public/assets/images can be referenced by

/images/image-name.png

Owner

spastorino commented Aug 24, 2011

@jfreeze did you solve the issue?, I'd like to see an app that try to reproduce it.
Did you test with rc6 and latest sprockets?.
Please, let us know.

jfreeze commented Aug 24, 2011

I have not test with rc6 yet, just rc5 and latest sprockets.
The problems I had were

  1. Cannot not locate images outside the public directory. So I moved all my images to public/images.

And, when moving to heroku, I had the problem

  1. The pathing for images is different than for other assets. I had to use /assets/images/filename
Owner

spastorino commented Aug 24, 2011

@jfreeze test it with rc6 since a lot of this kind of issues were fixed, then let us know. Thanks.

jfreeze commented Aug 25, 2011

This works locally, but not from heroku
<img src="/assets/rails.png"</img>

Heroku has error:

/app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0.rc6/lib/rails/railtie/configuration.rb:78:in method_missing': undefined methodsass' for #Rails::Application::Configuration:0x00000002a8f730 (NoMethodError)

rails (3.1.0.rc6)
sass (3.1.7)
sass-rails (3.1.0.rc.6)
sprockets (2.0.0.beta.14)

BTW, I can't access the image with /assets/images/rails.png.

With the asset pipeline flattening the directories, how are files with same names but in different directories supported?

marcweil commented Oct 1, 2011

I just started having this same problem today with Rails 3.1.1.rc2 and Sprockets 2.0.1. I had been using Rails 3.1.0 stable (well, from the tip of the rails3-1 branch at the beginning of September) and it was working fine until earlier today. Now only some of my assets don't render, and others work fine. A couple PNGs and stylesheets just throw 404s.

The workaround is to run rake assets:precompile, but I'd rather not do that on my dev environment all the time as it takes forever.

Owner

guilleiguaran commented Oct 1, 2011

@marcweil you can confirm if the problem is caused by 3.1.1.rc2 or sprockets 2.0.1? (try using sprockets 2.0.0)

marcweil commented Oct 1, 2011

I downgraded to sprockets 2.0.0 with rails 3.1.1.rc2 and it was still broken, so I tried reverting back to rails 3.1.0 (changeset c33b7c4) and leaving sprockets at 2.0.0 and it remained broken.

marcweil commented Oct 1, 2011

Also, if it helps, this is using ruby 1.9.2-p180.

Owner

spastorino commented Oct 1, 2011

@marcweil if you can share with us a simple app that reproduce the issue, that would be great

Contributor

rhulse commented Oct 1, 2011

@marcweil You say that you are having to precompile in dev mode for things to work. This suggests that the Rails helpers are writing filenames with digests, which is not the default for dev mode. If you have other production values set for dev mode, this might be your problem. Can I suggest that you check that the values in you config files are the same as those outlined in section 9 of the asset pipeline guide, and that try again after deleting tmp/cache/assets.

marcweil commented Oct 2, 2011

@rhulse So it turns out that for some reason the most recent version of compass was causing the problems. Locking it at revision 7147147e2412 seems to have fixed the problem. My config in terms of generating digests is correct according to section 9 of the guide. It had been working fine until I ran the dreaded bundle update and compass got bumped by a point release. Not sure why it caused everything to break, but at least it's working again. Thanks for the help!

Owner

spastorino commented Oct 2, 2011

@chriseppstein told me about some issue in compass, Chris ^^^? :)

Contributor

chriseppstein commented Oct 2, 2011

The most up-to-date compass instructions are here: https://gist.github.com/1184843

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment