Don't know how to build task 'rake tmp:clear' - ruby-on-rails-4

I'm used to enhance rake tasks, but today rake do not want to collaborate...
In particular I want to enhance rake tmp:clear. And as usual I tried this way:
Rake::Task["tmp:clear"].enhance do
puts "enhanced"
end
I always get a Don't know how to build task 'rake tmp:clear' on execution.
I tried to:
Rename my xxx.rake file that contain this piece of code.
Remove everything but this piece of code.
Look into rake tasks/tmp.rake source code to see if tmp:clear had some other weird treatment.
And of course Googled a lot...
I ended up with no solutions/clues.
Thanks for any help.
Flavien
Footnotes:
It works if I change "tmp:clear" for "assets:clobber" for exemple. But still not for "tmp:cache:clear" or other related to tmp.
I use rails 4.2

This is a problem I was facing as well and I was finally able to trace down what was happening. It seems that rails is not including the tmp tasks until after the local rake tasks were loaded. This does not apply to assets:clobber however since those are not declared in the same location as the tmp rake tasks. You can see more information about the declarations. I was able to fix this by adding
require 'rails/tasks'
to the top of my tmp.rake file in tasks, so in your case it would look like
require 'rails/tasks'
Rake::Task["tmp:clear"].enhance do
puts "enhanced"
end
and then everything worked for me as expected.

Related

Python Sub-Process Coverage

Situation:
I'm attempting to get coverage reports for a project that uses both C++ and Python. I'm using LCOV/GCOV for C++, and attempting to use Coverage.py for the python stuff. The only issue is, most of the python code that's being used is simply utility functions being called one function at a time. No initialization, no real life-cycle, or exit. So no real way to use the API to start/stop/save, or use the coverage command line to measure.
With this, I thought the easiest way to accomplish this would be using the sitecustomize.py method like outlined here. I have gotten that to work, and it measures all configured python code as expected. Now I'm looking at how to accomplish this with compiled python code (.pyc).
I can get it to work if I keep source(.py) and (.pyc) in the same directory when running, and then reporting. However, I'm looking for a way to RUN the files and generate the measurement data. Then at a later time point to the actual source files, and run the actual reports. Ideally I wouldn't need the source(.py) files at all, but I haven't found a way to accomplish this.
Objective:
In the end I want to be able to compile the python files(.pyc), install them on the target, and run coverage like stated above. It will generate coverage data files, then pull those files to my host machine which houses the source(.py) .. and do the actual coverage reporting.
Is this possible currently?
[Edit] Thanks to Ned's advice, I looked into the [paths] usage, and it worked exactly how I needed it to.

How to uninstall ArangoDB

I've installed ArangoDB on a CetOS7 system and it appears to have become corrupt after stalling out mid-import. Can't reach the web page and when I boot the server it consumes all of my memory. arangosh isn't functioning correctly either. What's the best way of uninstalling/removing all Arango files so I can run a fresh installation? My first guess is to remove everything that starts with "arango" since this seems to be the naming scheme. Any tips or can anyone verify that every arango file actually begins with "arango"?
Thanks for the help!
Usually yum remove packagename should do the trick for any package. You can try to delete the database directory in /var/lib/arangodb to remove a corrupted database. Please provide the exact version of your ArangoDB installation.

Git tells me my changes haven't been committed, even though they have been?

