Rvm and gems, bundle show and gem list - ruby-on-rails

Im using RVM with ruby on rails, when I do bundle install it shows a whole bunch more gems than when I do gem list? Something to do with rvm and which path its using?
bundle install
mds#db1:~/staging$ bundle
Using rake (0.9.6)
Using Ascii85 (1.0.1)
Using Platform (0.4.0)
Using open4 (1.3.0)
Using POpen4 (0.1.4)
Using activesupport (2.3.17)
Using rack (1.1.6)
Using actionpack (2.3.17)
Using actionmailer (2.3.17)
Using activerecord (2.3.17)
Using activeresource (2.3.17)
Using acts_as_audited (1.1.1)
Using addressable (2.2.8)
Using builder (3.0.0)
Using gyoku (1.0.0)
Using nokogiri (1.5.6)
Using akami (1.2.0)
Using ar-extensions (0.9.5)
Using cgi_multipart_eof_fix (2.5.0)
Using chunky_png (1.2.5)
Using cocaine (0.2.1)
Using coderay (1.0.9)
Using fssm (0.2.9)
Using sass (3.1.18)
Using compass (0.12.1)
Using daemons (1.1.9)
Using warden (0.10.7)
Using devise (1.0.6)
Using fastimage (1.2.13)
Using html_compressor (0.0.3)
Using rubyzip (0.9.8)
more gems......
Your bundle is complete!
It was installed into ./vendor/bundle
gem list
mds#db1:~/staging$ gem list
*** LOCAL GEMS ***
actionmailer (2.3.17)
actionpack (2.3.17)
activerecord (2.3.17)
activeresource (2.3.17)
activesupport (2.3.17)
bundler (1.3.5)
bundler-unload (1.0.1)
daemon_controller (1.1.4)
fastthread (1.0.7)
passenger (3.0.19)
rack (1.5.2, 1.1.6)
rails (2.3.17)
rake (10.1.0)
rubygems-bundler (1.2.2)
rvm (1.11.3.8)

this happens when you use bundle install --deployment or bundle install --path=..., it generates .bundle/config with something like this:
---
BUNDLE_FROZEN: '1'
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
it could be done by one of you coworkers or the bundler/capistrano integration:
if it was your coworker then just remove and ignore it:
rm -rf .bundle
echo '.bundle' >> .gitignore
for capistrano rvm-capistrano describes how to disable it => https://github.com/wayneeseguin/rvm-capistrano#disabling-bundle---deployment-when-using-gemsets

before doing gem list make sure you use the application's gemset:
rvm use application_ruby#application_gemset
gem list
Be sure to replace application_ruby with your ruby version string and application_gemset to the gemset that is used by your rails application

There is a hidden directory called .bundle in the root of your directory. Remove that, then run bundle again.

According to bundler documentation the current default, in ops case, may have been set to vendor/bundle, e.g. by a prior execution bundle install --path vendor/bundle:
Further bundle commands or calls to Bundler.setup or Bundler.require
will remember this location
Also check contents of $BUNDLE_PATH which shows where it's installed. Note: It's also possible it was installed to vendor/bundle via the --deployment option. See Deplyment mode 3.
As answered here, gem list will show only the gems installed using the --system option (see accepted answer and Caspar comment); use bundle list instead, to show gems installed in the application directory, i.e. via bundle install (without the --system option).

Related

installing rails 4.2 on ruby 2.2.0 using RVM generates "Your Ruby version is 2.2.0, but your Gemfile specified 2.1.5"

