Is it possible to have too many $PATHs set in OS X?

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)
)

  • How to run multiple external commands in the background in ruby
  • Create a bash script that doesn't prompt user for trivial responses like 'yes/Y or no/N'
  • Postgres cannot connect to server on Unix domain socket 5432
  • How to read stdout unbuffered with Open#popen3 in Ruby
  • Awk-like BEGIN and END with Ruby command-line
  • How to require a gem in .irbrc without needing to also add it to a Rails Gemfile?
  • Gems install fine but don't show as installed under rake gems
  • “which in ruby”: Checking if program exists in $PATH from ruby
  • 3 Solutions collect form web for “Is it possible to have too many $PATHs set in OS X?”

    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.

    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…

    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.

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