Rails Gem bundler not installed - even after I install it - ruby-on-rails

For a Rails app, I tried running $ bundle install. But, even after I ran $ gem install bundler, I got the same message.
this is what happened:
Run `bundle install` to install missing gems.
Davids-iMac-2:213calendar davidburton$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.
Davids-iMac-2:213calendar davidburton$ gem install bundler
Successfully installed bundler-1.3.5
1 gem installed
Installing ri documentation for bundler-1.3.5...
Installing RDoc documentation for bundler-1.3.5...
Davids-iMac-2:213calendar davidburton$ bundle install
ERROR: Gem bundler is not installed, run `gem install bundler` first.
UPDATE1
rvm list
rvm rubies
ruby-1.9.2-p290 [ x86_64 ]
=* ruby-1.9.3-p374 [ x86_64 ]
# => - current
# =* - current && default
# * - default

Check your home directory for a ~/.bash_profile file.
If it exists, and you don't remember creating it, copy its contents to ~/.bashrc and remove the .bash_profile file completely.
By default, rvm appends the commands for updating path with rvm function in .bash_profile after rvm installation.
Ubuntu, at a time only uses .bash_profile if it is present, or .bashrc when .bash_profile is absent. This results in PATH not being correctly set, and the gem, even though installed, is not detected since it is not on your path.

Related

Can not downgrade bundler for heroku

I am trying to push my project to heroku and I am getting this error.
Your Ruby version is 2.3.0, but your Gemfile specified 2.3.0
remote: Bundler Output: Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
I am also using rvm.
It seems like the heroku bundler uses 1.11.2 so I am trying to downgrade my version from 1.12.5.
I did gem uninstall bundler then gem install bundler --version '1.11.2'
However when I do bundler -v, it's still showing 1.12.5
But when I do gem uninstall bundler, it shows
Successfully uninstalled bundler-1.11.2
I still can't push and I am getting that error. Please help.
Please follow these steps;
http://rubygems.rubyforge.org/rubygems-update/UPGRADING_rdoc.html
And one more thing I think your bundler is installed in the rvm default gemset i.e. system gemset.
Try checking this;
Do rvm list in terminal, this will give you output like this;
rvm rubies
ruby-2.0.0-p643 [ x86_64 ]
=* ruby-2.1.4 [ x86_64 ]
ruby-2.2.1 [ x86_64 ]
ruby-2.2.4 [ x86_64 ]
Now do rvm gemset list; this will give you out put as this;
(default)
global
some-gemset
Check which gemset its used in your system, it can be identified as => global whenever you do the rvm gemset list.
Now when you identified in which gemset you currently in, do something like this rvm use 1.9.2#global
Then;
gem uninstall bundler
Or in a single step you can do it like this;
rvm #global do gem uninstall bundler
And then install your desired bundler version like this;
gem install bundler --version '1.11.2'
Hope this might help you.

Running rails console suddenly stopped working

All of the sudden, Rails' console stopped working on one of my projects. I keep getting the following error:
rails c
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Could not find activesupport-4.1.4 in any of the sources
Run `bundle install` to install missing gems.
So I updated Rubygems, with the following two lines (from rubygems.com)
$ gem install rubygems-update # again, might need to be admin/root
$ update_rubygems
and get the following output:
Successfully installed rubygems-update-2.4.4
Parsing documentation for rubygems-update-2.4.4
Done installing documentation for rubygems-update after 0 seconds
1 gem installed
...
RubyGems 2.4.4 installed
Parsing documentation for rubygems-2.4.4
Installing ri documentation for rubygems-2.4.4
=== 2.4.4 / 2014-11-12
Aaaaaand, then I run rails console again, and just get the same error message again.
Thoughts?
This might be the problem only if you use rvm else just ignore it.
Navigate to the root path (where your rails app is located).
type in your command line;
rvm list
You will get something like:
rvm rubies
jruby-1.7.11 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
=* ruby-2.0.0-p451 [ x86_64 ]
ruby-2.1.0 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
If your default is not the current you have most likely changed it.
Try to change it back and run:
You can change it like so:
rvm use ruby-2.0.0-p451
When you get the right version you can make it permanent.
like so:
rvm --default use ruby-2.0.0-p451
bundle install
again.
Just a shot in the dark, but maybe try:
gem install activesupport -v 4.1.4
Then try and run rails c again.
The message also says to run gem pristine --all which will reinstall all the gems from the cache and recompile all native drivers in the gems.
Updating the Rubygems code doesn't do this so you have to explicitly run the command.

