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

rake assets:precompile not resolving #72

Merged
merged 4 commits into from
Apr 26, 2014
Merged

rake assets:precompile not resolving #72

merged 4 commits into from
Apr 26, 2014

Conversation

SergeyKishenin
Copy link
Collaborator

Maybe I'm doing this wrong? Starting with no dependencies and running rake assets:precompile I get an error for a missing dependency. Looking at the trace, it doesn't seem like bower:install is ever called.

** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/nic/.rvm/rubies/ruby-2.0.0-p353/bin/ruby /Users/nic/.rvm/gems/ruby-2.0.0-p353@zeumo/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
...
# config/initializers/bower_rails.rb
BowerRails.configure do |bower_rails|
  bower_rails.resolve_before_precompile = true
end

What am I missing?

@SergeyKishenin
Copy link
Collaborator

What does the error message say?

@nicinabox
Copy link
Author

"couldn't find file ...", where file is a dependency that would be in bower_components. rake bower:install has not been run at this stage.

rake assets:precompile
/Users/nic/.rvm/rubies/ruby-2.0.0-p353/bin/ruby /Users/nic/.rvm/gems/ruby-2.0.0-p353@zeumo/bin/r
ake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
couldn't find file 'Chart.js/Chart'

@SergeyKishenin
Copy link
Collaborator

Could you, please, try issue-72 branch: gem 'bower-rails, github: '42dev/bower-rails', branch: 'issue-72'

@nicinabox
Copy link
Author

Same error as above.

@SergeyKishenin
Copy link
Collaborator

Could you test this branch again?

@nicinabox
Copy link
Author

Hmm, no change.

@SergeyKishenin
Copy link
Collaborator

I've tried and had success. Have you updated gem?

@nicinabox
Copy link
Author

Yeah, updated from issue-72 branch. I reviewed the code, and it looked appropriate. Still not seeing any difference though.

$ bundle list | grep bower-rails
  * bower-rails (0.7.1 f72fe0d)
rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/nic/.rvm/rubies/ruby-2.0.0-p353/bin/ruby /Users/nic/.rvm/gems/ruby-2.0.0-p353@zeumo/bin/rake assets:precompile:all
 RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
couldn't find file 'Chart.js/Chart'
  (in /Users/nic/work/zeumo/app/assets/javascripts/admin.js.erb)

Using Ruby 2.0.0 and Rails 3.2.17.

@nicinabox
Copy link
Author

@SergeyKishenin Any ideas? Seems like it should Just Work.

@SergeyKishenin
Copy link
Collaborator

That's very strange as I have it working with Rails 4.0.4 and Ruby 2.1.1.

Anyway I have to do a fix to make rake bower:install and others to run before not after rake assets:precompile task.

@SergeyKishenin
Copy link
Collaborator

I've added before hook to perform bower tasks before precompilation and now have to following trace:

$ rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
** Invoke bower:install (first_time)
** Execute bower:install
bower.js files generated
/usr/bin/bower install 
bower moment#*                  cached git://github.com/moment/moment.git#2.6.0
bower moment#*                validate 2.6.0 against git://github.com/moment/moment.git#*
bower moment#*                 install moment#2.6.0

moment#2.6.0 bower_components/moment
** Invoke bower:resolve (first_time)
** Execute bower:resolve
** Invoke assets:precompile (first_time)
** Invoke assets:environment 
** Execute assets:precompile
I, [2014-04-22T16:23:59.500561 #5699]  INFO -- : Writing /home/sergey/src/xxxxxxx/public/assets/application-afa23a41925dba57b4166b41335d4d49.js
I, [2014-04-22T16:23:59.565702 #5699]  INFO -- : Writing /home/sergey/src/xxxxxxx/public/assets/application-a029bd03bea21da7d02c0e9d272edc3a.css

@nicinabox
Copy link
Author

Confirmed working with Rails 4.0.1 with bower-rails#f0cf21f. Hmm... so Rails 3.2 not so much.

@nicinabox
Copy link
Author

Looks like asset_sync had a similar issue: AssetSync/asset_sync#41

@nicinabox
Copy link
Author

Following what asset_sync did, I added this file:

# lib/tasks/bower_rails.rake
Rake::Task['assets:precompile'].enhance ['bower:install', 'bower:resolve']

And it works. Check out this commit for reference.

@SergeyKishenin
Copy link
Collaborator

Well, does this invoke bower-rails' tasks before precompilation? With Rails 4.0.4 it did after, actually.

@nicinabox
Copy link
Author

Seems to.

** Invoke assets:precompile (first_time)
** Invoke bower:install (first_time)
** Execute bower:install
bower.js files generated
/Users/nic/.nvm/v0.10.22/bin/bower install
** Invoke bower:resolve (first_time)
** Execute bower:resolve
** Execute assets:precompile
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/nic/.rvm/rubies/ruby-2.0.0-p353/bin/ruby /Users/nic/.rvm/gems/ruby-2.0.0-p353@zeumo/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary

@SergeyKishenin
Copy link
Collaborator

I've just found that with Rails 3.2.x BowerRails.tasks are empty as the rake assets:precompile is performed before the app initialization.

@nicinabox
Copy link
Author

I also found that a little bit ago!

@SergeyKishenin
Copy link
Collaborator

Well, as a workaround I placed bower-rails' initializer code to application.rb and it seems to work. But I find this not the best solution. Any ideas?

UPD: or require initializer in application.rb like require "#{Rails.root}/config/initializers/bower_rails.rb"

SergeyKishenin added a commit that referenced this pull request Apr 26, 2014
`rake assets:precompile` not resolving
@SergeyKishenin SergeyKishenin merged commit e055eef into master Apr 26, 2014
@SergeyKishenin SergeyKishenin deleted the issue-72 branch April 26, 2014 12:43
@mogox mogox mentioned this pull request May 9, 2014
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

Successfully merging this pull request may close these issues.

2 participants