This is an update for the problem mentioned below:
I just found out that there is a Gemfile and Gemfile.lock in the root directory i.e system Home directory, and when ever i create a new gemset i believe it uses this gemfile. After installing rails in a newly created gemset, when check the rails version or try to create a new app, it shows the error Your ruby version is 2.2.0, but your Gemfile specifies 2.1.5, cause the Gemfile file in my home directory contains that ruby version, and if delete that Gemfile, and try to create a new rails app, it searches for that Gemfile.
I am current going through a hard time. I was starting a new project in ruby 2.2.0 and rails 4.2.0 and started by creating a gemset using RVM inside my project folder.
created gemset.
$rvm use ruby-2.2.0#myapp --ruby-version --create
Installed latest rails
$gem install rails
After that i checked the rails version just to verify
$rails -v
but instead i get a notification saying Your Ruby version in 2.2.0 but your Gemfile specified 2.1.5. I also don't have my application folder yet, cause i get the same output if i try to $rails new .
Following are the RVM related outputs
My RVM version is 1.26.10.
rvm gemset list
gemsets for ruby-2.2.0 (found in /Users/samy/.rvm/gems/ruby-2.2.0)
(default)
global
student-portal
=> myapp
gem list for global gemset
bigdecimal (1.2.7, 1.2.6)
bundler (1.7.13)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.2, 1.8.1)
mini_portile (0.6.2)
minitest (5.5.1, 5.4.3)
nokogiri (1.6.6.2)
power_assert (0.2.2)
psych (2.0.12, 2.0.8)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.0.9, 3.0.8)
gem list for myapp gemset
actionmailer (4.2.0)
actionpack (4.2.0)
actionview (4.2.0)
activejob (4.2.0)
activemodel (4.2.0)
activerecord (4.2.0)
activesupport (4.2.0)
arel (6.0.0)
bigdecimal (1.2.7, 1.2.6)
builder (3.2.2)
bundler (1.7.13)
bundler-unload (1.0.2)
erubis (2.7.0)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
globalid (0.3.2)
hike (1.2.3)
i18n (0.7.0)
io-console (0.4.3)
json (1.8.2, 1.8.1)
loofah (2.0.1)
mail (2.6.3)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1, 5.4.3)
multi_json (1.10.1)
nokogiri (1.6.6.2)
power_assert (0.2.2)
psych (2.0.12, 2.0.8)
rack (1.6.0)
rack-test (0.6.3)
rails (4.2.0)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.5)
rails-html-sanitizer (1.0.1)
railties (4.2.0)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
sprockets (2.12.3)
sprockets-rails (2.2.4)
test-unit (3.0.9, 3.0.8)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
tzinfo (1.2.2)
which ruby gives
/Users/samy/.rvm/rubies/ruby-2.2.0/bin/ruby
which rails gives
/Users/samy/.rvm/gems/ruby-2.2.0#myapp/bin/rails
the file contains
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
gem 'railties', version
load Gem.bin_path('railties', 'rails', version)
I tried removing and reinstalling RVM but i did not work.
Also i tried making app with ruby 2.1.5 with different gemset and all, but there i get different error when i try to do rails new app. i get the Could not find slop-3.6.0 in any of the sources
Run 'bundle install' to install missing gems., but once i do the bundle install i cannot run the rails new app command as it notifies
Can't initialize a new Rails application within the directory
of another, please change to a non-Rails directory first.
Any help would be greatly appreciated. If you need any more info i am ready to provide it.
Thanks in advance.
Cheers.
I had similar issues and restarting from scratch using this guide helped a lot. Though it seemed yet another guide, I found it to be a bit more systematic and detailed than the others.
Rails Apps Guide: Install Ruby on Rails ยท Ubuntu Linux
Alternatively, try Rails Apps Guide: Updating to Rails 4.2
Note:
Rails is not just a Ruby gem, it is a complex and rapidly evolving
ecosystem. It is important to set up your development environment with
the most current version of all the gems that are needed for
development.

Why "bundle install" try to install outdated version of gems?

