V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
brucmao
V2EX  ›  Linux

从 bash 切换到 zsh,配置的 Java 环境变量失效

  •  
  •   brucmao · 2019-07-16 22:57:18 +08:00 · 4453 次点击
    这是一个创建于 1739 天前的主题,其中的信息可能已经有所发展或是发生改变。
    前几天将安装了 oh-my-zsh,今天发现启动虚拟机的 centos 后提示
    /etc/profile.d/emacs.sh:declare:4: br_hide_port: can't assign initial value for array

    配置的 java 环境变量也不能用了
    https://i.loli.net/2019/07/16/5d2de3b6b610893401.png

    环境变量配置在 ~/.bash_profile
    https://i.loli.net/2019/07/16/5d2de419c4fdf60918.png
    10 条回复    2019-07-16 23:32:53 +08:00
    brucmao
        1
    brucmao  
    OP
       2019-07-16 22:58:55 +08:00
    怎么让图片显示出来啊
    jiqing
        2
    jiqing  
       2019-07-16 23:00:55 +08:00
    zsh 的配置文件在~/.zshrc,在这个配置里重新添加就行了。
    bash 的配置文件时 bashrc 吧,记不清了。
    我一般都是用 rpm 安装 jdk,包机制默认安装就在 bin 也就不用配置环境变量了
    encro
        3
    encro  
       2019-07-16 23:03:31 +08:00
    export 语法不一样,bash_profile,.bash_rc 一些要迁移到.zshrc
    brucmao
        4
    brucmao  
    OP
       2019-07-16 23:06:29 +08:00
    @jiqing 这样应该可以的,网上说的还有一种方法是在~/.zshrc,在文件里加入一行:

    source ~/.bash_profile
    via:https://learnku.com/laravel/t/1308/how-does-the-configuration-of-environment-variable-do-not-work-already-solved-everything-from-zsh
    但是我执行这个会也会报这个
    /etc/profile.d/emacs.sh:declare:4: br_hide_port: can't assign initial value for array
    上面这个到底是啥问题了,google 半天没找到结果
    kwanzaa
        5
    kwanzaa  
       2019-07-16 23:08:11 +08:00
    挪到 ~/.zshrc
    jiqing
        6
    jiqing  
       2019-07-16 23:11:01 +08:00
    报错提示的挺明显的
    /etc/profile.d/emacs.sh 这个文件的 declare:4: br_hide_port:无法为数组分配初始值
    貌似是 emacs 的一个 sh 文件,
    如果报错没啥额外影响,就是进去报错,不用理他。
    jdk 的环境变量重新在 zshrc 里配置一下好了。
    遇到问题就解决问题,解决不了就绕过他
    jiqing
        7
    jiqing  
       2019-07-16 23:12:41 +08:00   ❤️ 1
    主要我没遇到过,只能给建议。我常用 vim 当一个文本编辑器,emacs 只是看教程偶尔用用。你试试把 emacs。sh 改个名字,能不能把这个报错隐藏了。
    jiqing
        8
    jiqing  
       2019-07-16 23:13:11 +08:00
    你最好先备份好文件再尝试哈,有啥错误我不负责
    brucmao
        9
    brucmao  
    OP
       2019-07-16 23:29:04 +08:00

    我都不知道什么时候安装这个 emacs
    brucmao
        10
    brucmao  
    OP
       2019-07-16 23:32:53 +08:00
    @jiqing 我改名后就没有这个报错了,感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   880 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 21:57 · PVG 05:57 · LAX 14:57 · JFK 17:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.