Mat*_*ias 2 ruby rubygems ruby-on-rails bundler
我有以下设置:
一个rails 4.0.0 application =>我的主应用程序
通过这个应用程序,开发人员可以创建gem骨架
现在我想创建gem骨架源代码并通过rails master应用程序中的调用运行gem Gemfile的bundle install:
class MyClass
# this 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
# this method gets called, after I created the gem skeleton and manipulated it a bit with my preferences
def my_method
path = "path-to-gem-skeleton-outside-the-rails-master-app"
exec `cd #{path} && bundle install` # does not work, installs always the rails master bundle inside my rails master application, never touches the new gem-skeleton
system `cd #{path} && bundle install` # =||= .. same here
`cd #{path} && bundle install` # =||= .. same here
end
end
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何在我的rails主应用程序中运行这样的"bundle install"调用,在新的gem-skeleton中安装bundle而不是触摸rails bundle?
我使用rails 4.0.0和ruby 2.0.0-p195
谢谢!
垫
你应该在传递给的块中包装你的反引号调用Bundler.with_clean_env.这将确保它不会获取您的应用程序的Gemfile:
Bundler.with_clean_env { `cd #{path} && bundle install` }
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参见bundle-exec手册页.