I have different gemsets
> rvm gemset list
gemsets for ruby-2.0.0-p247 (found in /Users/kai/.rvm/gems/ruby-2.0.0-p247)
=> (default)
global
rails4
> rvm gemset use rails4
Using ruby-2.0.0-p247 with gemset rails4
> rails -v
/Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'railties' (>= 0) among 43 total gem(s) (Gem::LoadError)
from /Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /Users/kai/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/rails:22:in `<main>'
from /Users/kai/.rvm/gems/ruby-2.0.0-p247#rails4/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/kai/.rvm/gems/ruby-2.0.0-p247#rails4/bin/ruby_noexec_wrapper:14:in `<main>'
and when I'm doing:
> bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0)
Installing i18n (0.6.4)
Installing multi_json (1.7.9)
Installing activesupport (3.2.7)
Installing builder (3.0.4)
Installing activemodel (3.2.7)
Installing erubis (2.7.0)
Installing journey (1.0.4)
Installing rack (1.4.5)
Installing rack-cache (1.2)
Installing rack-test (0.6.2)
Installing hike (1.2.3)
Installing tilt (1.4.1)
Installing sprockets (2.1.3)
Installing actionpack (3.2.7)
Installing mime-types (1.23)
Installing polyglot (0.3.3)
Installing treetop (1.4.14)
Installing mail (2.4.4)
Installing actionmailer (3.2.7)
Installing arel (3.0.2)
Installing tzinfo (0.3.37)
Installing activerecord (3.2.7)
Installing activeresource (3.2.7)
Installing coffee-script-source (1.6.3)
Installing execjs (1.4.0)
Installing coffee-script (2.2.0)
Installing rack-ssl (1.3.3)
Installing json (1.8.0)
Installing rdoc (3.12.2)
Installing thor (0.18.1)
Installing railties (3.2.7)
Installing coffee-rails (3.2.2)
Installing jquery-rails (3.0.4)
Using bundler (1.3.5)
Installing rails (3.2.7)
Installing sass (3.2.10)
Installing sass-rails (3.2.6)
Installing sqlite3 (1.3.7)
Installing uglifier (2.1.2)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
But I have ruby 2.0! Why it doesn't install rails 4.0 and activesupport 4.0?
bundler installs gems basing on two files:
Gemfile.lock strict versions saved during previous installation,
Gemfile loose version declaration from user.
when you generate rails project first Gemfile is generated with something like this:
gem 'rails', '~> 3.2'
after the file is generated bundle install is ran which generates Gemfile.lock in which strict versions of gems are recorded, from now on any succeeding call to bundle install will install only the versions saved in Gemfile.lock.
To update gems to newer versions:
check Gemfile for any version restrictions - that might prevent installing the versions you would like to get
run bundle update <gem_name> to update only this single gem and what is require for it - but minimalizing scope of the changes to the smallest possible set of changes.
run bundle update to update all gems to latest versions allowed in Gemfile
bundle install or in short bundle does not install the latest gem unless you have left out the version in your Gemfile. e.g.
gem 'rails'
But usually this is not the case, we specify versions to prevent application from "crashing" when some gems are updated and we unknowingly run bundle update, or for that matter move application to say test or production servers. Usually when adding a gem to Gemfile, we do:
gem 'rails', '~> 3.2.7'
Note the leading ~> in the version number. This says: use rails gem between versions 3.2.7 and less than 3.3.0.
In order for your bundle command to grab rails 4.0, you need to change that line to read either one of the following:
gem 'rails', '>= 3.2.7'
or
gem 'rails', '4.0.0'
If you use gem 'rails', '>= 3.2.7' then your rails application will use the latest gem available in your system. Note that 3.2.7 is just an example I'm using here. If you use gem 'rails', '4.0.0' then your rails application will use rails version 4.0.0.
Please note that this change might break your existing rails 3.2 application.

"bundle install" fails even though bundler-1.1.3 is installed

