'gem install [name of gem] --pre' is not updating my system gems - ruby-on-rails

I am a newbie when it comes to working with gems so pardon me if i'm getting my facts wrong.
I want to update Bundler from v1.3.5 to the latest version (v1.5.3) so I tried doing:
sudo gem install bundler --pre
the command line outputs:
Fetching: bundler-1.5.3.gem (100%)Fetching: bundler-1.5.3.gem
Successfully installed bundler-1.5.3
Parsing documentation for bundler-1.5.3
Installing ri documentation for bundler-1.5.3
Done installing documentation for bundler after 4 seconds
1 gem installed
but when I do gem list or bundle --version, it shows that i'm still using the old version (v1.3.5). This goes to all my other gems. I tried updating Susy, Sass and Compass the same way, but it doesn't get updated even though it says that it was installed successfully.
Any ideas? TIA

Fixed it. It seems that if you add sudo when installing gems, it installs the gem on a different directory from the one used when you don't use sudo. I saw this when I did sudo gem list and it displayed different results from a normal gem list command.
To be able to add gems without sudo I just did chown -R [current_user] [ruby_directory]

Run bundle update on the command line. This will update your gems in your app.

Related

fail ruby bundle install

adan#adan-HP-1000-Notebook-PC:~/wpscan$ sudo gem install bundler && bundle install --without test
Fetching: bundler-1.15.1.gem (100%)
Successfully installed bundler-1.15.1
Parsing documentation for bundler-1.15.1
Installing ri documentation for bundler-1.15.1
Done installing documentation for bundler after 10 seconds
1 gem installed
There was an error while trying to write to /home/adan/wpscan/.bundle/config.
It is likely that you need to grant write permissions for that path.
i don't know why, this problem always follow me
First of all: never install gems with sudo. To fix this for the future try uninstalling all gems / ruby, install rvm or rbenv them create a gemset for specific project and then install gems with bundle install. This error will most likely follow You a while if You don't repair it.
sudo gem install bundler && sudo bundle install
This probably would help, just for now.

How to move or uninstall gems from default System Ruby folder to RVM?

I have so many issues trying to update from Rails 3.2 to Rails 4.1 following the guide that I decided to uninstall Ruby, Rails and RVM (with all its gems) and start over.
RVM and Ruby Gone. $ rvm remove
But still have a bunch of GEMS that I previously installed.
$gem list
As suggested on this answer, to remove all gems do:
$for i in `gem list --no-versions`; do gem uninstall -aIx $i; done
But I bump again on the error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
This is so frustrating! Using sudo does not make the fix either.
Even if I try to uninstall one by one, the system wont let me:
$rails uninstall
Could not find gem 'pg (~> 0.17.1) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
Why do I need another Gem to uninstall a Gem?!
Try
for i in `gem list --no-versions`; do sudo gem uninstall -aIx $i; done
This SO question has some ideas: getting rid of ruby gems that won't die
The answer to this SO question has step by step instructions to set it up properly: Removing Gems errors

Why won't bundler install JSON gem?

