Unknown Host Error while updating Ruby-Gems - ruby-on-rails

I am trying to update ruby gems by using:
gem update --system
But I am getting error:
ERROR: While executing gem ...(Gem::RemoteFetcher::UnknownHostError)
no such name (https://rubygems.org/specs.4.8.gz).

Unsure what version of rubygems you have installed, however there are three ways to fix:
network issues - try again later.
the version you have is bricked for updates, and you will need to install another way
NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no rubygems-update installed. You will need to use the following instructions if you see Nothing to update. If you have an older version of RubyGems installed, then you can still do it in two steps:
$ gem install rubygems-update # might need to be admin/root
$ update_rubygems
Failing that you have to get your hands dirty:
Download from https://rubygems.org/pages/download
Unpack into a directory and cd there
Install with: ruby setup.rb (you may need admin/root privilege)
See https://rubygems.org/pages/download for more info

Related

rbenv: version `2.0.0' is not installed

I'm trying to install the Gemfile contents using Bundle install but getting the error
rbenv: version `2.0.0' is not installed
The version of ruby installed in my system is:
ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]
and rbenv
2.1.2 (set by /home/jay/.rbenv/version)
2.1.3
The Gemfile requires ruby "2.0.0". Can any one tell how to install the required version without affecting the existing ones.
You can find a lot of information here: rbenv on github
To list all available installation candidates:
rbenv install -l
To install a ruby version you need (for example):
rbenv install 2.0.0-p643
So that you will only use this ruby version in this specific folder and not affect anything else you can do:
rbenv local 2.0.0-p643
This will generate a .ruby-version file in that directory which will force rbenv to use this ruby version here.
Just run:
rbenv install 2.0.0-p643
Which is the lastest 2.0.0 version.
If that version is not available on your system, run ruby-build --definitions to pick the lastest known 2.0.0 version on your system.
For me, I just ran
gem install bundler
and then run
bundle install
worked like a charm
You must change the ruby's version in .ruby-version file and in Gemfile
If you are getting a build failed error when trying to run rbenv install 2.0.0-p643 and after waiting for a few minutes; you might also see the last 10 lines of a log file as an output.
This can give you the hint of what would have happened for the build failure. It might miss some required library/dependency needed to be installed.
For ex. I got the following error for build failure-
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libreadline-dev` to fetch missing dependencies.

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'.

gem install error, index not found, ruby on rails

Problem: Cannot install any gem, any type. But I want to install riddle if that matters.
When I run sudo gem install "gem_name" I get the following error:
WARNING: RubyGems 1.2+ index not found for:
RubyGems will revert to legacy indexes degrading performance.
Bulk updating Gem source index for: http://gems.rubyforge.org/
What to do??
Check your sources
gem sources
rebuild index for affected sources, e.g.
gem generate_index http://gems.rubyforge.org
1) Here is the answer!!!!
- slow connection
2) Solution
- move to a new connection.
-
This might not affect people in the 1st world, but I live in China and this was a huge problem as few people seem to have experienced this.
Basically the error means that the connection is to slow and gives up saying no index found. But there is not documentation or help out there on this, except for a few posts about changing gem sources, and MERB causing problems, but all that failed for me.
I was having the same problem and ran the following:
gem env
And saw that I had the following sources in my rubygems configuration:
http://gems.rubyforge.org
http://gems.rubyonrails.org
http://gems.github.com
Based on other answers I've seen here and on the web I decided to remove the rubyonrails.org reference:
sudo gem sources -r http://gems.rubyonrails.org
I was then able to install the gem I was trying to get without the RubyGems 1.2+ index error.
So I'd suggest trimming your list of sources down to just rubyforge and github and then trying to install the gem you want.
I solved this problem by
rm -rf ~/.gem
And then run "gem install" again
Try to add the another gem source. For example github:
sudo gem sources -r http://gems.rubyforge.org
sudo gem sources -a http://gems.github.com
You are running an old RubyGems version.
Upgrade to the latest RubyGems 1.3.x branch.
$ rubygems update --self
If it doesn't work (RubyGems 1.2.0 has a weird bug that prevents --self update) then install rubygems_update
$ wget http://rubyforge.org/frs/download.php/60717/rubygems-update-1.3.5.gem
$ gem install rubygems-update-1.3.5.gem
$ update_rubygems
Use sudo if your os requires it.
Could be a daft entry in /etc/hosts...

Ubuntu: "Could not find rails locally or in a repository"

I'm following these instructions to set up Ruby on Rails on my Ubuntu machine. For now at least, I'm planning to use Mongrel.
When I get to this step:
sudo gem install rails
...I get this message:
Bulk updating Gem source index for: http://gems.rubyforge.org/
ERROR: could not find rails locally or in a repository
What should I do next?
I would try to update gems first. The latest version is 1.3.3. You can do this on Ubuntu by either:
sudo gem install rubygems-update
sudo update_rubygems
or
sudo gem install rubygems-update
cd /var/lib/gems/1.8/gems/rubygems-update-*
sudo ruby setup.rb
basically, try again!
It could be a serious error, but in earlier versions ( I encountered this about 1 year ago or so ) it happend on the first try and when trying again the gem would eventually be found. I think it had something to do with the servers performance or such.
Using a recent version of rubygems is probably a good idea, and if it really won't work you can always get the .gem file from sourceforge directly and install from it.
For example with the file rails-2.3.2.gem:
gem install rails-2.3.2 –local
gem install rails --source http://gems.rubyonrails.org

Errors when trying to update ruby gems from 2.0.1

I am trying to set myself up on a mac to learn Ruby on Rails, however I seem to be having some problems. If I try to run commands such as ./script/server, i get this:
Rails requires RubyGems >= 0.9.4 (you have 0.9.2). Please gem update --system and try again.
When I run "gem update.." I get this:
Updating RubyGems...
Attempting remote update of rubygems-update
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /opt/local/lib/ruby/gems/1.8/cache/rubygems-update-1.3.0.gem
got it.
sudo gem update --system
Starting with El Capitan, Apple prevents user applications to modify /usr/bin for security reasons. So better install/update rubygems in the recommended folder, /usr/local/bin:
sudo gem update -n /usr/local/bin --system
(recommendation taken from https://stackoverflow.com/a/39928447/1033581)

Resources