I'm trying to run "bundle install" and it seems to have an issue with finding the appropriate gemfile even though I installed the gem bundler. I'm not sure what to do from here. When I run "bundle install" I get this:
C:\Users\User1\Sites\simple_cms>bundle install
Fetching gem metadata from http://rubygems.org/.........
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.0) x86-mingw32 depends on
bundler (~> 1.0.0) x86-mingw32
Current Bundler version:
bundler (1.1.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
So then I install the bundler gem which appears to install just fine.
C:\Users\User1\Sites\simple_cms>gem install bundler
Successfully installed bundler-1.1.3
1 gem installed
Installing ri documentation for bundler-1.1.3...
Installing RDoc documentation for bundler-1.1.3...
But even though the install for the bundler gem succeeded "bundle install" still fails:
C:\Users\User1\Sites\simple_cms>bundle install
Fetching gem metadata from http://rubygems.org/.........
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.0) x86-mingw32 depends on
bundler (~> 1.0.0) x86-mingw32
Current Bundler version:
bundler (1.1.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
When I run "gem list" the bundler is definitely there:
C:\Users\User1\Sites\simple_cms>gem list
*** LOCAL GEMS ***
actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.3)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.0.0)
bundler (1.1.3)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.1)
erubis (2.7.0)
execjs (1.3.1)
hike (1.2.1)
i18n (0.6.0)
io-console (0.3)
journey (1.0.3)
jquery-rails (2.0.2)
json (1.7.0, 1.5.4)
mail (2.4.4)
mime-types (1.18)
minitest (2.5.1)
multi_json (1.3.4)
mysql2 (0.3.11 x86-mingw32)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.3)
railties (3.2.3)
rake (0.9.2.2)
rdoc (3.12, 3.9.4)
rubygems-update (1.8.24)
sass (3.1.16)
sass-rails (3.2.5)
sprockets (2.1.3)
sqlite3 (1.3.6 x86-mingw32)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.4)
C:\Users\User1\Sites\simple_cms>
Try to remove your Gemfile.lock. Then run bundle check and see the output. It may ask you to run bundle install again.
It looks to me like your version of Rails (3.0.0) requires Bundler 1.0.0 -- you have a newer version.
You can install a specific version through gem install like this:
gem install bundler -v 1.0.0
I suggest you don't copy and paste whole projects.
First of all learn to use rvm or rbenv so you don't encounter conflicts with ruby versions and gems.
if your tutorial uses rails 3.0, you can put in something like
gem 'rails', '3.0.0'
in your Gemfile.
I suggest you install the latest rails version though and learn that.

Rails can not find rake gem?

Started learning ruby on rails today, after spending the half day fixing the other errors, I am stuck at the following: When I enter the following command in the terminal: " bundle exec rake db:migrate" or "rails server" it gives me the following error:
Could not find rake-0.9.2 in any of the sources
Run bundle install to install missing gems.
I ran bundle install rake (Both with version number and without) and it says it has been installed to ./rake. When I run the command it gives me the same error again. No Idea how to fix this, so any help is wholeheartedly appreciated. I am using ruby 1.9.2 and rails 3.0.9 in the directory the App is located in with RVM. Thanks in advance for any help.
EDIT:
* LOCAL GEMS *
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using bundler (1.0.15)
Using rdoc (3.8)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using sqlite3-ruby (1.2.5)
EDIT2: This has been fixed: Try using rvm and go back to ruby 1.8.7 instead of 1.9.2. This fixed it for me. Don't forget to install rails again (sudo gem install rails while already on 1.8.7) if you have only installed rails for 1.9.2.]
First, you should unlock the Gemfile
[root#localhost ~]#cd yourapplication [root#localhost
yourapplication]#bundle unlock
Then, edit your Gemfile, add gem rake
[root#localhost yourapplication]#vi Gemfile
+ gem 'rake', '0.9.2'
Then, update bundle
[root#localhost yourapplication]#bundle update
I guess you tried already gem install rake but it should come with rails anyway.
Well, what fl00r said in comments above, or show us the output of gem list --local

Could not find builder-2.1.2 in any of the sources

I'm following the Getting Started with Rails guide, but I ran into a problem:
bash-4.1$ bundle install
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.14)
Using actionmailer (3.0.3)
Using arel (2.0.7)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using bundler (1.0.7)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)
Using sqlite3-ruby (1.3.2)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
bash-4.1$ rake db:create
(in /Users/user/Documents/blog)
Could not find builder-2.1.2 in any of the sources
Try running `bundle install`.
bash-4.1$ bundle show builder
/Users/user/.gem/ruby/1.8/gems/builder-2.1.2
I also tried installing Builder as a RubyGem, but that didn't change a thing.
Try running it through bundle exec to make sure all of the gems specified in your Gemfile are available at their correct versions: bundle exec rake db:create
You can verify the installed gem is visible to bundle like this:
bundle show builder
/usr/lib/ruby/gems/1.8/gems/builder-2.1.2
I have the same problem though, bundle exec rake still fails to see the installed gem.
My version of rake (installed at /usr/bin/rake) was pointing at an old version of Ruby 1.8.
Modify the first line of rake to point at the correct version of Ruby. You can also clear out the bundle cache under the 'vendor' directory or move bundle to another local directory:
bundle install --path gems
On the command line, locate your default 'ruby' and 'rake' commands and check the version of Ruby:
which ruby
which rake
ruby -v
In /usr/bin/rake (line #1):
#!/opt/local/bin/ruby

Resources