When you set PATH to just one value, you lost all the other places to search, such as /bin
and /usr/bin
. Set your PATH incrementally:
export PATH=/new/place/bin:$PATH
You can be more elaborate than that, but that basic technique works.
Meantime, logout and login again - that will get you going most easily. Alternatively:
export PATH=$PATH:/bin:/usr/bin
Additionally, your first line was:
export PATH=$PATHEXECUTABLE DIRECTORY: /Users/zak/.rvm/gems/ruby-1.9.2-p0@rails3tutorial/bin
When you run export
, it will export one or more variables, but the values must either be simple variable names, or must be variable assignments:
export SOMEVAR NOTHERVAR=new-value ...
The complaint -bash: export:
DIRECTORY:': not a valid identifier` is telling you that 'DIRECTORY:' is not valid. It is not clear what you had in mind. And you got a similar complaint about /Users/zak/... not being an identifier.
You can set an environment variable for just one run of a command:
PATH=$EXECUTABLE_DIRECTORY:$PATH /Users/zak/bin/command
The environment of the command will include the value of PATH given; note, though, that the shell won't search for the command with that modified path.
...What I was trying to do was...
I'm not a user of either Ruby or Rails, but on my Mac (10.6.4), I can find:
Osiris-2 JL: ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Osiris-2 JL: rails -v
Rails 2.3.5
Osiris-2 JL: which ruby rails
/usr/bin/ruby
/usr/bin/rails
Osiris-2 JL:
So, on my machine, both Ruby and Rails are in /usr/bin
. I don't have Heroku installed AFAIK (not on my PATH, anyway). Your first export clobbered PATH; the second one added your Ruby 1.9.2 directory to the empty PATH. Apparently, Heroku is installed somewhere else, or is not yet installed at all. You changed directory - a built-in operation that does not require a working PATH; you added the Ruby 1.9.2 directory to your PATH again (which didn't change anything usefully). Heroku is still not found. You echoed PATH (another built-in) - I'm not clear where the GEM: command not found
message comes from. And the commands gem
and heroko
(sic) were not found. So, your first command set in train the problems.
Then you commented:
In terms of what I was trying to do, I was just trying to set-up my heroku account and got stuck when I tried to add my public ssh key. The heroko gem I had installed (thought) was not registering. That is when I read through the stackoverflow question referenced above that suggested my path was incorrect. I closed terminal and reopened. Running stuff like ruby -v outputs, but running rails -v does not. Is there something still to do? Why would rails -v not output?
Specifically on rails -v I get "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:827:in report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:261:in
activate' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:68:in `gem' from /usr/bin/rails:18 "
This suggests that you have rails installed in /usr/bin (like I do), but the installation has been altered somehow so it is self-inconsistent. Either that or the messed up environment (PATH) is causing trouble. But usually, software can find its own bits'n'pieces, so it suggests there is something up. Part of the trouble may be that you're using a Ruby 1.9.2 program with some Ruby 1.8 software.
My personal policy is to leave o/s provided software strictly alone; I let the Mac updates take care of that. If I want my own version of something, I build it and install it under my control - I do this with Perl, sometimes with GCC, and with Git or SVN or Mercurial or other such software.
I would look at ensuring you have the Ruby 1.9.2 environment working fully, and worry about whether you need to update your Rails environment in parallel. I suspect that using Ruby 1.9.2 with Rails built for Ruby 1.8.x is causing some of the trouble - but I'm not certain of that.