ruby - Install bundle of gem within other rails application -


i have following setup:

a rails 4.0.0 application => master application

through application developers can create gem skeletons

now i´d create gem skeleton source code , run bundle install of gem gemfile through call in rails master application:

class myclass    # works   def create_gem_skeleton     path = "path-to-gem-skeleton-outside-the-rails-master-app"     fileutils.mkdir_p(path)     `cd #{path} && bundle gem my-new-gem`   end    # method gets called, after created gem skeleton , manipulated bit preferences   def my_method     path = "path-to-gem-skeleton-outside-the-rails-master-app"     exec `cd #{path} && bundle install`   # not work, installs rails master bundle inside rails master application, never touches new gem-skeleton     system `cd #{path} && bundle install` # =||= .. same here     `cd #{path} && bundle install`        # =||= .. same here    end  end 

anybody idea how can run such "bundle install" call within rails master application, install bundle in new gem-skeleton , not touch rails bundle?

i use rails 4.0.0 , ruby 2.0.0-p195

thanks!

mat

you should wrap backticks calls in block passed bundler.with_clean_env. ensure doesn't pick app's gemfile:

bundler.with_clean_env { `cd #{path} && bundle install` } 

see bundle-exec man page details.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -