I'm trying to import and run a rake task, that I put in the Gemfile
I ran the bundle install and it find the installed gem containing my rake task there. But, when I run the bundle exec rake <namespace>:<task>, then then I get this output instead of success:
Don't know how to build task 'forum2discourse:import_punbb'
/usr/local/rvm/gems/ruby-2.0.0-p0-turbo/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-2.0.0-p0-turbo/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
It looks like the task weren't found. How should I instruct the bundle install so it finds the task?
According the rake task import manual (provided by #Daiku). In the Rakefile, you can enumerate all the gems required in you project, and then try import all the rake task exported in those gems, if any, like this:
Gem::Specification.all.each do |spec|
Dir.glob('**/*.rake').each {|file| load file }
end
The try:
$ rake -T
the Gem I was trying to install isn't published yet, so adding
gem 'forum2discourse'
to the Gemfile isn't enough. I wast trying to fix this by checking out the repo, then installing the Gem globally? with sudo bundle install <gem>. The bundle install then stopped complaining about not having the needed gem, but it wouldn't expose the tasks in the gem. However, having the link to the github repo in the gem definition fixes the issue:
gem 'forum2discourse', github: 'initforthe/forum2discourse'
Ruby is magick :-)
Related
I am in process of installing Redmine app via RedmineInstall documentation I try step 5 :
bundle exec rake db:migrate
then error shows :
bundler: command not found: rake
Install missing gem executables with ´bundle install´
I use redmine 3.3.0 64 for windows
I use redmine gemfile and rake was installed (i see Using rake 11.2.2)
I tried reinstall it via bundle install or gem install/uninstall, but did not help (see Successfully installed rake-11.2.2 but rake do not work).
I tried this command from ruby/bin directory or redmine directory not success.
I do not understand, that rake is successfully installed, but when i try use it with bundle it says that command not found.
The problem may be in the directory where the Redmine or rake?
Try rake db:migrate in your redmine directory without bundle exec and see if that resolves your issue.
Bundler usually provides bin stubs for rake and other gem files, so that bundle exec is not necessary or will even fail because it will look in an other gem directory where, in this case, rake might not be installed.
When running rake commands, I get this error:
You have already activated rake 10.0.2, but your Gemfile requires rake 11.1.1.
Prepending `bundle exec` to your command may solve this.
How do I fix this so that I don't have to run bundle exec before every rake command?
I uninstalled rake and reinstalled, but it's still looking for an older version:
C:/Ruby22-x64/bin/rake:22:in `load': cannot load such file -- C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake (LoadError)
from C:/Ruby22-x64/bin/rake:22:in `<main>'
run
$ bundle update rake
that worked for me.
see the documentation.
http://bundler.io/v1.3/man/bundle-update.1.html
Pretty simple:
gem install rake -v 11.1.1
For me it was just that I needed to use sudo bundle exec rake <...>, maybe it can help someone else...
(I was trying to install concerto on a RaspberryPi, FYI)
UPDATE:
gem 'rake','10.0.2' in gemfile
gem uninstall rake
remove gemfile.lock
bundle update rake
Simply remove your gemfile.lock and do bundle install :)
simply write this
gem install rake
Check your Gemfile.lock for rake version, you should find something like
rake (10.0.2)
If you found the above then you have to remove your gemfile.lock then run bundle install again.
And it wouldnt hurt to double check that you are on the right project.
just write a command starting with bundle exec example bundle exec rake db:schema
The problem is your installed rake has a different version to the rake in your Gemfile.lock. Just go in there, Cmd + F to search for 'rake', change the version number to the one that terminal wants.
The problem is the rake version you are using is not same as that in your Gemfile, you must make sure of that there's no difference, you can also take no more bundle exec ... with rubygems-bundler
gem install rubygems-bundler
next run (once)
gem regenerate_binstubs
When trying to rake db:migrate on Heroku. I'm getting the following error.
rake aborted!
uninitialized constant Rake::DSL
From what I've gathered this seems to be a bug with Rake 0.9.2. If I do "gem list" locally only Rake (0.8.7) appears to be installed.
I've tried adding "gem 'rake', '0.8.7'" to my gem file and running bundle install but then I get the following error.
You have requested:
rake = 0.8.7
The bundle currently has rake locked at 0.9.2.
Try running `bundle update rake`
If I do run bundle update rake, it reverts back to 0.9.2, and I'm back where I started.
Am I missing something obvious here?
You should run commands with bundle exec to ensure your getting the proper dependencies. So run:
bundle exec rake db:migrate
For a more detailed post see Yehuda Katz blog post http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
If you still continue to have problems there appears to be several other people with the same issue How to fix the uninitialized constant Rake::DSL problem on Heroku? which they resolved by adding the following to their Rakefile:
require 'rake/dsl_definition'
require 'rake'
I got this error when doing "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'
....
...
....
..
etc...
I fixed it by adding
require 'rake/dsl_definition'
in RakeFile and then typed in
bundle update rake
git add .
git commit -m "Change RakeFile"
git push heroku
heroku rake db:migrate
This one solved my problem. I didn't add gem 'rake', '0.8.7' in my gem file
and my gem list shows rake (0.9.2, 0.8.7).
I have a blog post about this, You have already activated Rake 0.9.2. There are two ways to do this:
Only use the older version of Rake:
Check out your current Rake versions with $ gem list. See which versions of Rake you have and remove them all except for0.8.7. You can remove the gems with gem uninstall rake -v=0.9.1 or whatever version you need to remove.
Or just add a one liner to your Rake file:
Unless you have to use the older version of Rake it is easier to add this linerequire 'rake/dsl_definition' to your Rails's app Rakefile.
require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
I used this to solve this very problem earlier without deleting any gems. This method will force your app to use Rake 0.8.7 which is more stable than 0.9+. You must run bundle update rake command after specifying the version of Rake to use so your gemfile.lock file is in sync with your gem file (if you skip this step Heroku will not let you push your code!)
In your gem file specify the version of Rake to use:
"rake", "0.8.7"
Then do:
bundle update rake
If this still isn't working for you, then do:
sudo gem uninstall rake
As with rich's answer (solving this problem without deleting any gems), but with a correction to your step 1., and a few additional steps:
In the gem file specify:
gem 'rake', '0.8.7'
bundle install (Bundler documentation say to always 'bundle install' after changing your gem file)
git commit -am "Fixed heroku rake problem by specifying rake 0.8.7 in Gemfile"
git push heroku
heroku rake db:migrate
I got the same error without steps 3 and 4.
I have been trying to run rake but it seems that ever since I updated ruby gems rake is failing.
This morning I ran:
gem update --system
And ever since, rake has been failing with the following error:
$ rake db:migrate
rake aborted!
undefined method `specifications' for "/usr/lib/ruby/gems/1.9.1":String
/home/cknadler/projects/ecommerce/Rakefile:7:in `<top (required)>'
(See full trace by running task with --trace)
I have been reading about this problem and it seems that there is a problem with rake 0.9.x that breaks rails but when I check my rake version, I am running 0.8.7:
$ rake --version
rake, version 0.8.7
I have tried uninstalling rake and reinstalling it, using bundler, etc and at this point I am pretty stuck. Thanks in advance.
Edit:
My Rakefile (located in my app root directory)
# 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'
Ecommerce::Application.load_tasks
I would suggest using the bundled binary version of rake to avoid this issue.
bundle exec rake db:migrate
If you installed your bundle using binstubs (bundle install --binstubs) then you can also use the bin version of rake which is equivalent to the bundle exec rake command:
bin/rake db:migrate
P.S: I would also recommend using RVM instead of installing Ruby using sudo for all users. This allows you to keep more modular ruby and gem installation.
You should remove rake 0.9.x (you may have 0.9.2 installed) by doing
gem uninstall rake -v=0.9.2
And then run bundle update
bundle update
Hope that helps.
Install Gem from Github Branch?
I have been following the guide from that thread. When I get to step 4, rake gem , I get an error
rake aborted!
Don't know how to build task 'gem'
Looks like they are using Jeweler which has a rake build task to build the gem.
You can check what rake tasks are available by doing rake -T or rake -vT (more verbose). If I do that in a gem's root directory that uses Jeweler I get:
rake build # Build gem
as an option.
I think you can also skip the manual install step by doing rake install too.
Don't forget to install jeweler:
sudo gem install technicalpickles-jeweler -s http://gems.github.com
Otherwise it won't build.