I get the following error when attempting to run cap production deploy.
DEBUG [dc362284] Bundler::GemNotFound: Could not find json-1.8.1.gem for installation
DEBUG [dc362284] An error occurred while installing json (1.8.1), and Bundler cannot continue.
DEBUG [dc362284] Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
It may be important to note that this deployment was working, than I upgraded to Ruby 2.1.0 to remove an encoding error. I upgraded locally which worked fine. I ran rvm install 2.1.0 and rvm use 2.1.0 then changed my .ruby-version file to reflect this Ruby upgrade.
The bundle install command works locally, but produces the same above error when I ssh onto the destination server and run this command.
If I run gem list I can see this in the list of gems.
...
jquery-rails (3.0.4)
json (1.8.1)
less (2.3.2)
...
If I try the recommended solution gem install json -v '1.8.1' Locally and on the destination server I get the following output:
Building native extensions. This could take a while...
Successfully installed json-1.8.1
Parsing documentation for json-1.8.1
Done installing documentation for json after 0 seconds
1 gem installed
So it appears the gem is installed, right? Why is this happening? How can I solve this? Any help would be greatly appreciated.
$ bundle update json
$ bundle install
So after a half day on this and almost immediately after posting my question I found the answer. Bundler 1.5.0 has a bug where it doesn't recognize default gems as referenced here
The solution was to update to bundler 1.5.1 using gem install bundler -v '= 1.5.1'
Run this command then everything will be ok
sudo apt-get install libgmp-dev
if you are in MacOS Sierra and your ruby version is 2.4.0.The ruby version is not compatible with json 1.8.3.
You can try add this line in your Gemfile:
gem 'json', github: 'flori/json', branch: 'v1.8'
This works for me!
To solve this problem, simply run:
bundle update
It will update the version of your bundler. Then run:
bundle install
Your problem will get solve. Solution is well explained here.
I found the solution here. There is a problem with json version 1.8.1 and ruby 2.2.3, so install json 1.8.3 version.
gem install json -v1.8.3
You should try
$ sudo gem install json -v '1.8.2'
in my case (Ubuntu 14.04) that didn't work directly and I had to do this:
$ sudo apt-get install ruby-dev
and then I could install the gem and continue. Had one more problem that was fixed by:
$ sudo apt-get install libsqlite3-dev
Hoping helps.
If the recommended answer didn't help because you are already using a newer version of bundler. Try the solution that worked for me.
Delete everything inside your vendor folder.
Add a line to your gemfile
gem 'json', '1.8.0'
Then run - bundle update json.
It seems to be an issue with 1.8.1 so going back to 1.8.0 did the trick for me.
I ran into this error while trying to get a project to run on my local dev box (OSX 10.6), using Sinatra and Postgresql (through activerecord), running on an rvm'd ruby 2.1. I found my answer here: https://github.com/wayneeseguin/rvm/issues/2511
My exact problem (after the first block of log entries):
I also get an error when trying to build native extensions for gems
The answer:
rvm reinstall 2.1.0 --disable-binary
The explanation:
OSX does not have a package manager so all libraries have to be installed manually by user, this makes it virtually impossible to link the binary dynamically, and as you can see there are problems with the (pseudo)statically linked binary.
For the sake of completeness, I had first forgotten to update rvm (rvm get head), which yielded some other errors, but still needed the --disable-binary flag once I had done so.
bundle update json. Helped to get through.
When I tried to install the json gem using gem install json separate from just using bundle install I got ERROR: Failed to build gem native extension., looking that up I found using
apt-get install ruby-dev
did the trick
For OS X make sure you have coreutils
$ brew install coreutils
$ bundle
This appears to be a bug in Bundler not recognizing the default gems installed along with ruby 2.x. I still experienced the problem even with the latest version of bundler (1.5.3).
One solution is to simply delete json-1.8.1.gemspec from the default gemspec directory.
rm ~/.rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/specifications/default/json-1.8.1.gemspec
After doing this, bundler should have no problem locating the gem. Note that I am using chruby. If you're using some other ruby manager, you'll have to update your path accordingly.
I was missing C headers solution was to download it for Xcode, this is the best way.
xcode-select --install
Hope it helps.
Bundle was failing to install json -v '1.8.1' and deleting my Gemfile.lock and running bundle again solved this issue for me.
I installed the latest version of json:
gem install json
Then deleted the line json(1.8.1) from the Gemfile.lock and did a
bundle install
And then the Gemfile.lock file uses json(1.8.3) without erros
Switch ruby version from 1.9 to 2.2 with rvm did the job for me
For me, some of the answers mentioned earlier were helpful from understanding point of view, but those didn't solve my problem.
So this is what I did to solve issue.
Modified gemfile.lock to update json (2.0.2) (Earlier, it was 1.8.3)
Check the Bundler version installed (Bundler -v command). I had version 1.12.5 installed
Install bundler version 1.11.2 (using gem install bundler -v '1.11.2')
Then run bundle install
For macOS Sierra:
I ran into this error When i used bundler(v1.15.3) in Rails(v4.2) project.
The solution for me is gem uninstall bundler -v '1.15.3' and gem install bundler -v '1.14.6'.

Bundler using old version

I am using Bundler for my Rails application. When I list installed bundler gems it lists 1.4.0.pre.1 and 1.3.15 and running bundler -v yields 1.4.0.pre.1 (which is what i want).
However, when I try to run my application it says current bundler version is 1.0.15. This version is not installed as a gem and I cannot figure out how to remove it (gem uninstall bundler -v 1.0.15 wont work since this version is not installed as a gem).
I have tried updating and installing new versions, but nothing is working. Please help, I've been stuck for hours. Thank you.
Try running:
$ which -a bundle
This will tell you the location of all the instances of bundler found on your computer.
From there, you should be able to locate the offending version of bundler and uninstall it.
This worked for me when using vagrant
[vagrant#precise32:/vagrant (master)]$ sudo gem install bundler
Fetching: bundler-1.11.2.gem (100%)
Successfully installed bundler-1.11.2
1 gem installed
try running this on you app console:
bundle update

I'm having trouble running my Rails web server

I have installed ruby193 and I've installed rails via the command prompt (I also installed a DevKit). However, whenever I try the command:
rails server
I get this error:
←[31mCould not find gem 'jquery-rails (>= 0) x86-mingw32' in the gems available
on this machine.←[0m
←[33mRun `bundle install` to install missing gems.←[0m
I've tried a bundle install and it gives me an error with when trying to install the json gem. Any suggestions?
make sure in your Gemfile you are including the right gem (no misspellings, etc)
Looks like you are on Windows.
I defeated the very same problem on Windows by manually installing my gems from Gemfile (gem install gem_to_install). After successfully installing a particular gem I ran bundle check to see what else I need to install. And this way after few installed gems I ran bundle check again and saw the output The Gemfile's dependencies are satisfied.
And then server started. I wish you the same!
P.S. You can install few gems at once: gem install gem1 gem2.

Resources