Fix ruby gems path issues in debian

I’ve be banging my head against the wall trying to fix a ruby gems path without success. Here is my problem. In my production server running Debian GNU/Linux 6.0.6 (squeeze) I have both ruby1.8.7, ruby1.9.1 and jruby installed. For some reasons gem install uses jruby gems directory and not ruby gems directory which means I can not run ruby programs that depends on installed ruby gems. I’ve tried to export the ruby gem PATH using

export PATH=/var/lib/gems/1.8/bin:$PATH

but nothing changed.

  • gem install anything returns (Errno::EPERM) on debian jessie (8.3)
  • debian dependencies for gem gosu
  • jekyll build on debian 8, gem not found
  • What's the deal with rubygems on Debian? It's different and strange
  • Error installing mysql2 gem on Debian Squeeze
  • Permission errors installing gems on linux
  • Here is my .bashrc file

    # ~/.bashrc: executed by bash(1) for non-login shells.
    export PS1='\h:\w\$ '
    umask 022
    # You may uncomment the following lines if you want `ls' to be colorized:
    # export LS_OPTIONS='--color=auto'
    # eval "`dircolors`"
    # alias ls='ls $LS_OPTIONS'
    # alias ll='ls $LS_OPTIONS -l'
    # alias l='ls $LS_OPTIONS -lA'
    # Some more alias to avoid making mistakes:
    # alias rm='rm -i'
    # alias cp='cp -i'
    # alias mv='mv -i'
    export PATH
    export GEM_PATH=/usr/lib/ruby/gems/1.8


    No LSB modules are available.
    Distributor ID: Debian
    Description:    Debian GNU/Linux 6.0.6 (squeeze)
    Release:    6.0.6
    Codename:   squeeze
    gem env
    RubyGems Environment:
      - RUBYGEMS VERSION: 1.8.16
      - RUBY VERSION: 1.8.7 (2011-12-27 patchlevel 330) [java]
      - INSTALLATION DIRECTORY: /opt/jruby/lib/ruby/gems/1.8
      - RUBY EXECUTABLE: /opt/jruby/bin/jruby
      - EXECUTABLE DIRECTORY: /opt/jruby/bin
        - ruby
        - universal-java-1.6
      - GEM PATHS:
         - /opt/jruby/lib/ruby/gems/1.8
         - /usr/lib/ruby/gems/1.8
         - :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"
    which ruby
    which gem

    Here is the error I’m getting while running ruby file

    usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- net/https (LoadError)
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'

    I’ve been struggling to change that but with no luck. How do I change gem path on Debian?

  • Testing sftp connections in Ruby
  • How do I require a specific version of a ruby gem?
  • require 'command_line_argument_parser'?
  • gem check errors (registered but missing gems) after installing ruby 2.0.0-p0 with rbenv install
  • Rails Gem Kaleidescope Won't Install
  • Ruby on rails : Rspec installation guidance and usage
  • One Solution collect form web for “Fix ruby gems path issues in debian”

    Are you using a version manager like RVM/rbenv? They implement custom path modification.

    Do you know which user you are running as and if you are using sudo? This can of course also have a huge impact on path interpretation.

    Try this: navigate into the actual Bin folder of each of your Ruby implementations, and run the gem env command there. This has the effect running commands using that localized version of Ruby (and therefore RubyGems too in most cases). This can be very helpful in diagnosing these types of issues.

    For example:

    cd /some_path/Ruby-1.9.1/bin

    gem env

    Ruby is the best programming language in the world - Ruby on Rails.