Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "bundle exec rake" and "bundle exec rackup" and where does the flow of execution start for rackup?

Tags:

ruby

bundler

I understand that "bundle exec" is directing the bundler to execute something in the context of the given directory and gemfile.

But what is the difference between bundle exec rake and bundle exec rackup?

Also, in the case of bundle exec rackup what is the start of flow of execution?

like image 371
Mugen Avatar asked Oct 22 '25 00:10

Mugen


1 Answers

They are different tools.

  • rake runs task scripts defined using a special DSL.
  • rackup is a part of rack which is a minimal webserver interface.

rackup is a useful tool for running Rack applications, which uses the Rack::Builder DSL to configure middleware and build up applications easily. rackup automatically figures out the environment it is run in, and runs your application as FastCGI, CGI, or WEBrick—all from the same configuration.

To run a Rack application you can pass a path to it as a parameter: bundle exec rackup yourapp.ru Or create config.ru file with your application initialization and just run bundle exec rackup.

Here is the minimal Rack application:

run ->(env) { [200, {'Content-Type' => 'text/html'}, ['Hi Mugen']] }

UPD

As @tadman mentioned in a comment below bundle exec just loads what's in the Gemfile and prepared the environment. Also, dependent on your setup you can run rake and rackup without the bundle exec command.

like image 177
Yakov Avatar answered Oct 23 '25 19:10

Yakov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!