3

I added some data to my .bash_profile to run two aliases ruby version 19 and the proper gems. As soon as I added the data I could not longer run any commands such as the MacPorts command port nor the command mate to run TextMate. As soon as I deactivated .bash_profile and .bash_login and even .bash_history all was well again. .bash_history got regenerated and soon thereafter I got .bash_profile reinstated with my badly needed aliases, but then I lost the option to run these commands again. Here is some of the output of all these files:

jaspersmbp:~ jasper$ cat .bash_profile
    alias ruby='/opt/local/bin/ruby1.9'
    alias gem='/opt/local/bin/gem'
jaspersmbp:~ jasper$ cat .bash_login
jaspersmbp:~ jasper$ cat .bashrc
    HISTFILESIZE=1000000000
    HISTSIZE=1000000
jaspersmbp:~ jasper$ cat .profile
    #Django path
    export PATH=/opt/local/bin:opt/local/sbin:/opt/local/lib/python2.4/site-packages/django/bin:$PATH
    # Apache alias
    alias apacherestart='sudo /opt/local/apache2/bin/apachectl -k restart'
    #Subversion OSX for Eclips Joomla Development
    export PATH=/opt/subversion/bin:$PATH
    #Test
    #echo $PATH
    ##
    # Your previous /Users/jasper/.profile file was backed up as /Users/jasper/.profile.macports-saved_2012-05-18_at_09:47:58
    ##
    # MacPorts Installer addition on 2012-05-18_at_09:47:58: 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.

Does anyone know why making .bash_profile active anihilates the use of commands such as mate and port? I really need .bash_profile to work so I can use aliases and I need MacPorts port command for all kinds software.

  • I'm confused: is MacPorts generating some of your dotfiles? If so, exactly which files? This seems like a terrible idea.. – user13742 Jun 10 '12 at 11:24
0

It looks like MacPort is generating your configuration files, and messing up your PATH and such. The easiest way to fix this is by doing it yourself - disable MacPort generation/creation of the dotfiles concerning your path and aliases, remove the .bash_profile and .profile files and then append the following to the ~/.bashrc file:

# define aliases
alias ruby='ruby1.9'
alias apacherestart='sudo apachectl -k restart'

# define hist properties
HISTFILESIZE=1000000000
HISTSIZE=1000000

# define path to programs
PATH=/opt/local/bin:opt/local/sbin:/opt/subversion/bin:/opt/local/apache2/bin/:/opt/local/lib/python2.4/site-packages/django/bin:$PATH

# define manpath
MANPATH=/opt/local/share/man:$MANPATH

# export env vars
export HISTFILESIZE HISTSIZE PATH MANPATH

Start a new terminal and run echo $PATH to check that everything is in there and then test a couple of commands installed under /opt/local/bin. Since all the directories in the above PATH= statement are now in your PATH you don't need aliases that use absolute paths to the binary - for example you don't need the alias for gem anymore because you can just run gem.

Update: If your ~/.bashrc is not sourced put source ~/.bashrc in a clean ~/.bash_profile.

  • Here is my current PATH $ echo $PATH /opt/local/bin:/opt/local/sbin:/opt/subversion/bin:/opt/local/bin:opt/local/sbin:/opt/local/lib/python2.4/site-packages/django/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/X11/bin I will try your suggestion. I do need to keep MacPorts running, but reading your explanation it seems I can. macPorts did generate the files to make using the port command. – rhand Jun 10 '12 at 13:02
  • Only somehow the alias alias ruby='/opt/local/bin/ruby1.9' does not run Ruby 1.9 yet, but still grabs the old Ruby – rhand Jun 10 '12 at 13:39
  • When I also removed .profile I lost port and mate. Here is my current path echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/X11/bin and path in .bashrc PATH=/opt/local/bin:opt/local/sbin:/opt/subversion/bin:/opt/local/apache2/bin/:/opt/local/lib/python2.4/site-packages/django/bin:$PATH – rhand Jun 10 '12 at 13:48
  • @rhand See my update in the answer. – user13742 Jun 10 '12 at 14:37
  • Cool. All commands seem back. Only got one path warning concerning gems running: sudo gem install --user-install typhoeus Password: Fetching: typhoeus-0.4.2.gem (100%)m /opt/local/lib/ruby/site_ruby/1.8/rubygems/installer.rb:438: warning: Insecure world writable dir /usr/local in PATH, mode 040777 WARNING: You don't have /Users/jasper/.gem/ruby/1.8/bin in your PATH, gem executables will not run. Successfully installed typhoeus-0.4.2 1 gem installed Installing ri documentation for typhoeus-0.4.2... Installing RDoc documentation for typhoeus-0.4.2... – rhand Jun 10 '12 at 14:50
1

Bash reads ~/.bash_profile if it exists, and ~/.profile if it doesn't. Hence when you created ~/.bash_profile, your ~/.profile was no longer used. Your aliases aren't specific to bash as opposed to other shells, so you might as well put them in ~/.profile.

Also, you start an interactive login bash, bash reads ~/.bash_profile or ~/.profile (the bash-specific session startup script, or the generic shell session startup script if it doesn't exist), but not ~/.bashrc (the interactive bash startup script). So put these two lines in your ~/.bash_profile to load everything as it should be:

. ~/.profile
case $- in *i*) . ~/.bashrc;; esac
0

Well, maybe it's $PATH problem? Have you check it before & after?

  • Here is my PATH: $ echo $PATH /opt/local/bin:/opt/local/sbin:/opt/subversion/bin:/opt/local/bin:opt/local/sbin:/opt/local/lib/python2.4/site-packages/django/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/X11/bin Not sure if there is an issue there. You and @hesse do think there is so there must be. Still pretty green in this area. – rhand Jun 10 '12 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.