CodeSleeve / asset-pipeline

This Laravel 4 package provides a very simple and easy to use asset pipeline. It was heavily inspired by the Rails asset pipeline. We make use of the wonderful Assetic package to help with pre-compliation!
http://www.codesleeve.com
MIT License
491 stars 53 forks source link

404 when including jQuery #169

Open mcmillion opened 10 years ago

mcmillion commented 10 years ago

I'm getting a 404 whenever jQuery is imported. jQuery is still successfully loaded, but the log gets polluted with a stack trace on each page load.

[2014-05-07 17:39:24] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in [root]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:871
Stack trace:
#0 [root]/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(208): Illuminate\Foundation\Application->abort(404)
#1 [root]/vendor/codesleeve/asset-pipeline/src/controllers/AssetPipelineController.php(32): Illuminate\Support\Facades\Facade::__callStatic('abort', Array)
#2 [root]/vendor/codesleeve/asset-pipeline/src/controllers/AssetPipelineController.php(32): Illuminate\Support\Facades\App::abort(404)
#3 [internal function]: Codesleeve\AssetPipeline\AssetPipelineController->file('jquery-1.10.2.m...')
#4 [root]/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array)
#5 [root]/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('file', Array)
#6 [root]/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(Codesleeve\AssetPipeline\AssetPipelineController), Object(Illuminate\Routing\Route), 'file')
#7 [root]/vendor/laravel/framework/src/Illuminate/Routing/Router.php(934): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), '\\Codesleeve\\Ass...', 'file')
#8 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}('jquery-1.10.2.m...')
#9 [root]/vendor/laravel/framework/src/Illuminate/Routing/Route.php(105): call_user_func_array(Object(Closure), Array)
#10 [root]/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1000): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#11 [root]/vendor/laravel/framework/src/Illuminate/Routing/Router.php(968): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#12 [root]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(738): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#13 [root]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(708): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#14 [root]/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php(38): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#15 [root]/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Http\FrameGuard->handle(Object(Illuminate\Http\Request), 1, true)
#16 [root]/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#17 [root]/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#18 [root]/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#19 [root]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(606): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#20 [root]/public/index.php(49): Illuminate\Foundation\Application->run()
#21 [root]/server.php(19): require_once('/Users/Matthew/...')
#22 {main} [] []

Any ideas? jQuery resides in provider/assets/javascripts/jquery.min.js

evantishuk commented 10 years ago

What does your app's manifest look like?

mcmillion commented 10 years ago
//= require jquery
//= require_tree .
kdocki commented 10 years ago

The file being loaded (in the error above) is not in your manifest file so it is probably being loaded somewhere else.

If I had to guess I'd say you have a script tag in your layouts or views that point to /assets/jquery-1.10.2.min.js

mcmillion commented 10 years ago

Nope. No references to the file anywhere else, and if I take //= require jquery out of the manifest, it stops appearing altogether.

The file that's being picked up is the file at provider/assets/javascripts/jquery.min.js (which is version 1.10.2), as I just added a comment to the file and it appeared in the output js file.

Additionally, if I rename the jquery.min.js to jquery-1.10.2.min.js, I get a 500. Changing the manifest's require to //= require jquery.min or //= require jquery.min.js displays the same behavior above.

evantishuk commented 10 years ago

Well, isn't this the jquery that comes bundled into the package itself?

RE: https://github.com/CodeSleeve/asset-pipeline/blob/master/README.md#introduction-to-directives

It seems like a genuine bug if it's throwing a routing error. I guess it doesn't like where the file is located or maybe permissions?

@tabennett the immediate workaround is to remove the //= require jquery and replace with your own jquery files. Personally, I usually rely on a CDN for jQuery (http://jquery.com/download/#jquery-39-s-cdn-provided-by-maxcdn or http://cdnjs.com/libraries/jquery/) and just put it right into my layout file(s). Or you could checkout a copy of jQuery to /app/assets/javascripts/vendor/jquery do something like //= require_tree vendor in your manifest.

@kdocki What's the deal with the built-in jquery anyway?

mcmillion commented 10 years ago

@evantishuk That's what I've done for the time being.

Granted I don't know the internals, but it seems like it's checking multiple places or multiple filenames, as it does actually find jQuery, but it errors out on the filename it can't find.

Braunson commented 9 years ago

Have the same issue, since //require= jquery.min includes the jquery.min.js in provider/assets/javascripts I just created the jquery-1.10.2.min.map in that folder and left it empty, error solved for now.