How to set RUBY EXECUTABLE in .gemrc - ruby

My ~.gemrc looks like:
gem: --user-install --no-ri --no-rdoc
gemhome: /home/me/.gems
gempath:
- /home/me/.gems
and gem env returns:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23.2
- RUBY VERSION: 1.9.3 (2014-05-14 patchlevel 547) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/me/.gems
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /home/me/.gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/me/.gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--user-install --no-ri --no-rdoc"
- "gemhome" => "/home/me/.gems"
- "gempath" => ["/home/me/.gems"]
- REMOTE SOURCES:
- http://rubygems.org/
My $PATH is
/home/me/ruby:/home/me/ruby/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
and which ruby returns /home/slackbot/ruby/ruby.
Moreover when I install any gem like gem install bundler it goes to
.gem/ruby/1.9.1/bin/bundle
regardless my 1.9.3 version.
What am I doing wrong to set it up?

Related

gem list -r finds nothing

gem list -r ra
=> * REMOTE GEMS *
but no gems appear
gem list
=> (my installed gems)
ruby -v
=> ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
gem -v
=> 2.7.3
gem environment
RubyGems Environment:
RUBYGEMS VERSION: 2.7.3
RUBY VERSION: 2.5.0 (2017-12-25 patchlevel 0) [x86_64-linux]
INSTALLATION DIRECTORY: /home/xxx/.gem/ruby/2.5.0
USER INSTALLATION DIRECTORY: /home/xxx/.gem/ruby/2.5.0
RUBY EXECUTABLE: /usr/local/rubies/2.5.0/bin/ruby
EXECUTABLE DIRECTORY: /home/xxx/.gem/ruby/2.5.0/bin
SPEC CACHE DIRECTORY: /home/xxx/.gem/specs
SYSTEM CONFIGURATION DIRECTORY: /usr/local/rubies/2.5.0/etc
RUBYGEMS PLATFORMS:
ruby
x86_64-linux
GEM PATHS:
/home/xxx/.gem/ruby/2.5.0
/usr/local/rubies/2.5.0/lib/ruby/gems/2.5.0
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:backtrace => false
:bulk_threshold => 1000
"gem" => "--no-document"
REMOTE SOURCES:
https://rubygems.org/
SHELL PATH:
/home/xxx/.gem/ruby/2.5.0/bin
/usr/local/rubies/2.5.0/lib/ruby/gems/2.5.0/bin
/usr/local/rubies/2.5.0/bin
/home/xxx/.nvm/versions/node/v8.8.1/bin
/usr/local/heroku/bin
/home/xxx/commands
/home/xxx/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
I haven't changed anything (that I'm aware of) in my ruby since when it did work. Any suggestions on where to look?
well looks like you have no sources. see in gem env "gem" => "--no-document"
try running this:
gem sources -a https://rubygems.org/
my env differs by:
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["https://rubygems.org/"]
- "benchmark" => false
- "gem" => "--no-rdoc --no-ri"
can you paste output of ~/.gemrc to make sure? Mine looks like:
---
:backtrace: false
:bulk_threshold: 1000
:sources:
- https://rubygems.org/
:update_sources: true
:verbose: true
benchmark: false
gem: "--no-rdoc --no-ri"
If this doesn't work, perhaps try installing ruby using rvm https://rvm.io/rvm/install

How to set correct Ruby version in gem environment

