Reputation: 315
I broke it again and unfortunately I am not sure why...
Problem first
Using the .bash_profile
that was created during RVM installation Git cannot be found. Adding back the old path exports from mac ports in the .profile
breaks the rails server by reverting ruby back to 1.8.7
I think I identified
/opt/local/bin:
/opt/local/sbin:
to be the two directories in the .bash_profile
that will make Git work but break the new RVM ruby verison.
Solution
So here the solution: I am using a Mac Ports Git version. Thats why it won't run, unless the Mac Ports directories are part of the path. When the Mac Ports directories are sourced after RVM the Mac Ports Ruby Version seem to take precedence over the RVM version.
This will break:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
This will work:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
Thanks @three for pointing me in the right direction :)
How I broke it
Juggeling Ruby and Rails versions around to be in sync with the tutorials I am doing to learn the two, the name RVM kept popping up as a tool to manage those versions more conveniently.
I installed it and and got it to work
ruby -v
$ ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
rails -v
$ Rails 3.1.3
In the process my .profile
started failing, but I think that is because of the precedence of the .bash_profile
that was created during the RVM installation. I was expecting trouble but all good so far and everything working, including the rails server.
rails s
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-19 10:16:15] INFO WEBrick 1.3.1
[2011-12-19 10:16:15] INFO ruby 1.9.2 (2011-07-09) [x86_64-darwin10.8.0]
[2011-12-19 10:16:15] INFO WEBrick::HTTPServer#start: pid=53018 port=3000
Then I wanted to commit to Git, but that all of a sudden doesn't work anymore
git
-bash: git: command not found
So I compared the .profile
and .bash_profile
found that Mac Ports added a line of code to the .profile
when initially installing ruby, rails and git (sure 100% I used MacPorts for all three)
##
# Your previous /Users/username/.profile file was backed up as /Users/username/.profile.macports-saved_2011-10-19_at_08:48:41
##
# MacPorts Installer addition on 2011-10-19_at_08:48:41: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
If I query the ruby version with this setting I get:
ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10]
So my newbie guess is I broke the path variable in the process of installing RVM. If I add the line to the .bash_profile
git works again, but the rails server doesn't. Notice the ruby version missmatch.:
rails s
/Users/username/.rvm/gems/ruby-1.9.2-p290/gems/sqlite3-1.3.5/lib/sqlite3/sqlite3_native.bundle: [BUG] Segmentation fault
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10]
Abort trap
The contents of my $PATH when using the Mac Ports PATH exports is:
echo $PATH
/opt/local/bin:
/opt/local/sbin:
/Users/username/.rvm/gems/ruby-1.9.2-p290/bin:
/Users/username/.rvm/gems/ruby-1.9.2-p290@global/bin:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/bin:
/Users/username/.rvm/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/X11/bin:
On the other hand using the .bash_profile
as is this is the $PATH contents:
echo $PATH
/Users/username/.rvm/gems/ruby-1.9.2-p290/bin:
/Users/username/.rvm/gems/ruby-1.9.2-p290@global/bin:
/Users/username/.rvm/rubies/ruby-1.9.2-p290/bin:
/Users/username/.rvm/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/bin:
/usr/X11/bin:
Looks pretty similar, except for those two directories:
/opt/local/bin:
/opt/local/sbin:
So my guess is, thats where it breaks... But I have no idea what to do about it.
I am still so new to all of this development, Apple Computers, Unix, Ruby, Rails Stuff :(
Any help is greatly appreciated.
Thanks TIM
Upvotes: 1
Views: 1861
Reputation: 41
insert this line to .bash_profile:
source "$HOME/.profile"
before RVM added contents.
Upvotes: 0
Reputation: 8478
put the RVM line after the export PATH for macports so that the rvm binaries for ruby will take precendence
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
Also consider using homebrew instead of macports which is the much slicker version of maintaining *nix tools.
Upvotes: 2