Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to serve javascript from a gem in a production environment. #143

Open
jasonrobertfox opened this issue Nov 20, 2013 · 2 comments
Open

Comments

@jasonrobertfox
Copy link

I thought I'd be clever and include the Zurb Foundation javascript files in my asset pipeline with this:

serve '/foundation', from: Foundation.js_path

And this works well in development, however when I set the environment to production I get this stack trace:

ArgumentError - comparison of NilClass with String failed:
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/buster_helpers.rb:7:in `sort'
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/buster_helpers.rb:7:in `cache_buster_hash'
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/buster_helpers.rb:28:in `add_cache_buster'
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/package.rb:73:in `production_path'
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/package.rb:77:in `to_production_html'
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/helpers.rb:37:in `show_one_asset_pack'
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/helpers.rb:28:in `block in show_asset_pack'
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/helpers.rb:27:in `map'
    /Users/jfox/.rvm/gems/ruby-2.0.0-p247@sinatra-boilerplate/gems/sinatra-assetpack-0.3.1/lib/sinatra/assetpack/helpers.rb:27:in `show_asset_pack'

...

It does not seem to like trying to serve the files from outside the app root. Is there a way to serve files directly from included gems? It seems duplicative to have to copy the zurb javascript while I can just import the scss files.

Thanks!

@arman-h
Copy link

arman-h commented Mar 1, 2014

I'm getting the same error. My app structure is:

/
/config.ru
/app/
/app/app.rb
/app/assets/
/app/assets/css/
/app/assets/css/style.sass
/app/assets/js/
/app/assets/js/app.js

And I'm setting it up like so:

assets do
    js_compression :jsmin
    css_compression :simple
    serve '/js', :from => 'app/assets/js'
    serve '/css', :from => 'app/assets/css'
    js :app, [
        '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js',
        '//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js',
        '/js/app.js',
    ]
    css :style, [
        # Bootstrap
            '//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css',
        # Fonts
            '//fonts.googleapis.com/css?family=Roboto:400,500,700,900,300,100',
            '//fonts.googleapis.com/css?family=Source+Code+Pro:200,300,400,500,600,700,900',
            '//fonts.googleapis.com/css?family=Warnes',
        # Style
            '/css/style.css',
    ]
end

The error is thrown if I run the app in PRODUCTION mode only. It seems to be triggered by /js/app.js and /css/style.css. When I remove those lines from AssetPack configuration, the error dissapears.

@mighe
Copy link

mighe commented Jun 11, 2014

I've just had the same problem: it happens when in the js :app or css :style param array you reference a file that does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants