> ## Content Index
> Fetch the complete content index at: https://sgpublic.xyz/llms.txt
> Use this file to discover other available public pages before exploring further.

# JetBrains Gateway 不加载 .bashrc 甚至不加载 /etc/profile.d/*.sh 解决方案
- URL: https://sgpublic.xyz/p/2025/07/6aac9cb1810a480001533612/
- Published: 2025-07-02T12:52:01.000Z
- Updated: 2026-09-18T04:59:26.000Z
- Author: Haven Madray
- Tags: 桌面与终端, #wp-post

> 参考文章：[https://youtrack.jetbrains.com/issue/IJPL-166938/Bash-Profile-Not-Loaded-and-Non-Interactive-Run-Shell](https://youtrack.jetbrains.com/issue/IJPL-166938/Bash-Profile-Not-Loaded-and-Non-Interactive-Run-Shell?ref=sgpublic.xyz)

JetBrains Gateway 一直有个问题在困扰我，就是它启动的 IDE 不加载我放在 `/etc/profile.d` 的环境变量，我写在 `.bashrc` 里的 alias 也不生效。

经过网上冲浪找到原因：JetBrains Gateway 使用非交互式运行 shell，而这种情况下 `/etc/profile` 并不会加载，并且 `.bashrc` 文件开头有这么一句：

```shell
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

```

当使用非交互式运行的时候，后面的东西就都不会执行了。那么解决方案就很明了了，即把自定义的东西放到 `.bashrc` 文件的开头，而不是结尾。

而对于 `/etc/profile.d/*.sh`，我的方案是把我自定义的东西放到单独的文件夹里，比如 `/etc/profile.d/dev-container/*.sh`，然后在 `.bashrc` 开头加载。

这样就解决这个问题了。