Why are the gems not showing up? - ruby-on-rails

So this happens to me regularly, where i have gems that are installed but for some reason my rails app is not finding it...here is my example
my config/environment.rb
config.gem "whenever"
my install
sudo gem install whenever
Password:
Successfully installed whenever-0.6.2
1 gem installed
gem list | grep when
whenever (0.6.2)
script/server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
Missing these required gems:
whenever
You're running:
ruby 1.8.7.174 at /usr/local/bin/ruby
rubygems 1.3.7 at /Users/matt/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.4.0]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.8
- /Users/matt/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
- http://gemcutter.org
$ which gem
/usr/local/bin/gem
$ which ruby
/usr/local/bin/ruby
Does anybody see the issue because i clearly cant even start my server and i know the gem is installed. I am on a macbook pro with Snow leopard by the way...

Please check you ruby and gem installation :
May be use these commands
which ruby
which gem
and make sure they have the correct path.
Most times people have these problems is that "gem" command installs gems into a different ruby installation instead of the one used by your rails app.

I had two different 1.9.x ruby versions, and I had installed rvm.
All the gems installed through rvm were not showing up.
Basically my "which gem" was showing /usr/bin/gem while it was supposed to be "/home/gh/.rvm/rubies/ruby-1.9.x/bin/gem"
If such is the case, in your gnome-terminal, under Edit > Profile Preferences > Title and Command, check the option "Run command as a login shell"
This integrates rvm with gnome-terminal :) Hope this helps someone who faced the same issue as I did.
Reference: https://rvm.io/integration/gnome-terminal

Related

Ruby: Can't get gem to upgrade from 1.8.23 to 1.9.1 on Ubuntu 14.04

I'm just getting started with Ruby on Rails, so I apologize if I'm missing something horribly basic here...
Through some reading (and complaints from Rails), I've seen a lot of recommendations to install Ruby/Gem >v1.9. I upgraded whatever version Ruby was on my Ubuntu 14.04 machine to v1.9.3, but my version of Gem refuses to upgrade beyond 1.8.23.
The gem executable is labeled /usr/bin/gem1.9.1, but when you ask it for its version or dump the environment it returns 1.8.23. Rails seems to have installed fine with it as 1.8.23, but whines at me to upgrade whenever I generated a new project.
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
$ /usr/bin/gem1.9.1 -v
1.8.23
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/andy/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I installed ruby with sudo apt-get ruby-dev, which seems to be what folks are saying is correct for Ubuntu. At one point I tried sudo apt-get ruby-full, as recommended by ruby-lang.org but that didn't seem to work either.
I'm trying to make sure I set this up correctly, so I don't get too deep into development and realize I borked my environment from the get-go. Should I just give up on apt-get and install from source, or is there something else that I did wrong?
Thanks
Use rubygems-update:
gem install rubygems-update
update_rubygems
gem update --system

Gem environment/install location and bundler

it's been a while since I setup a brand new Rails environment.
I am trying to get gems to install under ~/.gems as opposed to /usr to avoid sudo-ing constantly.
Here is my gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/myname/.gems
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /home/myname/.gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/myname/.gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri"
- "gemhome" => "/home/myname/.gems"
- "gempath" => ["/home/myname/.gems"]
- REMOTE SOURCES:
- https://rubygems.org/
$ which bundle
/home/myname/.gems/bin/bundle
now I did rails new SomeApp and when I run
bundle install
I get:
Errno::EACCES: Permission denied - /usr/local/lib/ruby/gems/2.0.0/build_info/jquery-rails-3.0.4.info
An error occurred while installing jquery-rails (3.0.4), and Bundler cannot continue
Which tells me that it's still trying to install the gem NOT where I want it. Any thoughts what to check? (I do have a ~/.gemrc file, the contents are the last 3 lines of the GEM CONFIGURATION section above).
Many thanks for all tips -- this was supposed to be a quick and easy step :)
highly recommend rbenv and rbenv-gemset, installing here with homebrew:
brew install rbenv rbenv-gemset
cd into/project/
echo specialgemsetname > .rbenv-gemsets
now start a new terminal (to ensure environment is correct) and setup your project.

how to install the latest version of rails on ubuntu 11.10?

