Managing conflicting dependencies in Gemfile.lock - ruby

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?

Just define the specific version of the gem to a required version by adding the following line in the gemfile:
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 gemfile.lock into the project, it shell be used during a deployment anyway.

Related

Installing vagrant-librarian-chef Has net-ssh Version Conflicts

When trying to install vagrant-librarian-chef plugin for Vagrant 1.8.1 I get the following error
$ vagrant plugin install vagrant-librarian-chef
Ignoring bigdecimal-1.2.7 because its extensions are not built. Try: gem pristine bigdecimal --version 1.2.7
Ignoring bigdecimal-1.2.7 because its extensions are not built. Try: gem pristine bigdecimal --version 1.2.7
Installing the 'vagrant-librarian-chef' plugin. This can take a few minutes...
The plugin(s) can't be installed due to the version conflicts below.
This means that the plugins depend on a library version that conflicts
with other plugins or Vagrant itself, creating an impossible situation
where Vagrant wouldn't be able to load the plugins.
You can fix the issue by either removing a conflicting plugin or
by contacting a plugin author to see if they can address the conflict.
Vagrant could not find compatible versions for gem "net-ssh":
In Gemfile:
vagrant (= 1.8.1) x86-mingw32 depends on
net-ssh (~> 3.0.1) x86-mingw32
vagrant (= 1.8.1) x86-mingw32 depends on
net-scp (~> 1.1.0) x86-mingw32 depends on
net-ssh (>= 2.6.5) x86-mingw32
vagrant (= 1.8.1) x86-mingw32 depends on
net-scp (~> 1.1.0) x86-mingw32 depends on
net-ssh (>= 2.6.5) x86-mingw32
vagrant-librarian-chef (>= 0) x86-mingw32 depends on
librarian-chef (>= 0) x86-mingw32 depends on
chef (>= 0.10) x86-mingw32 depends on
net-ssh (~> 2.1.3) x86-mingw32
When I do gem list net-ssh I get the following back:
*** LOCAL GEMS ***
net-ssh (3.0.2, 2.9.4)
net-ssh-gateway (1.2.0)
net-ssh-multi (1.2.1)
Any help with what's wrong? I'm a total newbie to both ruby and vagrant which probably isn't helping the situation!
The problem is a conflict in the net-ssh version. Vagrant 1.8.1 uses v3.0.1, but vagrant-librarian-chef accepts versions up to 2.9.
Downgrading the vagrant version to 1.7.4 solved the issue for me.

Foreman Installation on Raspberry fails due to missing capybara

