当前位置: 首页 > news >正文

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

一、进坑过程如下

执行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      #######important########
    echo "?  Creating new symbolic links......"
    $SYSTEM_VIRTUALENV "$ENV_PATH"
    echo "?  Done!"
fi

(3)执行完就哭了,很多命令都找不到了,原因是删除了/usr/local及/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
(5)或执行以下恢复
Updating Homebrew...
Warning: nginx 1.13.12 is already installed, it's just not linked
You can use `brew link nginx` to link this version.
即:
brew link custom_software_name
➜  nginx brew link --overwrite --dry-run wget
Would remove:
/usr/local/bin/wget -> /usr/local/Cellar/wget
../Cellar/wget/1.19.1_1/bin/wget
(6)
for cs in `ls /usr/local/Cellar`;do
    brew link --overwrite --dry-run $cs
    brew link $cs
done

拿wget举例:

这种warning单独处理下吧.已经提示很明显了

二、总结

坑的连接如下:
#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.

三、遗留问题处理

(1)diagnosis

➜  ~ brew doctor    #根据brew doctor的建议进行响应的操作,notice warning section.
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python
  ruby
  vim

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
  echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc

Warning: Broken symlinks were found. Remove them with `brew prune`:
  /usr/local/bin/bin
  /usr/local/bin/erb
  /usr/local/bin/gem
  /usr/local/bin/irb
  /usr/local/bin/rake
  /usr/local/bin/rdoc
  /usr/local/bin/ri
  /usr/local/bin/ruby
  /usr/local/bin/sqlite3

(2)multi-version question

➜  ~ brew ls --versions | grep vim
vim 8.0.1250 8.0.1600
➜  ~ brew uninstall --force vim
➜  ~ brew install vim    #解决

 

相关文章:

  • Django中ORM之操作表记录
  • Flann库的MATLAB接口编译
  • #includecmath
  • 你相信永生吗?
  • 6421B Lab10 网络文件和打印服务的配置与故障排除
  • 记录idea创建多模块项目遇到的问题(Spring cloud项目,maven父子关系无法继承,使用模板创建web项目无法生成java和resource文件夹)...
  • QQ开放API
  • 【性能优化实践】优化打包策略提升页面加载速度
  • #、%和$符号在OGNL表达式中经常出现
  • JavaEE进阶知识学习-----SpringCloud(二)实践准备
  • JavaScript And Ajax(JavaScript 基本示例)
  • linux centos 如何设置swap大小?
  • 【资源共享】RK3288 WiFiBT 开发配置参考说明
  • 仪表运算放大器INA333
  • 5分钟快速了解es6常用特性
  • #Java异常处理
  • ES6 学习笔记(一)let,const和解构赋值
  • JavaScript 基础知识 - 入门篇(一)
  • js ES6 求数组的交集,并集,还有差集
  • Python打包系统简单入门
  • Python十分钟制作属于你自己的个性logo
  • react-core-image-upload 一款轻量级图片上传裁剪插件
  • SpiderData 2019年2月25日 DApp数据排行榜
  • 服务器之间,相同帐号,实现免密钥登录
  • 回顾2016
  • 前端攻城师
  • 设计模式(12)迭代器模式(讲解+应用)
  • 译有关态射的一切
  • 用element的upload组件实现多图片上传和压缩
  • 中国人寿如何基于容器搭建金融PaaS云平台
  • 不要一棍子打翻所有黑盒模型,其实可以让它们发挥作用 ...
  • ​MySQL主从复制一致性检测
  • #绘制圆心_R语言——绘制一个诚意满满的圆 祝你2021圆圆满满
  • (3)选择元素——(14)接触DOM元素(Accessing DOM elements)
  • (Bean工厂的后处理器入门)学习Spring的第七天
  • (C#)Windows Shell 外壳编程系列9 - QueryInfo 扩展提示
  • (HAL)STM32F103C6T8——软件模拟I2C驱动0.96寸OLED屏幕
  • (MIT博士)林达华老师-概率模型与计算机视觉”
  • (动态规划)5. 最长回文子串 java解决
  • (非本人原创)史记·柴静列传(r4笔记第65天)
  • (附源码)springboot学生选课系统 毕业设计 612555
  • (转)AS3正则:元子符,元序列,标志,数量表达符
  • (转)大型网站架构演变和知识体系
  • .htaccess配置常用技巧
  • .net core 6 集成 elasticsearch 并 使用分词器
  • .net core 6 集成和使用 mongodb
  • .NET MVC之AOP
  • .NetCore实践篇:分布式监控Zipkin持久化之殇
  • /usr/local/nginx/logs/nginx.pid failed (2: No such file or directory)
  • @Autowired多个相同类型bean装配问题
  • [ARM]ldr 和 adr 伪指令的区别
  • [CLR via C#]11. 事件
  • [cogs2652]秘术「天文密葬法」
  • [linux学习]apt-get参数解析
  • [MySQL]基础的增删改查