Search code examples
rubyrakemixpanel

How to run a rake task depending on environment?


I'm trying to export Mixpanel raw data, as documented here https://mixpanel.com/docs/api-documentation/exporting-raw-data-you-inserted-into-mixpanel

As the Mixpanel team didn't bother to just provide a script doing this, a kind soul made this Rake task https://gist.github.com/wongpeiyi/3217208

I figured out that it needs to go into a file named "Rakefile", and executed with

$ rake mixpanel:pull

However, that gives

rake aborted!
Don't know how to build task 'environment'

Tasks: TOP => mixpanel:pull

How can this task be run?

Thanks!


Solution

  • The rake task was problably written to be included in a rails project. You can just remove the dependency on the :environment task.

    So change the task line to

    task :pull do
    

    that should do the trick. It could be possible that some gems are missing (that is what the :environment task does: it loads the rails environment).