Code Monkey home page Code Monkey logo

chgems's Introduction

Software Engineer, Rubyist, Open Source Maintainer.

Languages

Ruby, Crystal, Bash, and sometimes C, C++, Java, XML/XSLT, HTML5, CSS4, JavaScript (ES6).

Status

Currently taking the rest of the year off to work on Open Source. See my GitHub Sponsor page for my plans/progress.

Projects

Stats

postmodern's github stats postmodern's top-languages stats

chgems's People

Contributors

chastell avatar choppa avatar havenwood avatar jwilkins avatar postmodern avatar timmoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

chgems's Issues

presence of a .ruby-version file and chruby autoswitching is resetting and overriding chgems

Thanks to an IRC chat with you, I am opening this ticket to remind you about this issue. I am using Chruby and have autoswitching enabled. I am using a .ruby-version folder in my project. Apparently this is preventing chgems from working properly.

To remind you, you said the following:
• auto.sh is resetting GEM_HOME/GEM_PATH
• So if you set the variables, then cd into the project directory the cd causes auto.sh to trigger and overrides those variables.

For now I removed the .ruby-version folder from my project and the autoswitch entry from my .bashrc file. I manually declare my version of Ruby when I go into the project and from this point, chgems will work as expected.

No profile.d in Snow Leopard

$ brew install https://raw.github.com/postmodern/chgems/master/homebrew/chgems.rb

