djl*_*ley 4 ruby gem bundler rvm thor
我正在thor为一些内部项目构建一个基于简单的生成器,似乎无法bundle install从正确的目录运行.
当我运行新的[APP_NAME]功能时,它应该创建目录和文件,然后运行bundle install以安装应用程序所需的gem.
生成器功能的来源:
def create
puts "Creating application #{name}"
directory 'application', "#{name}"
Dir.chdir("#{Dir.pwd}/#{name}") do
puts `bundle install`
end
end
Run Code Online (Sandbox Code Playgroud)
并且控制台输出来自运行调用此create方法的命令:
$ bundle exec bin/my_gem new test_app
Creating application test_app
create test_app
create test_app/Gemfile
create test_app/Guardfile
create test_app/README.md
create test_app/app/controllers
create test_app/app/helpers
create test_app/app/models
create test_app/app/views
Using thor (0.14.6)
Using my_gem (0.0.1)
Using bundler (1.1.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,它正在运行bundle install,但它的运行它在我的当前目录(thor,bundler,my_gem),而不是在test_app目录(guard,guard-coffeescript,guard-less,等).
运行其他命令,例如ls或pwd给出预期结果:
Gemfile
Guardfile
README.md
app
Run Code Online (Sandbox Code Playgroud)
和
/Users/davidlumley/Development/Gems/my_gem/test_app
Run Code Online (Sandbox Code Playgroud)
不确定它是否有任何区别,但我使用RVM来管理我的红宝石.
ava*_*tok 19
听起来你的应用程序已经在使用bundler,你有一个bundler-inside-bundler问题.试试这个:
Bundler.with_clean_env do
puts `bundle install`
end
Run Code Online (Sandbox Code Playgroud)
我猜你正在发生的事情是你的外部捆绑器将BUNDLE_GEMFILEenv变量设置为你的应用程序的Gemfile,然后你的内部捆绑器最终继承它.