Capybara gem installation error in Ubuntu12

Iam trying to execute command the bundle install it is showing the error message
Gem::InstallError: capybara requires Ruby version >= 1.9.3.
An error occurred while installing capybara (2.1.0), and Bundler cannot continue.
Make sure that `gem install capybara -v '2.1.0'` succeeds before bundling.
so i upgrade my ruby 1.8.2 to ruby 1.9.3 and set this as default in rvm.
$ rvm list
rvm rubies
=* ruby-1.9.3-p448 [ x86_64 ]
# => - current
# =* - current && default
# * - default
$ ruby -v
iam getting ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
same error obtaining when executing bundle install .
because of using rvm i use the command gem install capybara -v '2.1.0' iam getting
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions into the /var/lib/gems/1.9.1 directory
later i tried sudo gem install capybara -v '2.1.0'
it successfully installed
so again i used the bundle install command to install remaing gems in my gem file it agian showing the same above mentioned error.
Gem::InstallError: capybara requires Ruby version >= 1.9.3.
An error occurred while installing capybara (2.1.0), and Bundler cannot continue.
Make sure that `gem install capybara -v '2.1.0'` succeeds before bundling.
I suggest you to set project dependent rvm settings.
Goto to your project folder and do the following:
echo "ruby-1.9.3-p448" > .ruby-version
echo "myapp" > .ruby-gemset
Close the console, reopen it and once again go to your project folder. Then, verify you ruby version is 1.9.3-p448 (ruby -v) and do the following:
gem install bundler
bundle install
For more details, see this answer
make sure you have installed these before trying...
sudo apt-get install libqt4-dev libqtwebkit-dev

RVM bundler installed ERROR: Gem bundler is not installed, run `gem install bundler` first

I get to work with a new project and it's based on ruby 1.8.7, I'm using rvm to manage my ruby versions and I have installed 1.8.7 and 1.9.2.
The thing is when I do:
rvm use 1.8.7
and try to run:
bundle install
I get:
ERROR: Gem bundler is not installed, run `gem install bundler` first.
I've installed bundler 5 times and even after that it says it's not installed. What can cause this? Bundle even shows up at my gem list.
update from comments:
The ouput of the which ruby && which gem is:
/home/username/.rvm/rubies/ruby-1.8.7-p371/bin/ruby
/home/username/.rvm/bin/gem
Output of "env | grep -iE 'ruby|rvm|gem' | sort":
GEM_HOME=/home/username/.rvm/gems/ruby-1.8.7-p371#global
GEM_PATH=/home/username/.rvm/gems/ruby-1.8.7-p371#global
IRBRC=/home/username/.rvm/rubies/ruby-1.8.7-p371/.irbrc
MY_RUBY_HOME=/home/username/.rvm/rubies/ruby-1.8.7-p371
PATH=/home/username/.rvm/gems/ruby-1.8.7-p371#global/bin:/home/username/.rvm/rubies/ruby-1.8.7-p371/bin:/home/username/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
RUBY_VERSION=ruby-1.8.7-p371
rvm_bin_path=/home/username/.rvm/bin
rvm_delete_flag=0
rvm_path=/home/username/.rvm
rvm_prefix=/home/username
rvm_ruby_string=ruby-1.8.7-p371
rvm_sticky_flag=1
rvm_use_flag=1
rvm_version=1.17.7 (stable)
Unistalled and installed 1.8.7 via RVM
ran:
rvm install 1.8.7 --verify-downloads 1
and it worked.
It looks like you're probably running the wrong version of gem. In my RVM setup, using the shell command overrides recommended with RVM (source "$HOME/.rvm/scripts/rvm" in your .bashrc or .zshrc or another suitable startup file), gem is normally a shell function. It does some RVM magic under the covers and then runs the real gem command. In my case, both ruby and gem run out of the same version directory:
/home/jim/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
/home/jim/.rvm/rubies/ruby-1.9.3-p327/bin/gem
Make sure you're sourcing the RVM startup script.
Your PATH looks ok. Make sure you have a /home/username/.rvm/rubies/ruby-1.8.7-p371/bin/gem command. If not, you may have to reinstall ruby-1.8.7.
Running rvm current will show which Ruby version and gemset are being used. Make sure there's a gem in the path that matches the Ruby version.
rvm install ruby-1.9.2-p320
use this and remember close all terminal
and in edit-> profile preferences--> title and command -->> check (Run command as login shell)

