Code Monkey home page Code Monkey logo

Comments (8)

postmodern avatar postmodern commented on June 30, 2024

It appears the GEM_HOME / GEM_PATH variables are not being exported to the sub-shell. Could you echo their values from within the sub-shell?

from chgems.

janogonzalez avatar janogonzalez commented on June 30, 2024

Here are the values:

  • GEM_HOME: /Users/janogonzalez/.gem/ruby/2.0.0
  • GEM_PATH: /Users/janogonzalez/.gem/ruby/2.0.0:/Users/janogonzalez/.rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0:/Users/janogonzalez/.gem/ruby/2.0.0

I also noticed that chgems works properly when used without chruby.

from chgems.

postmodern avatar postmodern commented on June 30, 2024

Reproduced. Somehow chruby is incorrectly removing the gem dir added by chgems.

.zshrc

source /usr/local/share/chruby/chruby.sh
echo "Before: $GEM_PATH"
chruby ruby-2.0
echo "After: $GEM_PATH"

Output

$ chruby
   jruby-1.7.4
   rubinius-2.0.0-rc1
   ruby-1.8.7-p374
   ruby-1.9.3-p448
 * ruby-2.0.0-p247
$ chgems
Entering /vault/1/code/ronin with gems in .gem/ruby/2.0.0/ ...
Before: /vault/1/code/ronin/.gem/ruby/2.0.0:/home/hal/.gem/ruby/2.0.0:/opt/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0
After: /home/hal/.gem/ruby/2.0.0:/opt/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0:/home/hal/.gem/ruby/2.0.0

from chgems.

postmodern avatar postmodern commented on June 30, 2024

Ah ha, the problem is your calling chruby 2.0 in .zshrc. Before switching to a new Ruby, chruby_use will call chruby_reset which cleans PATH, GEM_PATH and unsets GEM_HOME. Since chgems spawns a sub-shell with GEM_HOME set, chruby_reset thinks it's another Ruby's GEM_HOME and removes it from PATH/GEM_PATH.

from chgems.

postmodern avatar postmodern commented on June 30, 2024

Double ah ha. The solution is to put chruby ruby-2.0 in ~/.zprofile, which will only be loaded when spawning login shells, not sub-shells.

from chgems.

janogonzalez avatar janogonzalez commented on June 30, 2024

.zprofile is loaded before .zshrc so the solution is not working. I also tried the autoswitching approach without any luck. I don't know enough zsh to find the solution so I will try to find someone to help me.

Maybe a shell function is the way to make it work in zsh?

from chgems.

postmodern avatar postmodern commented on June 30, 2024

Try putting the following in .zprofile:

source /usr/local/share/chruby/chruby.sh
chruby ruby-2.0

from chgems.

postmodern avatar postmodern commented on June 30, 2024

Oh, a zsh user pointed out that .zlogin is loaded after .zshrc. Perhaps I should recommend using that file instead of .zprofile.

from chgems.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.