views:

59

answers:

3

I've been learning about gems lately, and one error I get is:

WARNING:  Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
  /usr/bin aren't both writable.
WARNING:  You don't have /Users/Alex/.gem/ruby/1.8/bin in your PATH,
 gem executables will not run.
ERROR:  Error installing rubygame:
 ffi requires rake (>= 0.8.7, runtime)

I understand that UNIX (bash, more specifically) uses this .bash_profile file to know where to look for executables when I run a script/command, and that it does so "in order".

My question is: Can I just keep tacking directories on the end as I need them, and does doing this open me up to... anything?

(for what it's worth, I re-ran the command as "sudo gem..." and it still said "ERROR: Error installing rubygame: ffi requires rake (>= 0.8.7, runtime) )

A: 

I don't know of any limits of how long the $PATH var or any one env var can be. But I guess there is a limit on environment variables in general, something like 65KB total. Still not sure.

Joy Dutta
+3  A: 

You can add stuff to the end (or to the top) of PATH until you reach the length limit for a variable. Which is loooooong.

But it slows command searches. Every time you type a command the the executable is searched everywhere the PATH tells it to search until found. Commands typos may lead to non-existing files and those could get slow to sort out.

ZJR
All modern shells cache.
Jed Smith
Actually it depends of the shell (for the command searching). A clever shell like zsh (everybody should use it:P) keep a hash table of all the available commands, that's why you need to do "rehash" after installing something.
Ehm, *bash does hashing*. (check `help hash`) It's **lazy** hashing, yes. It doesn't search stuff it didn't already find. Then, also manually rehashing an active hash of a mastodontic path, can prove out to be a long operation.
ZJR
+1  A: 

I believe bash caches the location of executables, so even if you have a long PATH it shouldn't take longer to run programs.

You could try sudo gem update rake for that last error...

DigitalRoss