How to Set Correct Ruby Version in Gem Environment

How to set correct Ruby version in gem environment

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/

RubyGems How to change gem environment settings?

Actually I searched online and found the solution.

Just put the following in your .profile (Max OS) or .bashrc (Linux)

export GEM_PATH=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
export GEM_SPEC_CACHE=/Users/myusername/Tools/.rbenv/versions/2.1.0/lib/ruby/gems/specs

Make sure the folder you put there existed. Then source the .profile or .bashrc, or simply restart your terminal. It is tested working now my env is correct.

Reference:
https://github.com/rubygems/rubygems/pull/489

Change gem env RUBY EXECUTABLE path for one command

After hours and hours of research, stepping through the Ruby source with Pry, reading source code and more I figured out that this is not possible to do because it is hard-coded into ruby at compile time (wtf?). Anyway, the way to solve this is to simply recompile Ruby. Yeah.

There is also apparently a compile flag which you can set which removes this hard-coded environment: --enable-load-relative

After struggling with this for way to long I finally got this project working, where I have made an easy to use portable version of Ruby. Simply put, a folder with Ruby on it which you can move about, put on a USB stick or whatever, and it still works :)

How to change the path where ruby gems are installed on OS 10.6.6 Ruby 1.8 and Rails 3

I would suggest using RVM (Ruby Version Manager) to control which version of Ruby you are installing your gems into. It will also help keep all the bundle and gem data in a folder in your home directory.

Gem Environment Not Set Correctly

Run the command

gem install rails

again. It will download and install missing dependencies, including railties.

Ruby: How to install a specific version of a ruby gem?

Use the -v flag:

$ gem install fog -v 1.8


Related Topics



Leave a reply



Submit