######################################################################## 100.0%
==> Downloading https://github.com/downloads/postmodern/chgems/chgems-0.2.1.tar.gz
######################################################################## 100.0%
==> make install PREFIX=/usr/local/Cellar/chgems/0.2.1
install -d /usr/local/Cellar/chgems/0.2.1/share/doc/chgems-0.2.1
cp -r doc/* *.{md,tt,txt} /usr/local/Cellar/chgems/0.2.1/share/doc/chgems-0.2.1/ 2>/dev/null || true
ln -sf /usr/local/Cellar/chgems/0.2.1/share/chgems/chgems.sh /etc/profile.d/
ln: /etc/profile.d/: No such file or directory
make: *** [install] Error 1

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

The `-f` switch on readlink is missing on Mac OS X

Passing an argument to chgems in Mac OS X results in the following error:

$ chgems .
readlink: illegal option -f
usage: readlink [-n] [file ...]
chgems: cannot use  as a gem dir: No such directory

This seems to happen because the -f switch on readlink in Mac OS X is missing. Is there maybe an alternative?

chgems for "global" gems?

Sometimes I don't want to keep reinstalling a gem that I will use on every project (e.g. Bundler, Pry) but I don't want to have a system-wide Ruby either. With rbenv, I did this by installing those gems into a gemset called "global".

Then, in each project, I had a .rbenv-gemsets that said global that-project -- this tells it to look for the gem in a gemset named "global" first, then in a gemset named "that-project".

Is it possible to get equivalent functionality in chgems -- where I get one .gem folder that's shared amongst everything, and then a project-specific .gem folder?

Errors encountered running in Ubuntu

In Ubuntu, /bin/sh points to dash and this seems to be the cause of the ff. errors encountered:

/usr/local/bin/chgems: 10: /usr/local/bin/chgems: [[: not found
/usr/local/bin/chgems: 18: /usr/local/bin/chgems: [[: not found
/usr/local/bin/chgems: 38: /usr/local/bin/chgems: Bad substitution

chruby is overriding the environment variables after chgems sets them

I could not get chgems to properly set my gem related environment variables (PATH, GEM_HOME, GEM_PATH). I am using Linux Mint 15, and it appears that my .bashrc file was being run when chgems opened a sub-shell. When that happened,

source /usr/local/share/chruby/chruby.sh

was executed (from .bashrc) and overwrote the environment variables.
I was able to fix this by changing line 42 from

    $SHELL

to

    $SHELL -norc

This prevents the .bashrc file from being executed in the sub-shell.
Now it works flawlessly. Perhaps you could add this to your documentation.

Running 'chgems' resets the ruby version set by 'chruby'

(In my home directory & chgems executable installed by cloning the git repo)

$ mkdir test
$ cd test
$ ruby -v   # => ruby 1.8.7
$ chruby 2.0
$ ruby -v   # => ruby 2.0.0-p247
$ chgems
# Entering /Users/<username>/Documents/github_clones/codetriage with gems in .gem/ruby/2.0.0/ ...
$ ruby -v # => ruby 1.8.7
$ gem env
# RubyGems Environment:
#  - RUBYGEMS VERSION: 1.3.6
#  - RUBY VERSION: 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
#  - INSTALLATION DIRECTORY: /Users/<username>/test/.gem/ruby/2.0.0
#  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#  - EXECUTABLE DIRECTORY: /Users/<username>/test/.gem/ruby/2.0.0/bin
#  - RUBYGEMS PLATFORMS:
#    - ruby
#    - universal-darwin-12
#  - GEM PATHS:
#     - /Users/<username>/test/.gem/ruby/2.0.0
#     - /Users/<username>/.gem/ruby/2.0.0
#     - /Users/<username>/.rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0
#  - GEM CONFIGURATION:
#     - :update_sources => true
#     - :verbose => true
#     - :benchmark => false
#     - :backtrace => false
#     - :bulk_threshold => 1000
#     - "gem" => "--no-rdoc"
#  - REMOTE SOURCES:
#     - http://rubygems.org/

As an extension, if I set the default ruby in my shell profile, the gem_path doesn't get set at all. So, if I add the line chruby 2.0 to my zshrc, this is the behaviour:

$ mkdir test
$ cd test
$ ruby -v   # ruby 2.0.0-p247
$ chgems
# Entering /Users/<username>/Documents/github_clones/codetriage with gems in .gem/ruby/2.0.0/ ...
$ ruby -v   # ruby 2.0.0-p247
$ gem env
# RubyGems Environment:
#  - RUBYGEMS VERSION: 2.0.3
#  - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin12.4.0]
#  - INSTALLATION DIRECTORY: /Users/<username>/.gem/ruby/2.0.0
#  - RUBY EXECUTABLE: /Users/<username>/.rubies/ruby-2.0.0-p247/bin/ruby
#  - EXECUTABLE DIRECTORY: /Users/<username>/.gem/ruby/2.0.0/bin
#  - RUBYGEMS PLATFORMS:
#    - ruby
#    - x86_64-darwin-12
#  - GEM PATHS:
#     - /Users/<username>/.gem/ruby/2.0.0
#     - /Users/<username>/.rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0
#  - GEM CONFIGURATION:
#     - :update_sources => true
#     - :verbose => true
#     - :backtrace => false
#     - :bulk_threshold => 1000
#     - "gem" => "--no-rdoc"
#  - REMOTE SOURCES:
#     - https://rubygems.org/

Not Setting Environment

I thought this was a problem with zsh, but I just tried it on a box with bash, and it's not working there either.

I'm using chruby with auto changing from .ruby-version

You'll see, i've added an echo $GEM_HOME after the exports:

$ echo $SHELL
/bin/bash
$ echo $GEM_HOME
/home/vagrant/.gem/ruby/2.0.0
$ echo $PWD
/vagrant/projects/fog
$ chgems .
/vagrant/projects/fog/.gem/ruby/2.0.0
Entering /vagrant/projects/fog with gems in .gem/ruby/2.0.0/ ...
$ echo $GEM_HOME
/home/vagrant/.gem/ruby/2.0.0
$ 
dev :: ~ » echo $SHELL
/bin/zsh
dev :: ~ » cd fog
dev :: ~/fog » echo $PWD
/home/ichilton/fog
dev :: ~/fog » echo $GEM_HOME
/home/ichilton/.gem/ruby/2.0.0
dev :: ~/fog » chruby  
   ruby-1.9.3-p545
 * ruby-2.0.0-p481
   ruby-2.1.2
dev :: ~/fog » chgems .
Entering /home/ichilton/fog with gems in .gem/ruby/2.0.0/ ...
dev :: ~/fog » echo $GEM_HOME
/home/ichilton/.gem/ruby/2.0.0
dev :: ~/fog » 

Any ideas?

Thanks,

Ian

Leave my PS1 alone!

... or at least provide an option (ENVVAR?) that makes chgems leave it alone.

I already use a PS1 that has my current directory in, so chgems adding it too just makes for noise.

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.