How to fix rubygem not found after successful installation? - ruby

I have installed the rubygems-mirror gem (successfully it would seem), but when I execute the gem I get the following error:
$ gem mirror
ERROR: Install the rubygems-mirror gem for the mirror command
EDIT: The installation was done using a gem install command, and I have setup the ~/.gem/.mirrorrc file as a cut/paste from the gem documentation, save the target directory.
Both doing an listing of ~/.gems/ruby/gems and running gem list show I have rubygems-mirror version 1.1.0 on my system. Here is my gem list:
$ gem list rubygems-mirror
*** LOCAL GEMS ***
rubygems-mirror (1.1.0)
$ ls ~/.gem/ruby/gems/rubygems-mirror-1.1.0
CHANGELOG.rdoc lib Manifest.txt Rakefile README.rdoc test
And here is my gem environment:
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/localadm/.gem/ruby
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /home/localadm/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/localadm/.gem/ruby
- /usr/share/gems
- /usr/local/share/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
I've never had such an issue with a gem before, I'm a little confused at what to do here. To make things even more confusing, I can run gem mirror --help and receive the correct help text for the mirror gem as output.
UPDATE: It seems I am able to use a work-around. I have cloned the git source repo, and seem to be able to execute $ rake mirror:update successfully. I'm sitting at about 2000/819236 gems downloaded, but so far so good.
Still would like to figure out how I can run the mirror simply with $ gem mirror as it should work.

Related

How to change gem environment for RUBY VERSION

I'm pretty new to Ruby and pod installation. Currently I have Ruby installed through RVM. However I'd like to install a pod through bundler by bundle exec pod install.
I keep getting the following error that my current version of Ruby is different from Gemfile specified. My current version of Ruby via RVM is same with Gemfile version. (So if I do pod install it won't cause any issues).
My gem env shows different Ruby Version.
How can I go about changing that? Where does gem env live? I saw some instructions here to install a RubyGem. But I'm having trouble following this. Any advice helps!
➜ ios git:(main) bundle exec pod install
Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5
➜ ios git:(main) gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.3.1
- RUBY VERSION: 2.6.8 (2021-07-07 patchlevel 205) [universal.x86_64-darwin21]
- INSTALLATION DIRECTORY: /Users/myusername/.gem
- USER INSTALLATION DIRECTORY: /Users/myusername/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /Users/myusername/.gem/bin
- SPEC CACHE DIRECTORY: /Users/myusername/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-21
- GEM PATHS:
- /Users/myusername/.gem
- /Users/myusername/.gem/ruby/2.6.0
- /Library/Ruby/Gems/2.6.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/

How to install ruby gem without sudo?

Configuring a new machine (Mac OS Mojave - Version 10.14.2).
After installing ruby with rbenv. I'm trying to install some gem and running :
gem install rake bundler rspec rubocop pry pry-byebug hub colored octoki
But its give me the following error :
ERROR: While executing gem ... (TypeError)
incompatible marshal file format (can't be read)
format version 4.8 required; 60.33 given
Here is my Gem env :
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/elise/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /Users/elise/.rbenv/versions/2.5.3/bin/ruby
- EXECUTABLE DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/bin
- SPEC CACHE DIRECTORY: /Users/elise/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/elise/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
- /Users/elise/.gem/ruby/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
- :benchmark => false
- "gem" => "--no-document"
- REMOTE SOURCES:
- http://gems.rubyforge.org/
- http://gems.github.com
- SHELL PATH:
- /Users/elise/.rbenv/versions/2.5.3/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- ./bin
- ./node_modules/.bin
- /Users/elise/.rbenv/shims
- /Users/elise/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/sbin
Does anyone know where this bug comes from?
Thanks for the help.
You have only enable very old (and not maintained) remote gem sources in your gem configuration. This might be caused by some old migrated configuration or by following some very old and outdated advice.
To fix this, you first need to remove the outdated gem sources and then add the only one which should be currently used. For that, you can run the following command from your Terminal:
gem sources --remove http://gems.github.com/
gem sources --remove http://gems.rubyforge.org/
gem sources --add https://rubygems.org/
You have to remove all the gem sources you have and add https://rubygems.org/ instead. Note that http://gems.rubyforge.org/ and http://gems.github.com are permanently dead and should be removed. You can list your sources by running:
gem sources
You should get something like this:
*** CURRENT SOURCES ***
//gems.rubyforge.org/
//gems.github.com
1) Delete all sources:
gem sources -r http://gems.rubyforge.org/
gem sources -r http://gems.github.com
2) Add the right source:
gem sources -a https://rubygems.org/
Also, never sudo gem install
Hope this helps!

