call macports svn rather than pre-installed mac's svn - macos

i have mac preinstalled svn at ->/usr/bin/svn
i have macport install svn at -->opt/local/var/macports/software/subversion/1.6.3_0/opt/local
my .bash_profile look like
export M2_HOME=/Users/teoh/work/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
export PATH=/Users/teoh/work/gwt-mac-1.5.3:$PATH
how to set macport svn as default svn each time i use the console in mac? what do i need to put in .bash_profile?

The default install of Macports install links into /opt/local/bin and /opt/local/sbin.
So adding:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
at the end of your .bash_profile should let you access MacPorts svn.
I would also like to add that it is odd that MacPorts didn't do this for you when you installed it. Check for the line similar to above in your .bash_profile. If you have a line like it then try moving it to a position lower in the file.
You can also use 'which svn' in bash to determine which copy of subversion you are using.

In your .bash_profile file you can put:
alias svn=/opt/local/var/macports/software/subversion/1.6.3_0/opt/local/bin/svn

you need to set the macport svn location on the path before the preinstalled svn location.

Related

Failed to localise android-ndk installed from homebrew

I have installed SDK doing brew cask install android-ndk and NDK doing brew cask install android-ndk, everything was ok during the installation and inserted the PATH, like this:
export GRADLE_HOME=/usr/local/opt/gradle
export ANDROID_HOME=/usr/local/Caskroom/android-sdk/3859397
export ANDROID_NDK_HOME=/usr/local/Caskroom/android-ndk/16b/android-ndk-r16b
export ANDROID_SDK_ROOT=/usr/local/Caskroom/android-sdk/3859397
export PATH=$GRADLE_HOME/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
Saved and committed doing source ~/.bash_profile.
After, I tried to run my gradle task, during start of compile of a C++ library, I got this:
* What went wrong:
A problem occurred configuring project ':some-library'.
> NDK not configured.
Download it with SDK manager.
Is there any way to solve it?
Thank you.
In macOS installed with brew use this the following paths
In file ~/.bash_profile
export ANDROID_NDK_HOME = /usr/local/share/android-ndk
export ANDROID_HOME = /usr/local/share/android-sdk
If you are using another bash script or zsh for example, you should put it begin of that script file, eg.
myortherscript.sh
#!/bin/bash
# THIS AT TOP
source ~/.bash_profile
Important: This sample I'm considering the same user for configuration bash_profile and script execution.

Git and Terminal Commands not Working in Mavericks

