mac上多個svn版本_where命令

本篇文章主要目的是:經過一個實例說明 where 命令的用途。php

今天,在項目目錄下執行svn info忽然報錯:html

ccc ➤ svn info
svn: E155021: This client is too old to work with the working copy at
'/Users/luzuheng/PhpstormProjects/vagrant/data/ccc' (format 31).
You need to get a newer Subversion client. For more details, see
  http://subversion.apache.org/faq.html#working-copy-format-change

提示svn版本不夠高。apache

ccc ➤ svn --version
svn, version 1.7.22 (r1694152)
   compiled Feb 10 2016, 16:22:46

Copyright (C) 2015 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - handles 'http' scheme
  - handles 'https' scheme

看來確實是版本低了,可是奇怪的是前兩天還能夠用的,說明個人機器上確定有多個版本的svn。vim

肯定當前用的是哪一個svn:app

ccc ➤ which svn
/usr/bin/svn

查看機器上有哪些svn:svn

ccc ➤ where svn
/usr/bin/svn
/usr/local/bin/svn
/usr/bin/svn

果真有多個,至於爲啥顯示了兩次/usr/bin/svn,後面再解決。vagrant

ccc ➤ /usr/local/bin/svn --version
svn, version 1.8.11 (r1643975)
   compiled Jan 18 2015, 06:42:12 on x86_64-apple-darwin14.1.0

Copyright (C) 2014 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - using serf 1.3.8
  - handles 'http' scheme
  - handles 'https' scheme

/usr/local/bin/svn下的是1.8的,再去項目裏執行svn info:code

ccc ➤ /usr/local/bin/svn info
Path: .
Working Copy Root Path: /XXXXXXXXX/ccc
URL: http://svnXXXXXXXX/trunk
Relative URL: ^/XXX/trunk
Repository Root: http://XXXXX/
Repository UUID: xxx
Revision: xxxx
Node Kind: directory
Schedule: normal
Last Changed Author: aaa
Last Changed Rev: xxxx
Last Changed Date: 2016-09-21 17:50:31 +0800 (三, 21  9 2016)

果真能夠了!orm

設置一下別名。vim ~/.zshrc 增長一行 alias svn=/usr/local/bin/svn,source一下,再執行svn --versionhtm

➜  ccc  svn --version
svn, version 1.8.11 (r1643975)
   compiled Jan 18 2015, 06:42:12 on x86_64-apple-darwin14.1.0

Copyright (C) 2014 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - using serf 1.3.8
  - handles 'http' scheme
  - handles 'https' scheme

OK了!

再回頭看where svn的時候爲啥顯示了兩次/usr/bin/svn。懷疑跟環境變量PATH有關

ccc ➤ echo $PATH
/usr/local/Cellar/php55/5.5.22/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

果真有兩個 /usr/bin,一樣/bin 和 /usr/sbin 和 /sbin 也有兩個。

查看zsh配置:

ccc ➤ cat ~/.zshrc|grep PATH
export PATH="/usr/local/Cellar/php55/5.5.22/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"

原來問題出在這,修改文件後, source ~/.zshrc,而後再看

➜  ccc  where svn
svn: aliased to /usr/local/bin/svn
/usr/local/bin/svn
/usr/bin/svn

OK了,由於svn的問題發現環境變量配置的錯誤,也算XXXX。 求XXXX這個成語……想不出來。。。

後續:

隔了兩個小時,忽然想到where svn結果顯示順序是按照PATH環境變量優先級來的,前兩天項目中svn info仍是可用的,今天忽然不能用的緣由就是昨天我調整了PATH,也就是說如今我修復完PATH以後不用別名也是優先使用的1.8版本的svn。 確認一下,先刪除alias,而後:

└─[$]> where svn
/usr/local/bin/svn
/usr/bin/svn

─[$]> svn --version
svn, version 1.8.11 (r1643975)
   compiled Jan 18 2015, 06:42:12 on x86_64-apple-darwin14.1.0

Copyright (C) 2014 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
  - using serf 1.3.8
  - handles 'http' scheme
  - handles 'https' scheme

果真啊…… 原來PATH錯誤纔是致使項目裏svn忽然用不了的罪魁禍首!!!

以前還在慶幸由於svn問題發現了PATH錯誤……

蜜汁尷尬。。。

繼續求一發 XXXX 成語...

語死早。。。

相關文章
相關標籤/搜索