Code Monkey home page Code Monkey logo

Comments (23)

jankeesvw avatar jankeesvw commented on August 10, 2024 4

I'm running still running into this problem, I upgraded Rails to 4.2.6 which depends on sprockets (>= 3.0.0). Is there a way to hotfix this so I can deploy my security updates?

from requirejs-rails.

carsomyr avatar carsomyr commented on August 10, 2024 1

Thanks all for the reports. I'm looking to have a fix out in the upcoming week.

from requirejs-rails.

IceDragon200 avatar IceDragon200 commented on August 10, 2024

@samstarling I had a similar issue some time back, try downgrading your version of sprocket-rails to 2.x, that fixed it for me

from requirejs-rails.

samstarling avatar samstarling commented on August 10, 2024

@IceDragon200 You're right - downgrading sprockets-rails to 2.3.3 fixed this.

from requirejs-rails.

AntiFish03 avatar AntiFish03 commented on August 10, 2024

This seems to be the issue. rails/sprockets-rails#237

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

I have the same issue... Hope this can get fixed!

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

When I try to downgrade sprockets-rails to 2.3.3 I run into these kinds of errors:

Bundler could not find compatible versions for gem "tilt":
  In snapshot (Gemfile.lock):
    tilt (= 2.0.1)

  In Gemfile:
    haml was resolved to 4.0.7, which depends on
      tilt

    sass-rails (~> 5.0) was resolved to 5.0.4, which depends on
      tilt (< 3, >= 1.1)

    delayed_job_web was resolved to 1.2.10, which depends on
      sinatra (>= 1.4.4) was resolved to 1.4.6, which depends on
        tilt (< 3, >= 1.3)

    sprockets (= 2.3.3) was resolved to 2.3.3, which depends on
      tilt (!= 1.3.0, ~> 1.1)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

I tried downgrading a lot of gems, but bundler can't seem to solve the dependency issues. @carsomyr are you working on a fix? I would love to help!

from requirejs-rails.

carsomyr avatar carsomyr commented on August 10, 2024

All, I've been very busy lately delivering a major feature. I'll try to look into this on Saturday.

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

No problem @carsomyr, if you need a hand let me know. For now I removed this Gem and switched to using plain require-js, so the urgency is gone for me.

from requirejs-rails.

matfiz avatar matfiz commented on August 10, 2024

You can replace Raiils.application.assets with Rails.application.assets_manifest.files.values.map{|v| v['logical_path']} (ref. https://github.com/rails/sprockets-rails/blob/6f5a37cfc7e5e71e2a7e1d1c002448dc374f1324/lib/sprockets/railtie.rb#L142-L148)

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

@matfiz thanks for the comment. But what do you mean? Where should I replace this?

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

I got this result for the manifest files:

>>  Rails.application.assets_manifest.files
=> {}

from requirejs-rails.

matfiz avatar matfiz commented on August 10, 2024

@jankeesvw have you checked in production env?

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

@matfiz no only in development mode, how do you overwrite this? Add something to an initializer?

from requirejs-rails.

matfiz avatar matfiz commented on August 10, 2024

The assets_manifest reads the Sprockets manifest file from compiled assets - these are available only in production. AFAIK you can emulate it in development by setting config.assets.compile = false in development.rb.

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

Thanks for the quick response @matfiz, can you give me an concrete example of how we can fix this error?

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

Hi @matfiz, would be great if you have some more information on your proposed solution! Thanks!

from requirejs-rails.

ijdickinson avatar ijdickinson commented on August 10, 2024

I've just run into this issue as well. Is there any update on suggested resolutions?

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

Is there someone with a solution / work around?

from requirejs-rails.

ijdickinson avatar ijdickinson commented on August 10, 2024

@jankeesvw I switched my app to using modulejs instead of requirejs, following this pattern:

https://reinteractive.net/posts/172-a-better-way-to-modularise-your-js-in-rails

It has been working well for me, and fits more comfortably into the asset pipeline.

from requirejs-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024

@ijdickinson that looks good! Did it require a lot of rewriting?

I would rather not rewrite the app, there is quite some JavaScript in my application.

from requirejs-rails.

ijdickinson avatar ijdickinson commented on August 10, 2024

@jankeesvw No, it was very straightforward. The signature for the modulejs require function is almost the same as the requirejs require, and then you need to rely on the asset pipeline to load the JavaScript manifest in the usual way - modulejs doesn't do any file management like requirejs does. Modulejs isn't nearly as capable as requirejs, so if you're relying on aliasing and those kinds of advanced features it won't help you.

We probably shouldn't continue this discussion in this issue thread - it's going a bit off-topic. Please feel free to pm me if you want more details!

from requirejs-rails.

thegillis avatar thegillis commented on August 10, 2024

For me this appeared to be a problem with a sprockets upgrade. We needed to upgrade to sprockets 3 and there were multiple errors related to asset precompile.

The cause of the actual error is essentially that it's trying to access:

Rails.application.assets.paths.dup

Unfortunately in sprockets along the way this no longer works. Instead of accessing application.assets.path, the valid location now appears to be application.config.assets.

Although this was able to get us further, there are many more sprockets problems. I'll see if I can clean things up a bit and test my changes against sprockets 2, but my company is now using:

https://github.com/MediaFactual/requirejs-rails/tree/rails5-1-0-0

or with bundler:

gem 'requirejs-rails', :git => 'https://github.com/MediaFactual/requirejs-rails.git', :branch => 'rails5-1-0-0'

If these changes appear to be stable on our systems, I'll submit a pull request.

from requirejs-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.