I have two problems:
Git is not working although it is installed. Mavericks pops up a window and suggests to install Xcode (I don't want to): "The 'git' command requires the command line developer tools. Would you like to install it now?"
Sometimes even basic commands such as "ls" don't work. "-bash: ls: command not found". However, after inserting the command " . /etc/profile" it works for a while.
My ~/.bash_profile:
export PATH=/usr/local/git/bin:$PATH
export PATH=/usr/local/mongodb/bin
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
I'm very new to this. Please be aware while helping out.;) Your help is highly appreciated.
Amir
You are overwriting your PATH in this line:
export PATH=/usr/local/mongodb/bin
it should be:
export PATH=/usr/local/mongodb/bin:$PATH
Then if you are using OSX I strongly suggest that you use Homebrew http://brew.sh/ which is a package manager (like linux) for mac.
If you are developing on Mac, the command line tools are (almost) required for C/C++/ObjC dev. You can download them without XCode but it is not recommended. Homebrew will need them to build the software for your platform.
To download them go to https://developer.apple.com/downloads/index.action
Note, you'll need a developer account (it is free)
Once you have installed homebrew it is easy to have access to the latest software e.g:
brew install git
brew install mongodb
etc.
You don't have to manage and download the packages by hand. Very handy !
export PATH=/usr/local/git/bin:$PATH
export PATH=/usr/local/mongodb/bin
That second export overwrites PATH completely and sets it to the mongodb directory only. You need to append (or prepend) to PATH, not overwrite it.
export PATH="/usr/local/git/bin:$PATH"
export PATH="/usr/local/mongodb/bin:$PATH"
...

Replace Xcode's git with downloaded latest 1.8.3

I want to use latest version of git (1.8.3).
Currently when I make git --version it shows me git version 1.7.12.4 (Apple Git-37) which was installed together with Xcode I suppose.
I installed newest version but still bash uses Xcode one..
Please advice me how to override xcode git with the path that is installed to usr/local/bin?
Thanks!
Edit ~/.bash_profile and add
alias git=/usr/local/bin/git
Source the bash_profile file or restart bash (source ~/.bash_profile)
See what git --version prints.
I am not sure if this affects XCode. I never use versioning tools in IDEs, I do it from the command line
Or you add /usr/local/bin to $PATH to your bash_profile. I do this with macports or better said macports alters your bash_profile automatically.
export PATH=/usr/local/bin:$PATH
Use a symbolic link to make Xcode use the /usr/local/bin/git instead of its built-in git
cd /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo mv git xcodeGIt
sudo ln -s git /usr/local/git
Disclaimer: typed inline -- but thats how it works. Done it and it works fine for me

How to update my version of git on OSX 10.8

I'm on OSX 10.8.2 and I'm running git git v1.7.4.4
I just installed git on a remote server and it's version 1.11.x. I'm I would like to be running the same version of the software but I cannot figure out how to update git on my laptop.
I attempted to follow the steps listed here, which instruct to download the git-OSX-installer, run the install (which ran smoothly) and then do:
$ sudo mkdir -p /usr/local/bin
$ sudo ln -s /usr/local/git/bin/git /usr/local/bin/git
But after this I do git --version and it's still 1.7.4.4. Did I just reinstall the same version? Or did I install a newer version somewhere else?
I've been reading similar questions and I think the issue is that OSX ships with an old version of git installed in a different location then where the git-osx-installer or mac ports will put it. But I'm not sure how to correct this. Thanks in advance for your advice.
Update:
which git returns:
/usr/bin/git
echo $PATH returns:
/opt/local/bin:/opt/local/sbin:/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/opt/sm/bin:/opt/sm/pkg/active/bin:/opt/sm/pkg/active/sbin
Update2:
ESL ~/Downloads$ export PATH=/usr/local/bin:$PATH
ESL ~/Downloads$ which git
/usr/local/bin/git
ESL ~/Downloads$
ESL ~/Downloads$ git --version
git version 1.8.1.3
It appears I installed the newer git version in local. So should I add the export PATH=/usr/local/bin:$PATH to my .bash_profile? Is it a problem that both versions of git are installed?
I added export PATH=/usr/local/bin:$PATH to the bottom of my ~/.bash_profile and now the new version of git runs.
The best way to update any binary on a Mac OSX machine is to use the package(s) developed specifically for Mac (a .dmg or .pkg download).
In the case of git this is at: http://git-scm.com/download/mac
(clicking on this link should automatically start the download of the latest version of git for Mac).
However, in this case (at least for my 10.8.3 MacBook) this was not quite the whole story: the package installs git in /usr/local/git and then adds that path at the end of $PATH - which defeats the whole purpose IMO.
I have manually modified my .bashrc so as to have something similar to what suggested above:
export PATH=/usr/local/git/bin:$PATH
Once you do that, you should see the correct version of git being picked:
$ git --version
git version 1.8.2.2
Note that this won't work for any app that is launched interactively (eg, via the docking bar) - you'll have to run the additional script provided in the downloaded package; see the README for instructions.
Since /usr/bin shows up before /usr/local/bin in your path, the git executable in /usr/bin will be given precedence.
try this in your shell:
export PATH=/usr/local/bin:$PATH
which git
On a side note, I'd strongly recommend using homebrew for managing installations such as this on macos
I had a similar issue in Cygwin (linux environment compiled for windows). I would do
which git
and it would respond with the correct location of the updated git compiled from source, but wouldn't actually use it until I did
hash -r git
I don't claim to understand what this did or why it had to be done, but after that git --version replied with '1.8.2.rc0.22.gb3600c3' which was clearly no longer the old git shipped with Cygwin. This may not apply to OSX, but give it a shot if which git is locating the updated binary.

override git from Xcode with homebrew version

I've installed XCode and therefore git is there as well. Since i want to have a newer version of git I installed using homebrew.
But the homebrew version of git is never called since my PATH looks like this
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
which means the /usr/bin/git is allways called before /usr/local/bin/git.
Is there a way to change that without changing the PATH?
Xcode is actually using the GIT that is stored in /Applications/Xcode.app/Contents/Developer/usr/bin. The same version of GIT gets installed in /usr/bin when you installed the command line tools as part of Xcode installation. So, you won't be able to change what Xcode is using (unless you are willing to muck with the contents of the Xcode package). If, from a terminal application, you want to use the homebrew-installed GIT then you have two options:
Reference GIT with the full path as /usr/local/bin/git ... For this case you can create an alias like alias mgit=/usr/local/bin/git and then use mgit ... from the terminal
Change the path as PATH=/usr/local/bin:$PATH either in your .bashrc or .zshrc if you use zsh file (or each time you start a terminal at the command line).
Since Xcode hard coded its own version of git which is installed on /Applications/Xcode.app/Contents/Developer/usr/bin/git, I managed to use this work around trick:
change into the Xcode directory:
cd /Applications/Xcode.app/Contents/Developer/usr/bin
rename the Xcode's git like this:
sudo mv ./git ./git-xcode-usr-bin
link my own git which is installed through homebrew:
sudo ln -s /usr/local/bin/git ./git
And I did the same thing with /usr/bin/git
This will acctually link /usr/local/Cellar/git/1.8.0/bin/git (because I'm use git 1.8.0 at the present)
Certainly this may cause some other problems, such as when I upgrade the homebrew's verion git in the future, it would not work for me :( and I have to make a new link then.
I do it like this because I want to solve my own problem here 13177203. And after search StackOverFlow for a long time, I finally got this solution.
If you are using fish shell instead of bash, you can point to your preferred git binary by adding the following to ~/.config/fish/config.fish.
function git
/usr/local/bin/git $argv;
end

Resources