I want to install rails 3.2.1 on ubuntu 11.10.
I already installed rbenv, ruby-build.
When I run
gem install rails
it tells me
Successfully installed rails-3.2.1
1 gem installed
Installing ri documentation for rails-3.2.1...
Installing RDoc documentation for rails-3.2.1...
then after rbenv rehash, if I run "rails", it cannot find the binary file. So I guess rails is NOT installed. How can I do?
edit:
~ » gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /home/jafar/.rbenv/versions/1.9.3-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/jafar/.rbenv/versions/1.9.3-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1
- /home/jafar/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
edit 2 :
gem list tells me the rails gem is installed. When I search for the rails binary I find this :
~ » find . -name rails
./.oh-my-zsh/plugins/rails
./Downloads/robbyrussell-oh-my-zsh-3629270/plugins/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/guides/code/getting_started/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/bin/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails/app/templates/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails/plugin_new/templates/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/engine_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/engine_project/test/dummy/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/scss_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/sass_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/lib/sass/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activerecord-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/actionmailer-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jquery-rails-2.0.0/lib/jquery/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-3.1.12/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bin/rails
The rails binary should be in ~/.rbenv/shims but it's not. ~/.rbenv/shims is in my PATH
You need to add the bin subdirectory of /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1 to your PATH, e.g. edit your ~/.bashrc file and add this line at the end:
export PATH=/home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bin:$PATH
And then see what the command rails --version will output.

How to change the path where ruby gems are installed on OS 10.6.6 Ruby 1.8 and Rails 3

Whether I use gem install or bundle install for my gems, they don't work. Sometimes sudo gem install gets gems to work. I ran the gem list -d and which gem commands, and it seems that my system is configured such that all the gems get installed into " /Library/Ruby/Gems/1.8" but my environment expects them in "/usr/bin/gem". How could I properly correct this? I was under the impression that 'bundle' should be able to install a local, application specific copy of a gem?
Although many Rubyists will recommend you RVM or RBENV, I do not use it. It's VERY slow and it pollutes your environment.
If you use Bundler, you dont need RVM at all - rubygem itself supports multiple versions of single gems. So you can just start using gems (e.g. gem install etc) and it will install into your $HOME/.gem directory by default. You can check the installation path using:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.9.3 (2013-02-06 patchlevel 385) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/lzap/.gem/ruby/1.9.3
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /home/lzap/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/lzap/.gem/ruby/1.9.3
- /usr/share/gems
- /usr/local/share/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-rdoc --no-ri"
- REMOTE SOURCES:
- http://rubygems.org/
You can even change this with GEM_HOME environment variable. Happy gemming!
I would suggest using RVM (Ruby Version Manager) to control which version of Ruby you are installing your gems into. It will also help keep all the bundle and gem data in a folder in your home directory.

"gem install bundler --version=0.8.1" doesn't install the bundle executable

When trying to install Bundler 0.8.1 on Ubuntu machine, it install fine but the executable "bundle" is no where to be seen. Other gems install successfully, including their executables.
using: gem install bundler --version=0.8.1
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
- INSTALLATION DIRECTORY: /home/ahammad/gems
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /home/ahammad/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/ahammad/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gem1.gilt.com"]
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Path /home/ahammad/gems/bin has been added to PATH, the problem is there is no bundle exe.
Any ideas?
Maybe that specific version of bundler wasn't available for installation, so to choose specific available range of versions which could be available, try:
gem install bundler --version '<= 0.10.6'
Or simple uninstall the previous bundler and install it again. Then check by gem list bundler or bundler _0.9.26_ -v (where 0.9.26 is version of your older gem).
Check also the permissions of your local gem folders.
Learn more: How to upgrade/downgrade Rubygems at rubyforge
That might be. I've used only 1.0. But I had the same problem. A tutorial assumed I could run "bundle". It was fixed only after following the directions here
http://lindsaar.net/2010/3/31/bundle_me_some_sanity
The directions involve installing rvm and creating an app directory with a .rvmrc file among other things.
Then in that directory you can run "bundle".
The binary is ~/.rvm/gems/ruby-1.8.7-p302#railsplugins/bin/bundle
apparently 0.8.1 uses "gem bundle" rather than "bundle"

Resources