"gem update --system" doesn't find the latest version?

I downloaded Ruby 2.0.0 and have gem version 2.0.14. I need at least gem version 2.0.3 to meet the requirements to run my script. However, when I try to update:
gem update --system
I get a message that says "Latest version currently installed, Aborting." What do I need to do to get this to update properly? As a result of this, I can't install the gems that I need. For example:
gem install watir
returns
ERROR: could not find a valid gem 'watir' ()= 0), here is why: Unable to download data from https://rubygems.org/ - no such name (https://rubygems.org/latest_specs.4.8.gz).
Could this be a proxy issue, or is it something entirely different?
EDIT gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0 (2014-05-08 patchlevel 481) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Users/shwheelz/Documents/Ruby200/lib/ruby/gems/2.
0.0
- RUBY EXECUTABLE: C:/Users/shwheelz/Documents/Ruby200/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Users/shwheelz/Documents/Ruby200/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Users/shwheelz/Documents/Ruby200/lib/ruby/gems/2.0.0
- C:/Users/shwheelz/.gem/ruby/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
Try to run
gem install rubygems-update
update_rubygems
I have encountered the same problem. Because I was gem source deleted.
Type
gem sources -l
See if there is one gem source, if not, run following
gem sources --add https://rubygems.org/
To remove a source
gem sources --remove https://rubygems.org/
then try again.

gem command silently does nothing

I need to use Twitter's twurl command. In so doing I have installed Ruby and then Gem under Linux.
I've downloaded the latest version of twurl but when I attempt to use it to do an install it silently does nothing. I've also tried installing the oauth gem, but the same result. Gem must work because I can do a build using the gemspec file and it creates a gem file.
cam:~/twurl-master$ sudo gem build twurl.gemspec
sh: git: command not found
/usr/local/lib/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:55: command not found: git ls-files
sh: git: command not found
WARNING: description and summary are identical
WARNING: See http://guides.rubygems.org/specification-reference/ for help
Successfully built RubyGem
Name: twurl
Version: 0.9.2
File: twurl-0.9.2.gem
cam:~/twurl-master$ ls
COPYING Gemfile INSTALL README Rakefile bin lib test twurl-0.9.2.gem twurl.gemspec
cam:~/twurl-master$ sudo gem install twurl
cam:~/twurl-master$ sudo gem install twurl --remote
cam:~/twurl-master$ sudo gem list t
*** LOCAL GEMS ***
cam:~/twurl-master$ sudo gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /home/cam/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/cam/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/X11R6/bin
cam:~/twurl-master$
I am at a loss as to know what to do. I've searched on Google but nobody else seems to have this particular problem. No error message is highly unhelpful...
I'm not sure what is the issue and if that's related, but just in case, twurl gem also requires the gem oauth-0.4.7.

Ruby gem installation issue

I'm trying to install gems on my ruby installation... I've installed a few, like heroku, yet when i list my local gems, the only one i see is Rake, and of course heroku cannot be used...
Any idea how i can solve this? What could the issue be? Installation for Heroku gem sewems to go smooth using sudo gem install heroku...
here is my gem environment:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.6
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [i686-linux]
- INSTALLATION DIRECTORY: /home/alex/.rvm/gems/ruby-1.9.2-p290
- RUBY EXECUTABLE: /home/alex/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
- EXECUTABLE DIRECTORY: /home/alex/.rvm/gems/ruby-1.9.2-p290/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/alex/.rvm/gems/ruby-1.9.2-p290
- /home/alex/.rvm/gems/ruby-1.9.2-p290#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Thx!
I see that you use rvm to maintain your gems. Please do not use sudo to install the gems in that case.
RVM doesn't recognize gems installed with sudo and seems to be buggy even when you aren't using the sudo installed gems.
The ultimate solution that worked for me to uninstall all the gems locally and with sudo. Here is what to do:
$sudo gem list and $gem list to grab the gems you want. Save those as a .gems file using a text editor. The .gems file is just a listing of the gems, one per line, with the version number after (e.g. nokogiri -v1.4.3.1)
uninstall all of the gems. You can do this in bulk by just listing the gems with a space separated between them. $sudo gem uninstall gem1 gem2 gem3
use the directions at https://rvm.beginrescueend.com/gemsets/importing/ to import the newly made .gems list.

Resources