I was trying to clean up my directory by deleting no longer relevant files. Since then, whenever I try to push, I get the error "Your local changes to the following files would be overwritten by merge: [list of some files I tried deleting]. Please commit or stash them before you can merge" which is odd because all my other file deletions were committed successfully.
EDIT: I renamed my local copy and cloned the repo again, and discovered that the changes I made /were/ going through, but for some reason the web app itself hasn't been reflecting those changes. I tried clearing my browser's cache and viewing the website on other browsers, but those changes just don't appear anywhere except in the files I cloned, which baffles me completely.
Is there any explanation for why the web app is not displaying the most recently updated files?
I still get this error, if it sheds any light:
"Your local changes to the following file would be overwritten by merge:
static/css/newcss.css
Please, commit your changes or stash them before you can merge.
Despite the fact that I have not altered that file in any way since cloning it.
(Also note, I'm using Django for this web app)
EDIT EDIT: So I guess to close this question, the updating of the site was just taking a long time to process (like, two weeks long).
When i use GIT, i usually get this kind of strange errors.
Have you try this: Git telling me to pull, then commit, then pull?
Are you certain you committed your changes? Run this:
git diff
If something comes up, it means there are changes in your working directory that don't match your last commit, e.g., that is the change that needs to be committed.
Try committing the file that changed:
git add myfile.txt
git commit myfile.txt -m "Committing my file"

Apps with label XYZ could not be found

today I ran into an error and have no clue how to fix it.
Error: App with label XYZ could not be found. Are you sure your INSTALLED_APPS setting is correct?
Where XYZ stands for the app-name that I am trying to reset. This error shows up every time I try to reset it (manage.py reset XYZ). Show all the sql code works.
Even manage.py validate shows no error.
I already commented out every single line of code in the models.py that I touched the last three months. (function by function, model by model) And even if there are no models left I get this error.
Here http://code.djangoproject.com/ticket/10706 I found a bugreport about this error. I also applied one the patches to allocate the error, it raises an exception so you have a trace back, but even there is no sign in what of my files the error occurred.
I don't want to paste my code right now, because it is nearly 1000 lines of code in the file I edited the most.
If someone of you had the same error please tell me were I can look for the problem. In that case I can post the important part of the source. Otherwise it would be too much at once.
Thank you for helping!!!
I had a similar problem, but I only had it working after creating an empty models.py file.
I was running Django 1.3
Try to clean up all your build artifacts: build files, temporary files and so on. Also ./manage.py test XYZ will show you stack trace. Later try to run python with -m pdb option and step through the code to see where you fail and why.
You don't specify which server you're using. With Apache you'll almost certainly need a restart for things to take effect. If you're using the development one try restarting that. If this doesn't work you may need to give us some more details.
I'd also check your paths as you may have edited one file but you may be using a different one.
Plus check what's still in your database, as some of your previous versions may be interfering.
Finally as a last resort I'd try a clean install (on another django instance) and see if that goes cleanly, if it does then I'd know that I'd got a conflict, if not then the problem's in the code.

How to do hierarchical build with rake?

I recently started using Rake to build some of my (non-ruby) packages. Rake is nice, but what I found missing is a way to do hierarchical builds (aggregate Rakefiles in subdirectories). Since this is a common feature in most other build tools, I'm wondering if someone more familiar with Rake has a good solution.
I would recommend Buildr for non-Ruby build tasks. It is based on Rake (sits on top of it, allowing you to use all of Rake's features) but fits the semantics of compiled languages better. It also supports hierarchical builds.
I, too, could not figure out a way to do this. I ended up doing:
SUBDIR = "subdir"
task :subtask => SRC_FILES do |t|
chdir(SUBDIR) do
system("rake")
end
end
task :subtaskclean do |t|
chdir(SUBDIR) do
system("rake clean")
end
end
task :subtaskclean do |t|
chdir(SUBDIR) do
system("rake clobber")
end
end
task :default => [:maintask, :subtask]
task :clean => :subtaskclean
task :clobber => :subtaskclobber
Kinda sucks. Actually, really sucks. I scoured the docs and could not find the equivalent of <antcall>
I'm sure that since it's all Ruby and I barely know Ruby there's some super obvious way of requireing it or something.
Buildr uses the notion of scopes, coupled with the name of the projects.
Rake.application.current_scope should be the entry point to discover how to work with them. I hope this helps.
The fix I've used to get around this is:
Dir.chdir(File.dirname(Rake.application.rakefile))
This statement has to be run at every level in the hierarchy except for the root, at the start of every rakefile. A shortened example of how this works in practice:
/rakefile:
task :default do
sh "rake -f component/rakefile"
end
/component/rakefile
Dir.chdir(File.dirname(Rake.application.rakefile))
task :binary => OBJECTS do
sh "gcc #{SOURCES} -Iinclude -o #{TARGET}"
end
As I'm new to rake I'm not convinced it's the cleanest method of solving it, but it was how I eventually got it to work.