bundle (Gem::LoadError) - ruby-on-rails

I have been trying to install bundle on arch linux while on version 1.9.3 switched using chruby. I thought chruby was the problem and a switched to rbenv but the problem persisted. I could not install gems in version 1.9.3 and then back to chruby but same isssue. Gems just domn't seem to install.
The output from running bundle is:
/opt/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/rubygems/dependency.rb:247:in to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.5, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.5] (Gem::LoadError)
from /opt/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/rubygems/dependency.rb:256:into_spec'
from /opt/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/rubygems.rb:1231:in gem'
from /home/urbanslug/.gem/ruby/1.9.1/bin/bundle:22:in'
My gem env output is:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-02-22 patchlevel 392) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/urbanslug/.gem/ruby/1.9.3
- RUBY EXECUTABLE: /opt/rubies/ruby-1.9.3-p392/bin/ruby
- EXECUTABLE DIRECTORY: /home/urbanslug/.gem/ruby/1.9.3/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/urbanslug/.gem/ruby/1.9.3
- /opt/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["https://rubygems.org/"]
- "gem" => "--user-install"
- REMOTE SOURCES:
- https://rubygems.org/

I would recommend rvm. It just makes installing/maintaining so much easier.

How did you install or setup rbenv exactly? rbenv can install and setup different ruby development environment separately, including the gem path. Assume your git and curl are working, you can use getrbenv to configure/install rbenv easily. Or you can install first without default ruby version by:
curl -sSL https://raw.githubusercontent.com/martinsteinorth/getrbenv-installer/master/bin/install.sh | bash -s -- --plugins sstephenson/ruby-build,rkh/rbenv-update
After source your profile or restart your shell, install ruby and set the default version
rbenv install 1.9.3-p551
rbenv rehash
rbenv global 1.9.3-p551
Now your bundle should work for your gems. You can also consider newer version like 2.2.2 or 2.0.0-p645. Good luck!

Related

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.

OSX bundler install command not found

I'm getting this error:
Could not find i18n-0.6.1 in any of the sources
Run bundle install to install missing gems.
When i try to run bundle install, i get this:
-bash: bundle: command not found
I have googled and tried to solve this for a while now with no hope. Please help.
Don't mess with your PATH.
Just use rbenv and ruby-build to manage and install your ruby version(s).
And then install the bundler gem and rehash.
Install rbenv (if you haven't already) as follows:
$ brew update
$ brew install rbenv ruby-build
Initialize rbenv as follows:
$ rbenv init
Install ruby-build to compile and install different versions of Ruby on UNIX-like systems:
brew install ruby-build
Install a specific ruby version, e.g., 1.9.3-p551:
$ RUBY_VERSION=1.9.3-p551
$ ruby-build $RUBY_VERSION $HOME/.rbenv/versions/$RUBY_VERSION
Verify it worked:
$ ruby --version
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin14.0.0]
Set that version to be the global/default Ruby version:
$ rbenv global 1.9.3-p551
Install bundler:
$ gem install bundler
Fetching: bundler-1.7.11.gem (100%)
Successfully installed bundler-1.7.11
1 gem installed
Update rbenv:
$ rbenv rehash
Now, bundler will be available in the version of Ruby (1.9.3-p551) that you just installed.
Verify RubyGems Environment:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23.2
- RUBY VERSION: 1.9.3 (2014-11-13 patchlevel 551) [x86_64-darwin14.0.0]
- INSTALLATION DIRECTORY: /Users/lex/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/lex/.rbenv/versions/1.9.3-p551/bin/ruby
- EXECUTABLE DIRECTORY: /Users/lex/.rbenv/versions/1.9.3-p551/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/lex/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1
- /Users/lex/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- "install" => "--no-ri --no-rdoc"
- "update" => "--no-ri --no-rdoc"
- :sources => ["http://rubygems.org", "http://gems.github.com", "http://gems.rubyforge.org", "http://gemcutter.org"]
- REMOTE SOURCES:
- http://rubygems.org
- http://gems.github.com
- http://gems.rubyforge.org
- http://gemcutter.org
try to run
gem env
and then you will get something like this:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-darwin12.5.0]
- INSTALLATION DIRECTORY: /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/Cellar/ruby193/1.9.3-p448/bin/ruby
**- EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby193/1.9.3-p448/bin**
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /usr/local/Cellar/ruby193/1.9.3-p448/lib/ruby/gems/1.9.1
- /Users/madhava/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Just add the executable directory to your PATH variable like this:
echo PATH=/usr/local/Cellar/ruby193/1.9.3-p448/bin:$PATH >> ~/.bash_profile
Reload your terminal to apply the changes and you will be set!
Seems with Sierra, you need to use this to get bundler installed:
sudo gem install bundler -n /usr/local/bin
Reference here refers to how El Cap introduced "SIP (System Integrity Protection)."
I am on Mac OS X Maverics (10.9.2)
Currently my ~/.profile file reads as follows:
# MacPorts Installer addition on 2014-02-23_at_17:28:39: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
source /usr/local/bin/virtualenvwrapper.sh
. /sw/bin/init.sh
And my PATH variable ($PATH) is set to
/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
This is what worked for me.
First I installed bundler using:
gem install bundler
However I got error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Hence I ran sudo gem install bundler and that installed bundler successfully
After that when I ran gem env I got the Executable Directory set to /usr/bin which is already part of my PATH variable. Hence I didn't make any changes to ~/.profile file.
and now I am successfully able to run bundle install.
If the path listed in Executable Directory is not included in your $PATH variable or ~/.profile file, you will have to include it.
Note that if you're using rbenv, you should probably just rbenv rehash and not mess with your PATH

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.

Why are the gems not showing up?

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

"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