We are attempting to install foreman on a raspberry as a demo for installation on larger machines such as the cubietruck. We have problems building the foreman-installer from source:
bundle install --without mysql2 pg test --path vendor
Your Gemfile lists the gem gettext_i18n_rails_js (>= 0.0.8) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem gettext (~> 2.0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem locale (<= 2.0.9) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem minitest (~> 4.7) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...............................................
Could not find gem 'capybara (~> 2.0.0) ruby' in the gems available on this
machine.
We have already manually installed capybara using gem and can locally see it:
sudo gem list
*** LOCAL GEMS ***
bundler (1.6.2)
capybara (2.0.0)
childprocess (0.5.3)
ffi (1.9.3)
mime-types (2.3)
mini_portile (0.6.0)
multi_json (1.10.1)
nokogiri (1.6.2.1)
rack (1.5.2)
rack-test (0.6.2)
rubyzip (1.1.4)
selenium-webdriver (2.42.0)
websocket (1.0.7)
xpath (1.0.0)
Any ideas what we are missing?
Regards
Stefan

Travis CI won't install eventmachine?

I'm just getting started with CI on my open-source project, and it's all going swimmingly, however Travis is continually failing when it gets to pieces of code that require eventmachine. Eventmachine is specified in the gemspec as both runtime and development dependency (same as wisper), but Travis will not install Eventmachine, causing every build to fail - however, it does install wisper. What's going on? :(
Most recent build that failed
GemSpec Dependencies
..
spec.add_development_dependency 'bundler', '~> 1.5'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec', '~> 2.4'
spec.add_development_dependency 'wisper'
spec.add_development_dependency 'eventmachine'
spec.add_runtime_dependency 'wisper'
spec.add_runtime_dependency 'eventmachine'
Travis YML
rvm:
- 1.9.3
# we don't support 1.9.2
# - 1.9.2
- jruby
- rbx
script: "bundle exec rake"
Rake default task
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new :spec
task :default => :spec
Log
$ gem --version
2.2.2
$ bundle --version
Bundler version 1.5.3
Applying fix for NPM certificates
install
$ bundle install --deployment
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
Installing rake (10.1.1)
Installing wisper (1.3.0)
angler at /home/travis/build/DanPantry/angler did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
duplicate dependency on wisper (>= 0), (>= 0) use:
add_runtime_dependency 'wisper', '>= 0', '>= 0'
Using angler (0.0.1) from source at .
Installing timers (1.1.0)
Installing celluloid (0.15.2)
Installing nio4r (1.0.0)
Installing celluloid-io (0.15.0)
Installing diff-lcs (1.2.5)
Installing formatador (0.2.4)
Installing rb-fsevent (0.9.4)
Installing rb-inotify (0.9.3)
Installing listen (2.7.1)
Installing lumberjack (1.0.4)
Installing thor (0.18.1)
Installing guard (2.5.1)
Using bundler (1.5.3)
Installing guard-bundler (2.0.0)
Installing rspec-core (2.14.8)
Installing rspec-expectations (2.14.5)
Installing rspec-mocks (2.14.6)
Installing rspec (2.14.1)
Installing guard-rspec (4.2.8)
Cannot write a changed lockfile while frozen.
Your bundle is complete!
It was installed into ./vendor/bundle
$ bundle exec rake
/home/travis/.rvm/rubies/ruby-1.9.3-p484/bin/ruby -S rspec ./spec/remote_spec.rb
/home/travis/build/DanPantry/angler/lib/angler.rb:5:in `require': cannot load such file -- eventmachine (LoadError)
NOTE: Even without add_runtime_dependency, Travis just won't install EventMachine.
The important part of your log is this
angler at /home/travis/build/DanPantry/angler did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
duplicate dependency on wisper (>= 0), (>= 0) use:
add_runtime_dependency 'wisper', '>= 0', '>= 0'
Fix your gemspec, then bundler can install gems specified there. I simple solution would be to remove the development dependency to wisper and rely solely on the runtime_dependency for it.

"The gem ... has been deleted. It was installed at" Error. Bundle install doesn't install gems. How to re-install gems?

I'm trying to build capybara-webkit on XP. I follow this instruction. I says:
8) Clone latest version of capybara-webkit from Github:
$ git clone git://github.com/thoughtbot/capybara-webkit.git
9) Bundle/Install capybara-webkit version:
$ cd ruby193\capybara-webkit
$ bundle install
I did so at the first time. It installed some gems. Then I followed the instruction steps but couldn't build capybara-webkit. So to begin one more time, I deleted all the gems that were installed manually. Now I follow all the same steps but bundle install doesn't work any more. I says that all the gems are present:
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems>cd capybara-webkit
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle install
Resolving dependencies...
Using rake (0.9.2)
Using addressable (2.3.2)
Using bundler (1.3.5)
Using appraisal (0.4.0)
Using mime-types (1.22)
Using nokogiri (1.5.9)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using xpath (2.0.0)
Using capybara (2.1.0)
Using json (1.8.0)
Using capybara-webkit (1.0.0) from source at .
Using ffi (1.2.0)
Using childprocess (0.3.6)
Using diff-lcs (1.1.2)
Using websocket (1.0.6)
Using libwebsocket (0.1.7.1)
Using subexec (0.0.4)
Using mini_magick (3.2.1)
Using multi_json (1.5.0)
Using rack-protection (1.3.2)
Using rspec-core (2.6.4)
Using rspec-expectations (2.6.0)
Using rspec-mocks (2.6.0)
Using rspec (2.6.0)
Using rubyzip (0.9.9)
Using selenium-webdriver (2.27.2)
Using tilt (1.3.3)
Using sinatra (1.3.5)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
But now I check these gems with bundle show but it says they all were deleted:
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle show sinatra
The gem sinatra has been deleted. It was installed at:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/sinatra-1.3.5
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle show selenium-webdriver
The gem selenium-webdriver has been deleted. It was installed at:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle show mini_magick
The gem mini_magick has been deleted. It was installed at:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mini_magick-3.2.1
How it can be that bundle install says they are present but bundle show says they are deleted? So bundle install doesn't work any more. How may I again use bundle install to install these gems again?
This solved it for me: "gem install" and "bundle install" do not install gem dependencies after manual gem deletion. How to inform Rubygems that gems were deleted manually?
(Delete the .gemspec files for the gems you have removed).

Why does bundler think it needs a specific version when the gemspec specifies a pessimistic constraint?

My gemspec clearly requires active_support ~> 3.0, but bundler is failing to bundle install saying that my gem requires active_support = 3.0. WTF bundler? Can anyone explain this?
$ gem install code_filter
Successfully installed activesupport-3.0.0
Successfully installed active_support-3.0.0
Successfully installed code_filter-0.1.1
$ gem dependency code_filter
Gem code_filter-0.1.1
active_support (~> 3.0, runtime)
$ bundle
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://192.168.10.22/...
Fetching gem metadata from http://rubygems.org/...........
Fetching gem metadata from http://192.168.10.22/..
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
code_filter (= 0.1.1) ruby depends on
activesupport (= 3.0.0) ruby
json_builder (~> 3.1) ruby depends on
activesupport (3.0.20)

Resources