Is it possible to run bundle install from a ruby system call?
I'm trying to install gems and run tests for a project under another path...
For example the command is:
"cd /some/other/project && bundle install && gem list && rspec spec"
Ideally I want to just run the tests via a rake file in one project whilst making sure the relevant gems for that project are install.
The cd seems to be working correctly, if I run:
"cd /some/other/project && pwd"
It does give the correct path. But if I do bundle install && gem environment, it seems to install the gems for the current folder and doesn't use the Gemfile from the other project, and subsequently the rspec spec doesn't work.
To summarize, what's the best way to run 'rspec spec' for example, for another project within a rakefile also ensuring the relevant gems are available?
The bundle exec command ensures that executable programs installed by Gems don't interfere with your app's requirements. For instance, if your app needs a specific version of rake but the default version of rake differs, bundle exec ensures that you can still run the specific rake version compatible with your app.
bundle exec is a Bundler command to execute a script in the context of the current bundle (the one from your directory's Gemfile). rake db:migrate is the script where db is the namespace and migrate is the task name defined.
Actually it looks that the official way to achieve this behavior is like this:
Bundler.with_clean_env do
system "shell out"
end
I found the answer over at google groups: https://groups.google.com/d/msg/ruby-bundler/UufhzrliWfo/d51B_zARksUJ
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With