When I push my ruby on rails app to heroku all the images don't load.
I have attempted to precompile all assets but I get this error:
jack:my_first_ruby_app Jack$ bundle exec rake assets:precompile
rake aborted!
/Users/Jack/Sites/my_first_ruby_app/Rakefile:1: unknown regexp option - b
/Users/Jack/Sites/my_first_ruby_app/Rakefile:1: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/rake_module.rb:25:in `load'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/application.rb:589:in `raw_load_rakefile'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/application.rb:89:in `block in load_rakefile'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/application.rb:88:in `load_rakefile'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/application.rb:72:in `block in run'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195#global/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'
/Users/Jack/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `<main>'
Contents of Rakefile:
/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
MyFirstRubyApp::Application.load_tasks
Version of Ruby 2.0.0p195
Please Edit your Rakefile
and commented the line 1
like this
#!/usr/bin/env rake
Related
estimatemyproject.com is running on ruby on rails for more than 2 years without any problems.
But just today it stopped loading assets .
I searched online and tried
rake assets:precompile --trace RAILS_ENV=production
but it fails:
root#emp:/home/emp/current# rake assets:precompile --trace RAILS_ENV=production
rake aborted!
/home/emp/emp/releases/20160127092918/config/application.rb:7: syntax error, unexpected ':', expecting ')'
Bundler.require(*Rails.groups(assets: %w(development test)))
^
/home/emp/emp/releases/20160127092918/config/application.rb:7: syntax error, unexpected ')', expecting kEND
Bundler.require(*Rails.groups(assets: %w(development test)))
^
/home/emp/emp/releases/20160127092918/config/application.rb:60: syntax error, unexpected $end, expecting kEND
/home/emp/emp/releases/20160127092918/Rakefile:5:in `require'
/home/emp/emp/releases/20160127092918/Rakefile:5
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:25:in `load'
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:25:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:501:in `raw_load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:82:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:81:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:65:in `run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:63:in `run'
/usr/bin/rake:27
Help me to debug this please!
Need the assets to reload or refresh the cache somehow.
Thanks!
I tried using the change diego suggested :
It gives me a different error now.
rake aborted!
no such file to load -- rubygems
/home/emp/emp/releases/20160127092918/config/boot.rb:1:in `require'
/home/emp/emp/releases/20160127092918/config/boot.rb:1
/home/emp/emp/releases/20160127092918/config/application.rb:1:in `require'
/home/emp/emp/releases/20160127092918/config/application.rb:1
/home/emp/emp/releases/20160127092918/Rakefile:5:in `require'
/home/emp/emp/releases/20160127092918/Rakefile:5
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:25:in `load'
/usr/lib/ruby/vendor_ruby/rake/rake_module.rb:25:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:501:in `raw_load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:82:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:81:in `load_rakefile'
/usr/lib/ruby/vendor_ruby/rake/application.rb:65:in `run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:63:in `run'
/usr/bin/rake:27
You have a syntax error in config/application.rb line 7.
Seems like you're using an old version of Ruby that does not support the colon hash syntax. Change this:
Bundler.require(*Rails.groups(assets: %w(development test)))
to:
Bundler.require(*Rails.groups(:assets => %w(development test)))
Fix that and redeploy your app and rerun the rake command.
I am in the process of developing a Rails Engine (currently using Rails 4.1.6). I get this error when I try to run any Rake tasks:
$ bundle exec rake app:db:migrate --trace
** Invoke load_app (first_time)
** Execute load_app
rake aborted!
NameError: uninitialized constant Thor::Base
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/ui/shell.rb:12:in `initialize'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/gem_helper.rb:26:in `new'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/gem_helper.rb:26:in `initialize'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/gem_helper.rb:13:in `new'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/bundler-1.7.3/lib/bundler/gem_helper.rb:13:in `install_tasks'
/Users/andrew/example_rails_engine/Rakefile:10:in `<top (required)>'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_module.rb:28:in `load'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:687:in `raw_load_rakefile'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:93:in `load_rakefile'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:77:in `block in run'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/andrew/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/andrew/.rbenv/versions/2.1.3/bin/rake:23:in `load'
/Users/andrew/.rbenv/versions/2.1.3/bin/rake:23:in `<main>'
My Rakefile is as follows:
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
This error doesn't make sense to me. I'm guessing Thor is a dependency of Rails Rake tasks. Where is this error coming from and how do I fix it?
adding
require 'thor'
to your RakeFile before
Bundler::GemHelper.install_tasks
fixed the issue for me
This seems to be an issue with either:
Bundler: https://github.com/bundler/bundler/issues/3205
or guard-rspec: https://github.com/guard/guard-rspec/issues/258
Guard lists Thor as a dependency, while Bundler vendors its own version of Thor, causing some sort of conflict.
I was able to temprorarily fix the problem by changing the order in which the code is loaded:
Move this line: Bundler::GemHelper.install_tasks above these lines:
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Following this tutorial, I applied the steps for deploying to Heroku under 2.3.5 Deploying the demo app.
When I run the command: > heroku rake db:migrate, I get the following:
$ heroku rake db:migrate
(in /app)
rake aborted!
uninitialized constant Rake::DSL
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2482:in `const_missing'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:8:in `<class:Ta
skLib>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:6:in `<module:R
ake>'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/tasklib.rb:3:in `<top (req
uired)>'
/app/.bundle/gems/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/task.rb:37:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/rdoc-3.8/lib/rdoc/task.rb:37:in `<top (require
d)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.r
ake:2:in `require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks/documentation.r
ake:2:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `load'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:15:in `block
in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/tasks.rb:6:in `<top (
required)>'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in
`require'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:215:in
`initialize_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:139:in
`load_tasks'
/app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:in
`method_missing'
/app/Rakefile:7:in `<top (required)>'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run'
/usr/ruby1.9.2/bin/rake:31:in `<main>'
Why is that? And, how can I solve this issue?
Thanks.
I have a blog post about it here:
http://codeglot.com/posts/13-you_have_already_activated_rake_0_9_2
You have two options. Keep the latest gem and do this:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
Or you need to specify the older version of rake:
gem list
Then see which version of rake you have.
gem uninstall rake -v=0.9.1
Then in your bundler specify the older version:
gem 'rake', '0.8.7'
This link may help: fix unitialized constant rake heroku
Form that post:
Put this in your Rakefile above require 'rake':
require 'rake/dsl_definition'
I have upgraded rails 2.3.11 to rails 3.0.8 using rails_upgrade plugin. Now I am getting this error and I do not understand why. Any help you can provide is appreciated!
rake aborted!
no such file to load -- tasks/rails
/home/mpn/mpn_admin/branches/to_rails3/Rakefile:13:in `require'
/home/mpn/mpn_admin/branches/to_rails3/Rakefile:13:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake:19:in `<main>'
Check your RakeFile to make sure it doesn't have the old Rails 2 artifacts left in it. The error is getting thrown in the RakeFile so that's probably the cause and the upgrade plugin would not have caught that.
Here is what a sample Rails 3 RakeFile looks like:
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
MyAppNameGoesHere::Application.load_tasks
When running rake db:create or rake db:migrate locally my app successfully builds the tables as expected. When running on heroku however (eg. heroku rake db:migrate --trace --app ) it is giving me the following error all of a sudden:
C:\>heroku rake db:migrate --trace --app foo rake aborted!
undefined method `task' for #<Foo::Application:0x7f8e77aa1420>
/app/.bundle/gems/ruby/1.8/gems/railties-3.0.4/lib/rails/application.rb:214:in `initialize_tasks'
/app/.bundle/gems/ruby/1.8/gems/railties-3.0.4/lib/rails/application.rb:139:in `load_tasks'
/app/.bundle/gems/ruby/1.8/gems/railties-3.0.4/lib/rails/application.rb:77:in `send'
/app/.bundle/gems/ruby/1.8/gems/railties-3.0.4/lib/rails/application.rb:77:in `method_missing'
/app/Rakefile:7
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:78:in `load_rakefile'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:61:in `run'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'
/app/.bundle/gems/ruby/1.8/gems/rake-0.9.0/bin/rake:31
/usr/ruby1.8.7/bin/rake:19:in `load'
/usr/ruby1.8.7/bin/rake:19
Looking at the Rakefile this is all that's present:
require File.expand_path('../config/application', __FILE__)
require 'rake'
Foo::Application.load_tasks
The load_tasks line is line 7. I'm really not sure what changed but something sure has. Has anyone had experience with this error?
See that
There's an issue with Rake 0.9.0. Use 0.8.7 in your Gemfile for now.