Note: This question relates to How can I get bundler to use the Ruby version set by chruby and .ruby-version?.
Using chruby I have Ruby 1.8.7 installed on macOS:
$ ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]
Also, I have used gem update --system 1.8.30 to install a specific version of RubyGems which I am hoping is compatible. This would appear to be installed properly:
$ gem --version
1.8.30
However, my RubyGems environment shows the incorrect version of Ruby (2.5.0):
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.30
- RUBY VERSION: 2.5.0 (2017-12-25 patchlevel 0) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/keithpitty/.gem/ruby/1.8.7
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
How can I fix the RubyGems environment to use the version of Ruby that chruby has set?
My missing step was installing RubyGems 1.6.2 from source. Following advice elsewhere from Dan Cheail, I did the following:
curl -O https://rubygems.org/rubygems/rubygems-1.6.2.tgz
(and then unzipped it)
cd rubygems-1.6.2
chruby ruby-1.8.7-p374
ruby setup.rb
gem update --system 1.8.25
And then my RubyGems environment was fixed:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.4.0]
- INSTALLATION DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7
- RUBY EXECUTABLE: /Users/keithpitty/.rubies/ruby-1.8.7-p374/bin/ruby
- EXECUTABLE DIRECTORY: /Users/keithpitty/.gem/ruby/1.8.7/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-17
- GEM PATHS:
- /Users/keithpitty/.gem/ruby/1.8.7
- /Users/keithpitty/.rubies/ruby-1.8.7-p374/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/

how i can correct this error in ruby installed ruby is 1.9.3 and it shows the path of installed ruby 2.0.0

what is that probem and how can i solve it
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-05-15 patchlevel 429) [x86_64-linux]
- INSTALLATION DIRECTORY: /home8/novapext/.rvm/gems/ruby-2.0.0-p648
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /home8/novapext/.rvm/gems/ruby-2.0.0-p648/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home8/novapext/.rvm/gems/ruby-2.0.0-p648
- /home8/novapext/.rvm/gems/ruby-2.0.0-p648:/home8/novapext/.rvm/gems /ruby-2.0.0-p648#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--remote --gen-rdoc --run-tests"
- "gemhome" => "/home8/novapext/.rvm/gems/ruby-2.0.0-p648"
- "gempath" => "/home8/novapext/.rvm/gems/ruby-2.0.0-p648:/home8/novapext/.rvm/gems/ruby-2.0.0-p648#global"
- "rdoc" => "--inline-source --line-numbers"
- REMOTE SOURCES:
- http://rubygems.org/
this is therubygem environment how i can correct this it showing the ruby version 1.9.3 and installation directory is /home8/novapext/.rvm/gems/ruby-2.0.0-p648 this is my error
You could switch your rvm environment to ruby 1.9.3
rvm install 1.9.3
rvm use 1.9.3

Two ruby versions, need tidying up

I seem to have multiple ruby / rubygem installations on my server.
The gem environment for each is:
root#weepingangel:~# gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /usr/local/rbenv/versions/2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rbenv/versions/2.1.0/bin
- SPEC CACHE DIRECTORY: /root/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- /root/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org", "http://gems.github.com"]
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://gems.rubyforge.org
- http://gems.github.com
- SHELL PATH:
- /usr/local/rbenv/versions/2.1.0/bin
- /usr/local/rbenv/libexec
- /usr/local/rbenv/shims
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
root#weepingangel:~# sudo gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org", "http://gems.github.com"]
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://gems.rubyforge.org
- http://gems.github.com
Does anyone know how I can clear these up as I only need one and I think I have things looking at my $PATH but it's pointing to the wrong one.
If you use rbenv you can run this in your profile to set the default ruby environment.
$rbenv global 2.2.0
Hope this helps.

rvm + jruby / gem install bundler - Errno::ECONNREFUSED: Connection refused

