Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskManager#synthesize_file_task results in surprising command line behavior #234

Open
rickhull opened this issue Nov 5, 2017 · 3 comments

Comments

@rickhull
Copy link
Contributor

rickhull commented Nov 5, 2017

I have a Rakefile with the report task defined. There are no FileTasks in my Rakefile. I also have a reports dir at my project toplevel.

If I run rake report then my task is executed as expected. If I run rake reportx then I get the expected error about "don't know how to build task". If I run rake reports then I get a NOOP. No errors.

I don't understand why, for any existing file or dir passed to rake as a target, rake will create a NOOP FileTask. What is gained from having tons of (potential) NOOP tasks that correspond to every single file and dir (and possible path to such) on the filesystem?

In my rake reports case, I would much prefer an error. So the downside is that the user doesn't get an error for erroneous tasks that were never defined. What is the upside of TaskManager#synthesize_file_task ?

I believe its invocation here is causing the problem (lacking an error) for my rake reports case.

@rickhull rickhull changed the title TaskManager#synthesize_file_task has surprising behavior TaskManager#synthesize_file_task results in surprising command line behavior Nov 5, 2017
@rickhull
Copy link
Contributor Author

rickhull commented Nov 6, 2017

This appears to be a (more informative) dupe of #127 If one issue must prevail, I suggest this one :)

@mill1000
Copy link

mill1000 commented Jun 6, 2022

Recently encountered this issue as well due to some unexpected pattern matching from the shell. I have a release task defined and a releases directory. When executing the release task with an argument like rake release[test] Rake runs the NOP releases task because the shell pattern matched the directory and replaced release[test] with releases. Very annoying and very confusing, but not really Rake's fault.

I don't understand why, for any existing file or dir passed to rake as a target, rake will create a NOOP FileTask. What is gained from having tons of (potential) NOOP tasks that correspond to every single file and dir (and possible path to such) on the filesystem?

My naive understanding of this behavior is that it appears to be a side effect of how Rake handles dependencies. If a task or rule depends on a file, Rake will automatically create a NOP task for it if the file exists. The task can then be added to part of the dependency chain.

@jasonkarns
Copy link
Contributor

This is entirely consistent with rake's ancestry being a ruby version of make. The original purpose of make (and thus rake) is to make files. What we call tasks are an extension of the underlying recipes for making files (typically by compiling from source files).

Just like make, if a file exists, then its task is considered satisfied (modulo, the file's mtime). Thus the noop task is necessary to allow any tasks or dependencies to depend on files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants