在我的gemspec文件中:
当我
bundle install时,bundler非常聪明,可以识别这两个gem的需求,并正确地将2.6.8标识为要安装的net-ssh版本。
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
...
net-ssh (2.6.8)
...
zconfig (0.2.7)
mysql (~> 2.9.1)
mysql2 (~> 0.3.13)
net-ssh (~> 2.6.8)
net-ssh-gateway (~> 1.2.0)
sequel (~> 4.1.0)
sqlite3 (~> 1.3.7)
到目前为止,在远程服务器上进行测试时,我一直在克隆项目并使用
bundle install --deployment安装这些gem,然后使用
bundle exec ..使用本地安装的供应商gem运行该项目。
但是,我现在已完成开发工作,并将该项目打包为gem,并将其安装在远程服务器上。问题是执行 gem ruby 时不遵守我的Gemfile.lock规范,而是使用net-ssh 2.7.0,这会导致冲突:
/usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1615:in `raise_if_conflicts': Unable to activate zconfig-0.2.7, because net-ssh-2.7.0 conflicts with net-ssh (~> 2.6.8) (Gem::LoadError)
有没有办法像
bundle exec my_gem这样使用Gemfile.lock规范?
请您参考如下方法:
只需在gemfile中添加以下行,即可将gem的特定版本定义为所需版本:
gem 'net-ssh', '2.6.8'
或在 thinegem.gemspec 中:
spec.add_dependency 'net-ssh', '2.6.8'
而且,如果确实将 gemfile.lock添加到项目中,则无论如何在部署期间都可以使用它shell。




