where are my gems installed with rbenv? - ruby

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)

Related

Why is bundler a dependency but not a spec in Gemfile.lock?

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.

Bundler could not find compatible versions for gem "actionpack"

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)

Error while installing spree

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.

Bundler: is bundle viz the only way to show the dependencies?

I don't have Graphviz on this machine and don't wish to install it, so an alternative, the terminal being preferred, would be good.
Bundler v1.1.5
Gemfile.lock shows dependencies:
view Gemfile.lock
e.g.
GEM
remote: http://rubygems.org/
specs:
ZenTest (4.5.0)
aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (3.0.19)
actionpack (= 3.0.19)
mail (~> 2.2.19)
actionpack (3.0.19)
activemodel (= 3.0.19)
activesupport (= 3.0.19)
...

heroku, thin rack 1.1.0, gemfile requires rack 1.0.1

My ror app runs on rails 2.3.5(which requires rack 1.0.1),
thin on heroku activates rack 1.1.0 by default
and throws error:
" You have already activated rack 1.1.0, but your Gemfile requires rack 1.0.1. Consider using bundle exec."
my Gemfile:
source 'http://rubygems.org'
group :test, :development do
gem "rack","1.0.1"
end
gem "rails","2.3.5"
gem "mysql"
gem "rake", "0.8.3"
gem "declarative_authorization", "0.5.2"
gem "searchlogic"
gem "prawn", "0.6.3"
gem "thin","1.2.11"
group :test, :development do
gem "rack","1.0.1"
end
group :development do
# bundler requires these gems in development
# gem "rails-footnotes"
end
group :test do
# bundler requires these gems while running tests
# gem "rspec"
# gem "faker"
end
----------------------
I installed bundler and developed Gemfile.lock :
GEM
remote: http://rubygems.org/
specs:
actionmailer (2.3.5)
actionpack (= 2.3.5)
actionpack (2.3.5)
activesupport (= 2.3.5)
rack (~> 1.0.0)
activerecord (2.3.5)
activesupport (= 2.3.5)
activeresource (2.3.5)
activesupport (= 2.3.5)
activesupport (2.3.5)
daemons (1.1.4)
declarative_authorization (0.5.2)
eventmachine (0.12.10)
mysql (2.8.1)
prawn (0.6.3)
prawn-core (>= 0.6.3, < 0.7)
prawn-format (>= 0.2.3, < 0.3)
prawn-layout (>= 0.3.2, < 0.4)
prawn-security (>= 0.1.1, < 0.2)
prawn-core (0.6.3)
prawn-format (0.2.3)
prawn-core
prawn-layout (0.3.2)
prawn-security (0.1.1)
rack (1.0.1)
rails (2.3.5)
actionmailer (= 2.3.5)
actionpack (= 2.3.5)
activerecord (= 2.3.5)
activeresource (= 2.3.5)
activesupport (= 2.3.5)
rake (>= 0.8.3)
rake (0.8.3)
searchlogic (2.4.28)
activerecord (>= 2.0.0)
thin (1.2.11)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
PLATFORMS
ruby
DEPENDENCIES
declarative_authorization (= 0.5.2)
mysql
prawn (= 0.6.3)
rack (= 1.0.1)
rails (= 2.3.5)
rake (= 0.8.3)
searchlogic
thin (= 1.2.11)
---------------------------
Please help me deploy it on heroku........
Solved it...
my app uses rack 1.0.1 , rails 2.3.5
and heroku activates rake 1.1.0 by default..
so i switched my rails app version to 2.3.11 which uses rack 1.1.2 in environment.rb and created a Gem file,
installed bundler
tested on my laptop...
generated lock file and pushed it to heroku...
finally worked....
took a week to get my app working...
:)

Resources