I'm parsing Gemfile.lock to create a dependency graph. A sample of the file:
rack-ssl (1.3.4)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (3.2.22.1)
actionmailer (= 3.2.22.1)
actionpack (= 3.2.22.1)
activerecord (= 3.2.22.1)
activeresource (= 3.2.22.1)
activesupport (= 3.2.22.1)
bundler (~> 1.0)
railties (= 3.2.22.1)
rack (1.4.7)
It is a list of specs (gems which need to be installed for this project), followed by an indented list of that spec's dependencies. Because every dependency needs to be installed, they are all listed as specs somewhere else in the file. (E.G. rack is listed as a spec in the bottom of the sample, but is a dependency for two other specs near the top)
The one exception to this rule is bundler, which is listed as a dependency but not as a spec. Why is this? Is it because gems already installed on a system level aren't included in the Gemfile.lock? Or is this a special case because bundler is the gem that generates Gemfiles, so it doesn't include itself?
If any of the needed gems are already installed, Bundler will use them. After installing any needed gems to your system, bundler writes a snapshot of all of the gems and versions that it installed to Gemfile.lock
https://bundler.io/rationale.html
It's bundler that creates Gemfile.lock and it's a list of all dependencies that are installed by bunler. As bundler does not install itself, it's not included. It makes it a special gem - the one that needs to be installed to bootstrap a ruby app.
Related
When I'm trying to bundle update i get this error:
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
actionpack (>= 4.2.5, ~> 4.2)
railties (>= 4.2.5, ~> 4.2) was resolved to 4.2.5, which depends on
actionpack (= 4.2.5)
railties (>= 4.2.5, ~> 4.2) was resolved to 4.2.5, which depends on
actionpack (= 4.2.5)
railties (>= 4.2.5, ~> 4.2) was resolved to 4.2.5, which depends on
actionpack (= 4.2.5)
strong_parameters (~> 0.2.3) was resolved to 0.2.3, which depends on
actionpack (~> 3.0)
This problem can arise if you update the Rails version (for example from 4 to 5), and you have included certain gems locked to a specific version which still depend on an old ActionPack version from the old Rails version. Then bundler says..
Bundler could not find compatible versions for gem "actionpack"
..because the new rails version wants to use the new ActionPack gem, but one of the gems wants to use the old ActionPack gem.
You should've include the Gemfile in the question.
Anyway, in Rails 4.x strong_parameters gem is not required. If you have that in your gemfile, remove it and try again.
You don't need the strong_parameters gem. Strong parameters is part of rails 4, the gem allows that feature to be backported to rails 3.x
This is partly to help rails 3.x users to migrate to rails 4 and I think it may have been used earlier to prototype how strong parameters should work (by allowing people to use it without switching to rails edge)
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
Bundler could not find compatible versions for gem "railties":
In Gemfile:
rails (= 3.2.8) ruby depends on
railties (= 3.2.8) ruby
sass-rails (~> 4.0.0) ruby depends on
railties (4.0.0)
This error occured, how can i fix this error.
I do not know railties and sass-rails version.
If you're using Rails 3.2 you should use all gems with that branch too, i.e.:
Gemfile:
gem https://github.com/rails/sass-rails.git, branch: '3-2-stable'
You can see branches listed on GH next to green compare button (with new layout).
What if specific gem doesn't have branches? Well, you can fork it, modify the gemspec,see what fails and fix it.
I use rbenv and bundler, I want open the installed rails gem and insert some debug codes. So I run 'bundle show rails' in a rails project, I get '~/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rails-3.2.11', but there is nothing in this directory.
Rails is just a meta-gem, as-in it doesn't contain any actual code, it just lists dependencies that make up Rails. This is why the gem's directory is empty.
If you want to edit part of the Rails code you should edit the relevant dependency. In a Gemfile.lock the direct dependecies of Rails 3.2.11 are listed as follows:
rails (3.2.11)
actionmailer (= 3.2.11)
actionpack (= 3.2.11)
activerecord (= 3.2.11)
activeresource (= 3.2.11)
activesupport (= 3.2.11)
bundler (~> 1.0)
railties (= 3.2.11)
This is not the first time I've run into this, but here's a concrete example:
$ bundle update rails
Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "builder":
In Gemfile:
rails (~> 3.0.0) ruby depends on
builder (~> 2.1.2) ruby
hoptoad_notifier (>= 0) ruby depends on
builder (3.0.0)
So Bundler claims the hoptoad_notifier gem depends on the 3.0.0 version of builder. But that's not the case, it only requires builder >= 0.
$ gem dependency hoptoad_notifier
Gem hoptoad_notifier-2.4.11
actionpack (>= 0, development)
activerecord (>= 0, development)
activesupport (>= 0, runtime)
bourne (>= 0, development)
builder (>= 0, runtime)
nokogiri (>= 0, development)
shoulda (>= 0, development)
Why does Bundler think hoptoad_notifier depends on builder 3.0.0?
Selected bits from the Gemfile and Gemfile.lock:
source "http://rubygems.org"
gem 'rails', '~> 3.0.0'
gem 'hoptoad_notifier'
...a bunch of testing gems, custom gems, etc.
Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
actionmailer (2.3.14)
actionpack (= 2.3.14)
...
builder (3.0.0)
...
cucumber (1.2.0)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.10.0)
json (>= 1.4.6)
...
hoptoad_notifier (2.4.11)
activesupport
builder
... no other mentions of builder
I consider this more of a workaround than an answer to the question, so I'll leave the question open for a while to see if there's a better answer.
I found different ways to attack the problem (using bundle update on specific gems, modifying the Gemfile, running bundle install), but continued to run into some form of this error for various dependencies. It really seems like an issue with Bundler. (I'm using v1.0.22, upgrading made it worse.) Ultimately, what got me out of this mess was to delete the Gemfile.lock and run bundle install, letting Bundler resolve all the dependencies from scratch. Now of course, this is far from ideal, since the whole reason you have a lock file is to lock down your app's dependencies. But since I'm upgrading Rails to v3 anyway, it was acceptable in this case.