码迷,mamicode.com
首页 > 其他好文 > 详细

002_网上脚本执行请注意,慎重

时间:2018-05-03 14:20:47      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:cti   local   rom   upgrade   new   注意   python   sudo   bsp   

一、进坑过程如下

执行ansible遇到这种错误:
(1)
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /your/home/.virtualenvs/virtualenv_name/bin/python
  Reason: image not found
[1]    95221 trace trap  python

(2)于是从Google查解决方案。看到是之前同事写的,就没细看就执行了,执行关键内容如下
#https://gist.github.com/tevino/1a557a0c200d61d4e4fb

read -p "??  Press Enter if you are not sure (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    echo "??  Removing old symbolic links......"
    find "$ENV_PATH" -type l -delete -print
    echo "??  Creating new symbolic links......"
    $SYSTEM_VIRTUALENV "$ENV_PATH"
    echo "??  Done!"
fi

(3)执行完就哭了,很多命令都找不到了,原因是删除了/usr/local/bin下的所有软连接

(4)粗糙的执行恢复:
cd /usr/local/bin
for i in `ls ../Cellar/*/*/bin`;do
    softlinksrc=`sudo find /usr/local/Cellar  -name $i|sed  ‘s#/usr/local#..#g‘`
    ln -s $softlinksrc .
done

二、总结

坑的连接如下:
#https://gist.github.com/tevino/1a557a0c200d61d4e4fb

其中有个叫laymonk的哥们明确说了这有坑了,所以以后Google和github出的内容一定要看完,谨记!!!

laymonk commented on Oct 7, 2016 ? 
I stumbled upon this, and just had to comment.

I imagine you reckon you are being helpful, but this a most dangerous thing to ask people to run. Running it could easily delete all links in /usr/local, which is the standard place homebrew installs pip (so, your $ENV_PATH will be /usr/local)

The simple fix involves just cd‘ing into the virtualenv, and deleting all the stale links to the upgraded python by running:
find . -type l -delete

.. and then re-installing your virtualenv:
mkvirtualenv venv-name or virtualenv venv-name

An unsuspecting user may not understand the implication of answering yes, and have all symlinks blown away from /usr/local .. I think you should take this down, or amend it. No offence intended.

  

 

002_网上脚本执行请注意,慎重

标签:cti   local   rom   upgrade   new   注意   python   sudo   bsp   

原文地址:https://www.cnblogs.com/itcomputer/p/8984828.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!