Question

In my gemspec file:

  • I have a gem dependency called zconfig that explicitly requires net-ssh version 2.6.8
  • I'm also using net-sftp, which in turn requires net-ssh version >= 2.6.5

When I bundle install, bundler is smart enough to recognize the needs of both gems and correctly identifies 2.6.8 as the version of net-ssh to install.

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)

So far, while testing on the remote server, I've been cloning the project and installing these gems with bundle install --deployment and then running the project with the locally instaled vendor gems using bundle exec ..

However, I'm now done with development and I've packaged the project as a gem and installed it on the remote server. The problem is that when executing the gem ruby doesn't adhere to my Gemfile.lock specification and uses net-ssh 2.7.0, which causes a conflict:

/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)

Is there a way to do something like bundle exec my_gem so that it uses the Gemfile.lock specifications?

Was it helpful?

Solution

Just define the specific version of the gem to a required version by adding the following line in the :

gem 'net-ssh', '2.6.8'

or in the thinegem.gemspec:

spec.add_dependency 'net-ssh', '2.6.8'

And if you did add the into the project, it shell be used during a deployment anyway.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top