英文:
PATH-variable in wsl 2 gets always reset . How to fix that?
问题
在我重置Ubuntu(wsl2)后,无法设置例如:
export PATH=$PATH:/usr/local/go/bin
我的意思是它设置了,但是在我关闭终端后,所有配置都被重置,我应该执行:
export PATH=$PATH:/usr/local/go/bin
再次强调,即使我完全删除wls和ubuntu并重新安装,但没有任何变化。
英文:
after I reset Ubuntu (wsl2) from apps I can't set, for example,
> export PATH=$PATH:/usr/local/go/bin
I mean it set, but after I closed the terminal all config got reset and I should
> export PATH=$PATH: /usr/local/go/bin
Again, even I remove wls and ubuntu completely and reinstall, but nothing change
答案1
得分: 13
首先,这是大多数shell的预期行为。在你的bash shell中,导出的变量只在会话期间保留。你需要将export
命令添加到你的~/.bashrc
文件中。每次打开shell时,该文件都会被源化。
你可以运行echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
将该命令添加到bashrc文件中,或者使用你选择的编辑器。添加了export命令后,运行source ~/.bashrc
或重新启动你的shell。
此后,Go应该可用。
如果你有一个需要添加到源路径的Python模块安装路径,这也适用。
英文:
First, this is the expected behavior of most shells. In your bash shell, the exported variables are only kept for a session. You need to add the export
command to your ~/.bashrc
file. The file is sourced every time you open the shell.
You can run echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
to add the command to the bashrc file, or use your editor of choice. After adding the export command, run either source ~/.bashrc
or restart your shell.
Go should be available after this.
This also works if you have a python module installation path that needs to be added to the source.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论