cron and bundle exec problem - ruby-on-rails-3

I've upgraded to rails 3.0.9 which has introduced the rake issues. I've gotten it all resolved except for a problem with a cron job.
This used to work:
#!/bin/sh
source /usr/local/rvm/scripts/rvm
cd /home/p1r65759/apps/abbc/
/usr/local/bin/rake refresh_events RAILS_ENV=production
But now I get this error:
You have already activated rake 0.8.7, but your Gemfile requires rake 0.9.2. Consider using bundle exec.
/home/p1r65759/apps/abbc/Rakefile:4:in `'
(See full trace by running task with --trace)
How do I modify my script to use bundle exec so it will use the proper version of rake and run successfully?
Thanks.

If you are using bundler for your application then you don't need to use "/usr/local/bin/rake" as a path for rake.
you can just use bundle exec rake
so your new script will be
#!/bin/sh
source /usr/local/rvm/scripts/rvm
cd /home/p1r65759/apps/abbc/
bundle exec rake refresh_events RAILS_ENV=production
bundle exec will work because you are already in your project directory.
And don't forgot to include rake in your Gemfile.

instead of
/usr/local/bin/rake refresh_events RAILS_ENV=production
you should use
bundle exec rake refresh_events RAILS_ENV=production
or better yet install your bundle with --binstubs:
bundle install --binstubs --without development test
then you will have bin/rake:
./bin/rake refresh_events RAILS_ENV=production

Related

Resque - rake aborts

Iam new to ruby on rails, currently iam trying to make my task to run at background using resque gem
I had installed redis and resque gem successfully, Now i want to run my rake file which is placed at .../lib/tasks/resque.rake
content in resque.rake
require 'resque/tasks'
task "resque:setup" => :environment
I had started my redis server, Opened a new terminal and moved to my app path now i executed the rake command which is
rake resque:work QUEUE='*'
Now i got an error as
rake aborted!
Don't know how to build task 'resque:work'
.../.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in eval'
.../.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in'
Please help me to fix the bug
Try the following to start the rake task,
QUEUE=* VVERBOSE=1 rake environment resque:work
From here,
http://bradhe.wordpress.com/2011/05/09/notes-on-working-with-resque-in-rails-3and-ruby-1-8/

Getting message about missing multi_json-1.3.6 when Capistrano tries to run assets:precompile

I'm using Capistrano with Rails 3.2.1. When I do cap deploy, I get this error:
Could not find multi_json-1.3.6 in any of the sources
Here's some of the relevant output leading up to this error:
* executing `deploy:assets:precompile'
* executing "cd /home/jason/dittypad-cap/releases/20120728190221 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["sniphq.com"]
[sniphq.com] executing command
** [out :: sniphq.com] Could not find multi_json-1.3.6 in any of the sources
I do have this gem, though:
$ bundle list | grep multi_json
* multi_json (1.3.6)
I was curious to see what would happen if I ran assets:precompile directly in production. The first time I tried it, it worked. But now when I try it I get this:
$ bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile
/home/jason/.rvm/gems/ruby-1.9.2-p290/gems/bundler-1.0.22/lib/bundler/rubygems_integration.rb:143:in `block in replace_gem': rake is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /home/jason/dittypad-cap/shared/bundle/ruby/1.9.1/bin/rake:18:in `<main>'
Why is it complaining about multi_json being missing even though I have it?
I got past this by updating my bundler version to 1.0.18.
I got the answer here: Capistrano deploy/assets on Rails 3.1 fails

spree install errors

i am following the guide at http://guides.spreecommerce.com/getting_started.html
all's ok until i run
bundle exec rake spree_sample:load
rake says
Don't know how to build task 'spree_sample:load'
if i decide to skip that and do
rake db:bootstrap
it says
Table 'myproject_development.countries' doesn't exist
if alternatively i run
rake db:migrate
rake db:seed
rake spree_sample:load
it also says
Don't know how to build task 'spree_sample:load'
if i still continue that and run
rake db:admin:create
i get another error:
no such file to load -- /home/pavel/cetsy/db/sample/users.rb
bundler information:
...
Using rails (3.0.9)
...
Using spree_core (0.60.1)
Using spree_auth (0.60.1)
Using spree_api (0.60.1)
Using spree_dash (0.60.1)
Using spree_promo (0.60.1)
Using spree_sample (0.60.1)
Using spree (0.60.1)
Simon was right, upgrading rails and spree to 3.1.1/0.70 partially solved the issue
now, running
bundle exec rake spree_sample:load
still produces
Don't know how to build task 'spree_sample:load'
but skipping this step lets me finish installing spree without other problems

rake db:seed issue

I'm seeing a weird issue here when I run rake db:seed or rake db:migrate:
user#ubuntu:~/Desktop/staging/config$ bundle show activeresource
/usr/lib/ruby/gems/1.8/gems/activeresource-3.0.3
user#ubuntu:~/Desktop/staging/config$ rake db:seed
(in /home/rohan/Desktop/staging)
Could not find activesupport-3.0.3 in any of the sources
Try running `bundle install`.
user#ubuntu:~/Desktop/staging/config$ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
I don't know what to do. Any help would be appreciated. For the record, I am using RVM.
Run bundle install. This will fix the problem.
you need to require rails in gemfile then run bundle install.
gem "rails", 'version'
now run bundle install
On the assumption that you tried running bundle install like it asked, you probably just need to use:
$ bundle exec rake db:seed
to run rake in the context of the bundle.

Rails 3.1 engine rake task doesnt work

I created a new engine with Rails 3.1.rc1
➜ (ruby-1.9.2-p180#rails3-pre) rails git:(master) be bin/rails plugin new ../first_engine --mountable
rails g scaffold project title:string
Scaffold is generated and now when I run
bundle exec rake db:migrate
I get the following error:
rake aborted!
Don't know how to build task 'app:db:migrate'
Tasks: TOP => db:migrate
Before rc1, it was working. But what happened now? I couldn't figure it out!
Here is the gist with all the steps and backtraces https://gist.github.com/990641
Can anyone put me the right direction?
In you Gemfile or RVM Global Gemset file. Change rake to include the version. e.g.
gem 'rake', '0.8.7'
Just using rake will not work until Rails comes out with a fix. Let us know how you get on. All the best.