Trying to install some gems under jruby 1.6, but getting connection refused:
$ gem install bundler
ERROR: Could not find a valid gem 'bundler' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ECONNREFUSED: Connection refused - Connection refused (http://rubygems.org/latest_specs.4.8.gz)
DOH - looks like an old proxy setting for squid in my .gemrc was finally being picked up and then failing as squid was not running :(
Works fine if I switch back to jruby 1.5.6 or ruby 1.8...
$ rvm use jruby
Using /Users/kimptoc/.rvm/gems/jruby-1.6.0
$ gem list
*** LOCAL GEMS ***
rake (0.8.7)
sources (0.0.1)
Any clues would be appreciated.
$ rvm info
ruby-1.9.2-p136:
system:
uname: "Darwin Chris-Kimptons-MacBook-Air.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
rvm:
version: "rvm 1.5.2 by Wayne E. Seguin (wayneeseguin#gmail.com) [http://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.9.2p136"
date: "2010-12-25"
platform: "x86_64-darwin10.5.0"
patchlevel: "2010-12-25 revision 30365"
full_version: "ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.5.0]"
homes:
gem: "/Users/kimptoc/.rvm/gems/ruby-1.9.2-p136"
ruby: "/Users/kimptoc/.rvm/rubies/ruby-1.9.2-p136"
binaries:
ruby: "/Users/kimptoc/.rvm/rubies/ruby-1.9.2-p136/bin/ruby"
irb: "/Users/kimptoc/.rvm/rubies/ruby-1.9.2-p136/bin/irb"
gem: "/Users/kimptoc/.rvm/rubies/ruby-1.9.2-p136/bin/gem"
rake: "/Users/kimptoc/.rvm/gems/ruby-1.9.2-p136/bin/rake"
environment:
PATH: "/Users/kimptoc/.rvm/gems/ruby-1.9.2-p136/bin:/Users/kimptoc/.rvm/gems/ruby-1.9.2-p136#global/bin:/Users/kimptoc/.rvm/rubies/ruby-1.9.2-p136/bin:/Users/kimptoc/.rvm/bin:/Users/kimptoc/Documents/java/libs/torquebox-current/jruby/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/kimptoc/bin:/usr/local/mysql/bin"
GEM_HOME: "/Users/kimptoc/.rvm/gems/ruby-1.9.2-p136"
GEM_PATH: "/Users/kimptoc/.rvm/gems/ruby-1.9.2-p136:/Users/kimptoc/.rvm/gems/ruby-1.9.2-p136#global"
MY_RUBY_HOME: "/Users/kimptoc/.rvm/rubies/ruby-1.9.2-p136"
IRBRC: "/Users/kimptoc/.rvm/rubies/ruby-1.9.2-p136/.irbrc"
RUBYOPT: ""
gemset: ""
Also logged as bug on jruby site - http://jira.codehaus.org/browse/JRUBY-5683
Chris-Kimptons-MacBook-Air:temp kimptoc$ rvm ruby 'gem env && echo'
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-12-03 patchlevel 249) [java]
- INSTALLATION DIRECTORY: /Users/kimptoc/.rvm/gems/jruby-1.5.6
- RUBY EXECUTABLE: /Users/kimptoc/.rvm/rubies/jruby-1.5.6/bin/jruby
- EXECUTABLE DIRECTORY: /Users/kimptoc/.rvm/gems/jruby-1.5.6/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-java-1.6
- GEM PATHS:
- /Users/kimptoc/.rvm/gems/jruby-1.5.6
- /Users/kimptoc/.rvm/gems/jruby-1.5.6#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-rdoc --no-ri"
- "update" => "--no-rdoc --no-ri"
- "gem" => "--http-proxy http://localhost:3128"
- "bundle" => "--http-proxy http://localhost:3128"
- "bundler" => "--http-proxy http://localhost:3128"
- REMOTE SOURCES:
- http://rubygems.org/
RubyGems Environment:
- RUBYGEMS VERSION: 1.5.1
- RUBY VERSION: 1.8.7 (2011-03-15 patchlevel 330) [java]
- INSTALLATION DIRECTORY: /Users/kimptoc/.rvm/gems/jruby-1.6.0
- RUBY EXECUTABLE: /Users/kimptoc/.rvm/rubies/jruby-1.6.0/bin/jruby
- EXECUTABLE DIRECTORY: /Users/kimptoc/.rvm/gems/jruby-1.6.0/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-java-1.6
- GEM PATHS:
- /Users/kimptoc/.rvm/gems/jruby-1.6.0
- /Users/kimptoc/.rvm/gems/jruby-1.6.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-rdoc --no-ri --env-shebang"
- "update" => "--no-rdoc --no-ri --env-shebang"
- "gem" => "--http-proxy http://localhost:3128"
- "bundle" => "--http-proxy http://localhost:3128"
- "bundler" => "--http-proxy http://localhost:3128"
- REMOTE SOURCES:
- http://rubygems.org/
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10.4.3]
- INSTALLATION DIRECTORY: /Users/kimptoc/.rvm/gems/ruby-1.8.7-p302
- RUBY EXECUTABLE: /Users/kimptoc/.rvm/rubies/ruby-1.8.7-p302/bin/ruby
- EXECUTABLE DIRECTORY: /Users/kimptoc/.rvm/gems/ruby-1.8.7-p302/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /Users/kimptoc/.rvm/gems/ruby-1.8.7-p302
- /Users/kimptoc/.rvm/gems/ruby-1.8.7-p302#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "bundle" => "--http-proxy http://localhost:3128"
- "gem" => "--http-proxy http://localhost:3128"
- "bundler" => "--http-proxy http://localhost:3128"
- REMOTE SOURCES:
- http://rubygems.org/
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10.5.0]
- INSTALLATION DIRECTORY: /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330
- RUBY EXECUTABLE: /Users/kimptoc/.rvm/rubies/ruby-1.8.7-p330/bin/ruby
- EXECUTABLE DIRECTORY: /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330
- /Users/kimptoc/.rvm/gems/ruby-1.8.7-p330#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "bundle" => "--http-proxy http://localhost:3128"
- "gem" => "--http-proxy http://localhost:3128"
- "bundler" => "--http-proxy http://localhost:3128"
- REMOTE SOURCES:
- http://rubygems.org/
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-12-25 patchlevel 136) [x86_64-darwin10.5.0]
- INSTALLATION DIRECTORY: /Users/kimptoc/.rvm/gems/ruby-1.9.2-p136
- RUBY EXECUTABLE: /Users/kimptoc/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
- EXECUTABLE DIRECTORY: /Users/kimptoc/.rvm/gems/ruby-1.9.2-p136/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/kimptoc/.rvm/gems/ruby-1.9.2-p136
- /Users/kimptoc/.rvm/gems/ruby-1.9.2-p136#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--http-proxy http://localhost:3128"
- "bundle" => "--http-proxy http://localhost:3128"
- "bundler" => "--http-proxy http://localhost:3128"
- REMOTE SOURCES:
- http://rubygems.org/
Chris-Kimptons-MacBook-Air:temp kimptoc$ gem update --system
Updating RubyGems
ERROR: While executing gem ... (NoMethodError)
undefined method `version' for nil:NilClass
Chris-Kimptons-MacBook-Air:temp kimptoc$ rvm install jruby
jruby-1.6.0 - #fetching
jruby-1.6.0 - #extracted to /Users/kimptoc/.rvm/src/jruby-1.6.0 (already extracted)
Building Nailgun
jruby-1.6.0 - #installing to /Users/kimptoc/.rvm/rubies/jruby-1.6.0
ERROR: Cannot switch to 1.6.2 for this interpreter.
jruby-1.6.0 - #importing default gemsets (/Users/kimptoc/.rvm/gemsets/)
Copying across included gems
ERROR: Could not find a valid gem 'jruby-launcher' (>= 0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ECONNREFUSED: Connection refused - Connection refused (http://rubygems.org/latest_specs.4.8.gz)
This doesn't sound like a RVM problem. RVM manages which Ruby is running, but it shouldn't touch the repository information for a gem install.
Type rvm ruby 'gem env && echo'. Each gem instance for each of your install Rubies will output their environmental information. You can compare them to see if the "REMOTE SOURCES" are different. The remote sources are where gems find their files. If the one that can't find a gem is different then you'll have found your problem.
You might need to update the gem versions. You can use gem update --system to do that, and rvm ruby 'gem update --system' to do all of them. Following that you'll probably want to do rvm ruby 'gem clean rubygems-update' to clean up any old versions of gem.
rvm old commands have been deprecated instead use these commands:
rvm ruby 'gem env && echo'
rvm all do ruby gem clean rubygems-update

Resources