HariKrishnan
HariKrishnan

Reputation: 356

Assets gem throws file not found error in assets precompile

I have created an assets gem out of jquery simple faq. https://github.com/MavenHive/jquery_simplefaq

I have added below line to my application.js file.

//= require simplefaq

When I run assets:precompile on my local I get below error.

rake aborted!
couldn't find file 'simplefaq'

To investigate the problem I cloned the gem to my local machine and referred to it using path.

gem 'jquery_simplefaq', :path => '/path/to/jquery_simplefaq'

This works perfectly well. Changing this to use the git url for local gem repository throws the file not found error.

gem 'jquery_simplefaq', :git => 'file:///path/to/jquery_simplefaq'

Using :path works and :git throws error. What am I missing?

Update:

The error message

/home/user/.rvm/rubies/ruby-1.9.3-p194-perf/bin/ruby /home/user/.rvm/gems/ruby-1.9.3-p194-perf@gemset2/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
couldn't find file 'simplefaq'
  (in /home/user/code-repo/proj/webapp/app/assets/javascripts/application.js:27)

You can replicate this error by adding the gem to any rails 3 app.

gem 'jquery_simplefaq', :git => 'git://github.com/MavenHive/jquery_simplefaq'

Add below line to your application.js.

//= require simplefaq

Run assets:precompile

Upvotes: 1

Views: 608

Answers (1)

klaffenboeck
klaffenboeck

Reputation: 6377

So, I forked your repository and got this working. You have a little mixup in your gemspec-file.

Currently, you have this:

# jquery_simplefaq.gemspec
spec.files = `git ls-files`.split($/)
# ...
spec.require_paths = Dir["{lib,vendor}/**/*"] + ["README.md"]

Change it to something like this:

spec.files = Dir["{lib,vendor}/**/*"] + ["README.md"]
# ...
spec.require_paths = ["lib"]

After that, precompiling should work

Upvotes: 2

Related Questions