How to run rake tasks from console? - console

I want to invoke my rake task from console. Is it doable? if yes, how to do so?
I tried this on console:
require 'rake'
Rake::Task['my_task'].invoke
but it give me this error:
RuntimeError: Don't know how to build task
it's like the rake cannot found the task.
any help would be appreciated.
Thank you
Edit: I am using rails 2.3.5

Running your Rake tasks requires two steps:
Loading Rake
Loading your Rake tasks
You are missing the second step.
Normally this is done in the Rakefile, but you have to do it manually here:
require 'rake'
Rails.application.load_tasks # <-- MISSING LINE
Rake::Task['my_task'].invoke

The easiest way to do it is to run %x[command] from the irb. I'm not sure if what you want to achieve though.
%x[rake db:migrate]
EDIT: I highly recommend to use .invoke as Daniel says in the accepted answer.

The easy way is:
Rails.application.load_tasks
Rake::Task['my_task'].invoke

I am using rails 5.x.x, and was in the need the do the same form rails console.
I have create rake task here-
app/lib/task_to_execute.rake
Here is the command worked for me-
Load Rails.application.load_tasks
Rake::Task['task_to_execute:task_name'].invoke
Worked for me!

Just a note that if you are in the rails console via rails c you can just call/run the rake task method by irb(main):001:0> TaskClassName.new.my_task

Related

Create a New Plone addon mrbob error

I want to start developing of my first test addon. I have a problem on the basis of mr.bob. Any described ways have leaded to one result. my documentation
log image
Check
mrbob --help
do the same answer.
After I came to the conclusion the problem is in pre-installed Python2.7 with no worked mr.bobe and bobtemplates. I do not know how to make a working set.
Looking at your traceback I guess mr.bob is not fully supporting Windows.
The readline module on Windows is not available. There's some alternatives like pyreadline.
Seems it's a know issue: see https://github.com/domenkozar/mr.bob/issues/49
Don't know about mr.bob, but you could alternatively try adi.devgen (disclaimer: one of my add-ons). Install it with pip:
pip install adi.devgen
And then do:
devgen addOn yournamespace.youraddonname

Display Symfony command output in Capistrano V3 script

I use Capistrano to deploy SF projects.
So, to call a SF command, I use :
invoke 'symfony:console', :'assets:install'
Let's say I want to display command output, how can I do ? I tried with "capture" but didn't manage to make it work.
Many thanks for answers,
Nicolas
Did you install capistrano/symfony gem ?
Then call a SF command like this:
symfony_console('assetic:dump')
And set capistrano with debug log level and pretty format:
set :format, :pretty
set :log_level, :debug
At least it works for me.

adobe brackets-shell : cef extract failed

I followed all the step is mention in given below url to build my project( I am using win7 OS).
https://github.com/adobe/brackets-shell/wiki/Building-brackets-shell.
actullly i want to create brackets installer (installed wix 3.7).
but i am getting cef-extract failed error.
even though i also used grunt cef-extract --force.
after that its throunging new error.
create -project failed after that i am not able to process further.
can some one help me.
thanks in advanced.
Regards
ashish .
If you include the exact console output you're seeing, it would be much easier to help you. But based on snags other people have encountered recently, you can try these things:
Make sure your PATH includes Python 2.7 (otherwise "create-project" will fail).
Delete all these folders to be sure you're starting from a clean slate: deps, Debug, include, libcef_dll, Release, Resources.
Just run the high-level tasks grunt setup and grunt build, following the Building brackets-shell instructions. (There's a known bug where grunt cef-extract fails when run standalone).

Java - ant cannot find rt.jar

I'm compiling DrJava by following these instructions.
But when I run ant jar, I get the error:
/Users/arthur/dj/drjava/build.xml:1270: Can't find rt.jar in the Java 7 home: ${env.JAVA7_HOME}
I know that rt.jar is in /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/jre/lib.
How do I fix it?
This answer is same as what others have provided - just a little more detailed. So what you simply need is type this on your shell:
export JAVA7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/jre/lib
Now you have mentioned I know that rt.jar is in /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/jre/lib.
Usually you would not have Contents/Home inside JDK. A standard Java installation should have jdk1.7.0_07.jdk/jre/lib. Check if you have provided the correct path above and rt.jar is indeed in there.
You should make sure you point ant to a JDK rather than to a JRE.
SET PATH TO JDK..This will solve the issue.
I ran into this same problem. Pulak was close, but not quite right: you don't need the jre/lib part at the end. The command that ultimately did the trick for me was:
export JAVA7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/

How to run PHPUnit Test from another directory

I have a very straightforward PHPUnit test in c:\kim\test\HelloTest.php on a Windows PC. I can execute it from within the c:\kim\test directory with the command:
phpunit HelloTest
The problem is that I can't execute it from any other directory.
As far as I know I should be able to execute this from the c:\kim directory with:
phpunit test
Also, I would have thought the following syntax would work too:
phpunit c:\kim\test
But I don't get any response from the command. Simply a blank line and then I am returned to the cursor.
I am trying to get unit tests working properly with Netbeans and I think I need to solve this problem first. Perhaps it has something to do with paths? Any ideas?
I spent quite a while trying to sort this out, per the comments above. Also tried reinstalling PHPUnit. In the end I ran up a new server, installed XAMPP, and all works fine.
If any help.
I am using makegood extension for eclipse which handle phpunit test execution with one click.
Maybe you can find similar extension for Netbeans or switch to eclipse

Resources