catapult icon indicating copy to clipboard operation
catapult copied to clipboard

Adding multiple requires causes ArgumentError in sprockets

Open mraaroncruz opened this issue 12 years ago • 11 comments

I'm getting this
1.9.3-p194/lib/ruby/gems/1.9.1/gems/sprockets-2.4.5/lib/sprockets/directive_processor.rb:206 :in process_require_directive: wrong number of arguments (7 for 1) (ArgumentError)
when my app.js looks like this

//= require './vendor/underscore-min'
//= require './vendor/backbone-min'
//= require './backbone/app'

This is what is being sent to that process_require_directive method in sprockets

["vendor/underscore-min", "//=", "require", "vendor/backbone-min", "//=", "require", "backbone/app"]

Thanks!!!!!!!!

mraaroncruz avatar Jul 12 '12 17:07 mraaroncruz

sorry I'm not using Spine

mraaroncruz avatar Jul 12 '12 17:07 mraaroncruz

There seems to be an issue (here) with the generated files. Coffeescript was also taking a crap in my lap.
After deleting -> retouching the files, everything works as expected. ^M? Weird stuff.
I will leave this to y'all to close.

mraaroncruz avatar Jul 12 '12 18:07 mraaroncruz

This just bit me again. Super strange. Works with require_tree . but when I add any other require directives it won't compile. Deleting the file and touching a new one fixes it...

mraaroncruz avatar Aug 10 '12 10:08 mraaroncruz

This seems to be more related to sprockets rather than catapult, and you could get more help over there. Anyway, if you can provide a sample app I might take a look on it later.

lucasmazza avatar Aug 10 '12 13:08 lucasmazza

Here's a sample repo https://github.com/pferdefleisch/broken-catapult in https://github.com/pferdefleisch/broken-catapult/tree/broken it won't watch or build for me

Write asset: ./public/assets/app.js
/Users/aaron/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sprockets-2.4.5/lib/sprockets/directive_processor.rb:258:in `process_require_directory_directive': wrong number of arguments (4 for 1) (ArgumentError)
  (in /Users/aaron/tmp/sample/assets/stylesheets/app.css:1)

in https://github.com/pferdefleisch/broken-catapult/tree/new_file I have yanked the text from the app.css file, deleted it, created a new buffer, pasted and written the buffer, all in vim, and catapult builds. Thanks

mraaroncruz avatar Aug 10 '12 16:08 mraaroncruz

Your app.css at the broken branch is using CR line terminators and it breaks when sprockets process it, while the new_file is using LF.

You could convert it to LF (recommended) or open an issue at the sprockets repo to fix it somehow.

lucasmazza avatar Aug 10 '12 17:08 lucasmazza

AFAIK this is the only project that I use that generates files with CR terminators. So I am more apt to believe that it is a bug in catapult and not in Sprockets. What could be causing this? Maybe we can fix it. Is there a reason this project prefers CR?

mraaroncruz avatar Aug 10 '12 21:08 mraaroncruz

Created an issue on Thor https://github.com/wycats/thor/issues/245 I want to get to the bottom of this :)

mraaroncruz avatar Aug 10 '12 21:08 mraaroncruz

Thanks! Let's see what come out of it.

lucasmazza avatar Aug 11 '12 00:08 lucasmazza

Hi, I had the same problem today.

Sprockets deliberately relies on LFs (String#lines() uses $/ and it defaults to "\n").

I'm not sure if Sprockets should fix it by handling all line endings (they accept the default $/ which is flexible), neither I investigated if thor generates files with this problem, but I'm sure Catapult could generate valid files since this is a very annoying bug with a simple fix (I had no clue why that was happening and spent some time hunting this while reading Sprockets source code).

13k avatar Oct 21 '12 06:10 13k

So late, but if anyone has a similar problem, mine was a malformed syntax:

//= require foo_//= require bar

Hope help someone.

wbotelhos avatar Jun 19 '15 14:06 wbotelhos