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

load Rakefile before executing -p, -e, and -E code #363

Open
avdi opened this issue Sep 29, 2020 · 0 comments
Open

load Rakefile before executing -p, -e, and -E code #363

avdi opened this issue Sep 29, 2020 · 0 comments

Comments

@avdi
Copy link

avdi commented Sep 29, 2020

Let's say we have this sad little Rakefile:

FOO=23*42

And we want to find out the value of FOO. We look at the --help output, and -p sounds promising:

$ rake --help
    ...
    -p, --execute-print CODE         Execute some Ruby code, print the result, then exit.
    ...

But when we try it...

$ rake -p 'FOO'
rake aborted!
NameError: uninitialized constant Rake::Application::FOO

(See full trace by running task with --trace)

...this is confusing! Especially for a Rake novice.

We can get the result we intended:

$ rake -p 'load_rakefile; FOO'
966

But this requires substantial inner knowledge of Rake.

Suggested behavior:

$ rake -p 'FOO'
966

Thoughts, anyone? Is there a reason I'm missing that -e, -E, and -p don't load the rakefile by default?

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

1 participant