problem with bundle

I try command bundle install --local
but it show issue:
-bash: /usr/local/bin/bundle: /usr/local/bin/ruby: bad interpreter: No such file or directory.
please help me.
The solution that worked for me was entirely different, perhaps because I've been inconsistent about using RVM or not.
I used 'which bundler' to find out where bundler was being launched, it was from /usr/bin/bundler. Noticing that /usr/bin/bundler began with a location and version of ruby that did not exist on my system any more, I did
gem uninstall bundler
gem install bundler
Checking 'which bundler' again confirmed that bundler was now installed within a .rvm environment instead of /usr/bin/bundler, and now references the correct version of ruby; so bundle install now works for my rails project.
I think you need to export the path of ruby and bundle in your .bashrc (linux).
Open your .bashrc and add this line:
export PATH="$PATH:/usr/bin:/usr/local/bin/"
It should work.
The bundle executable is provided by the bundler gem. If you are using rvm then seeing which bundle in /usr/local/bin/bundle indicates a problem, because use of rvm means gems like bundler are installed under your home directory, usually in ~/.rvm/gems/....
# Symptoms of a broken bundler installation:-
# Cannot start Rails...
$ bin/rails s
/Users/rogermarlow/project/config/boot.rb:9:in 'rescue in <top (required)>': uninitialized constant Bundler (NameError)
# bundle not working...
$ bundle install
zsh: /usr/local/bin/bundle: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin: no such file or directory
# ^----- that path does not look right, rvm does not put gems there
$ which bundle
/usr/local/bin/bundle
# ^--- I want bundle from something under ~/.rvm/gems
# First check rvm is in effect:
$ rvm reload
RVM reloaded!
$ which ruby
/Users/rogermarlow/.rvm/rubies/ruby-2.3.4/bin/ruby
# ^--looks good, it is an rvm path, not /usr/local/bin/...
# Now fix bundler
$ gem uninstall bundler # just in case
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
1 gem installed
$ which bundle
/Users/rogermarlow/.rvm/gems/ruby-2.3.4#project/bin/bundle
$ ^--- that is better, bundle is on a path controlled by rvm
# bundle now working
$ bundle install
Fetching gem metadata from http://rubygems.org/..........
*snip*
# rails now working
$ bin/rails s
=> Booting Thin
=> Rails 4.2.7.1 application starting in development on http://localhost:3000
*snip*
On my side, I am using rbenv.
When I checked the /usr/local/bin/bundle, it shows it is using the older ruby, thus causing the problem.
#!/usr/bin/ruby1.9.1
by changing it to point to proper ruby fix the problem
#!/home/user/.rbenv/shims/ruby
For newly created gem-set gem bundler is missing for me,
Before bundler install path for it, /usr/local/bin/bundler
Installed bundler to resolve issue.
gem install bundler --no-ri --no-rdoc
Bundler path changes to, /home/root/.rvm/gems/ruby-2.2.1#drag-drop-list/bin/bundler
Encountering this same problem,
I found bundler installation in /var/lib/gems/2.3.0/gems/bundler-1.16.1;
Then i fixed the error by creating a symbolic link like this:
ln -s /var/lib/gems/2.3.0/gems/bundler-1.16.1/
/usr/lib/ruby/gems/2.3.0/gems/bundler-1.16.1
I did this because I needed this version of ruby.

Resources