Hyper: .bash_profile not sourced automatically.

Created on 9 Sep 2016  ยท  23Comments  ยท  Source: vercel/hyper

OSX, fresh install via brew, app updated.

The application window looks great, but it doesn't seem to respect my ~/.bash_profile, so I don't get my colors or aliases out of the box. source ~/.bash_profile works as expected. Annoying though.

help wanted High Bug Compatibility

Most helpful comment

Hi @Miserlou, I did some researching into this, think I found the issue. Is bash your default terminal, or are you using something like zsh and executing /bin/bash after you're in zsh?

Basically what happens when you run bash is:

  • It doesn't start a login shell. For that you have to use bash --login
  • Only when your shell is a login shell it sources ~/.bash_profile otherwise it will try ~/.profile and if that one is not available ~/.bashrc. This explains why @hamstu's example is functioning ๐Ÿ˜„

More information on this loading behaviour can be found here

By default when creating a new tab hyperterm will load your default login shell using --login provided here.

Tested this in Hyperterm and Terminal.app. Could you provide some more insights in how you're using it? Thanks ๐Ÿ‘

All 23 comments

I can't believe this haven't been noticed by anyone else before ๐Ÿ˜ฑ Thanks for reporting!!!

_PS: I can reproduce_

Hmm, seems to be working fine on my end.

Out of curiosity what's in your ~/.bashrc file @Miserlou and @matheuss?

This is for .bash_profile, not .bashrc. Although I actually do have some exports in my .bashrc, now that I look at it, my .bash_profile is really where the magic happens.

I don't have a .bashrc ๐Ÿค”

@Miserlou Ah yeah โ€”ย I was just wondering if HyperTerm is sourcing your .bashrc, since this is what's in mine and _maybe_ that's why it's sourcing my .bash_profile no problem?

[ -n "$PS1" ] && source ~/.bash_profile

Hi @Miserlou, I did some researching into this, think I found the issue. Is bash your default terminal, or are you using something like zsh and executing /bin/bash after you're in zsh?

Basically what happens when you run bash is:

  • It doesn't start a login shell. For that you have to use bash --login
  • Only when your shell is a login shell it sources ~/.bash_profile otherwise it will try ~/.profile and if that one is not available ~/.bashrc. This explains why @hamstu's example is functioning ๐Ÿ˜„

More information on this loading behaviour can be found here

By default when creating a new tab hyperterm will load your default login shell using --login provided here.

Tested this in Hyperterm and Terminal.app. Could you provide some more insights in how you're using it? Thanks ๐Ÿ‘

Bash is my default shell. This is just a normal OSX install.

On Tue, Oct 4, 2016 at 4:32 PM, Tim Neutkens [email protected]
wrote:

Hi @Miserlou https://github.com/Miserlou, I did some researching into
this, think I found the issue. Is bash your default terminal, or are you
using something like zsh and executing /bin/bash after you're in zsh?

Basically what happens when you run bash is:

  • It doesn't start a login shell. For that you have to use bash --login
  • Only when your shell is a login shell it sources ~/.bash_profile
    otherwise it will try ~/.profile and if that one is not available
    ~/.bashrc. This explains why @hamstu https://github.com/hamstu's
    example is functioning ๐Ÿ˜„

More information on this loading behaviour can be found here
http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup

By default when creating a new tab it will load your default login shell
using --login provided here
https://github.com/zeit/hyperterm/blob/master/app/config-default.js#L61.

Tested this in Hyperterm and Terminal.app. Could you provide some more
insights in how you're using it? Thanks ๐Ÿ‘

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/zeit/hyperterm/issues/699#issuecomment-251504429, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIi0zNKxN4lz7akbMNDO7l-zWXqjWBoks5qwrfzgaJpZM4J4tEy
.

echo $0
-bash

On Tue, Oct 4, 2016 at 4:50 PM, Rich Jones [email protected] wrote:

Bash is my default shell. This is just a normal OSX install.

On Tue, Oct 4, 2016 at 4:32 PM, Tim Neutkens [email protected]
wrote:

Hi @Miserlou https://github.com/Miserlou, I did some researching into
this, think I found the issue. Is bash your default terminal, or are you
using something like zsh and executing /bin/bash after you're in zsh?

Basically what happens when you run bash is:

  • It doesn't start a login shell. For that you have to use bash
    --login
  • Only when your shell is a login shell it sources ~/.bash_profile
    otherwise it will try ~/.profile and if that one is not available
    ~/.bashrc. This explains why @hamstu https://github.com/hamstu's
    example is functioning ๐Ÿ˜„

More information on this loading behaviour can be found here
http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup

By default when creating a new tab it will load your default login shell
using --login provided here
https://github.com/zeit/hyperterm/blob/master/app/config-default.js#L61
.

Tested this in Hyperterm and Terminal.app. Could you provide some more
insights in how you're using it? Thanks ๐Ÿ‘

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/zeit/hyperterm/issues/699#issuecomment-251504429,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAIi0zNKxN4lz7akbMNDO7l-zWXqjWBoks5qwrfzgaJpZM4J4tEy
.

Could you try to add /bin/bash to the ~/.hyperterm.js config section:
shell: '/bin/bash'

That's how i've tried to reproduce having it as default shell.

Sent from my phone

On 4 Oct 2016, at 22:50, Rich Jones [email protected] wrote:

Bash is my default shell. This is just a normal OSX install.

On Tue, Oct 4, 2016 at 4:32 PM, Tim Neutkens [email protected]
wrote:

Hi @Miserlou https://github.com/Miserlou, I did some researching into
this, think I found the issue. Is bash your default terminal, or are you
using something like zsh and executing /bin/bash after you're in zsh?

Basically what happens when you run bash is:

  • It doesn't start a login shell. For that you have to use bash --login
  • Only when your shell is a login shell it sources ~/.bash_profile
    otherwise it will try ~/.profile and if that one is not available
    ~/.bashrc. This explains why @hamstu https://github.com/hamstu's
    example is functioning ๐Ÿ˜„

More information on this loading behaviour can be found here
http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup

By default when creating a new tab it will load your default login shell
using --login provided here
https://github.com/zeit/hyperterm/blob/master/app/config-default.js#L61.

Tested this in Hyperterm and Terminal.app. Could you provide some more
insights in how you're using it? Thanks ๐Ÿ‘

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/zeit/hyperterm/issues/699#issuecomment-251504429, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIi0zNKxN4lz7akbMNDO7l-zWXqjWBoks5qwrfzgaJpZM4J4tEy
.

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

Yeah, that does fix it. I'd either change that default to bash or respect
the default shell in the default Terminal app on OSX for empty strings, or
look at how they're ordered in /etc/shells

On Tue, Oct 4, 2016 at 4:56 PM, Tim Neutkens [email protected]
wrote:

Could you try to add /bin/bash to the ~/.hyperterm.js config section:
shell: '/bin/bash'

That's how i've tried to reproduce having it as default shell.

Sent from my phone

On 4 Oct 2016, at 22:50, Rich Jones [email protected] wrote:

Bash is my default shell. This is just a normal OSX install.

On Tue, Oct 4, 2016 at 4:32 PM, Tim Neutkens [email protected]
wrote:

Hi @Miserlou https://github.com/Miserlou, I did some researching
into
this, think I found the issue. Is bash your default terminal, or are
you
using something like zsh and executing /bin/bash after you're in zsh?

Basically what happens when you run bash is:

  • It doesn't start a login shell. For that you have to use bash --login
  • Only when your shell is a login shell it sources ~/.bash_profile
    otherwise it will try ~/.profile and if that one is not available
    ~/.bashrc. This explains why @hamstu https://github.com/hamstu's
    example is functioning ๐Ÿ˜„

More information on this loading behaviour can be found here
http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup

By default when creating a new tab it will load your default login
shell
using --login provided here
config-default.js#L61>.

Tested this in Hyperterm and Terminal.app. Could you provide some more
insights in how you're using it? Thanks ๐Ÿ‘

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/zeit/hyperterm/issues/699#issuecomment-251504429,
or mute
the thread
auth/AAIi0zNKxN4lz7akbMNDO7l-zWXqjWBoks5qwrfzgaJpZM4J4tEy>
.

โ€”
You are receiving this because you commented.

Reply to this email directly, view it on GitHub, or mute the thread.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/zeit/hyperterm/issues/699#issuecomment-251511077, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIi05QW7RZpu2mcHkYMTQdeR54Qrrqvks5qwr2XgaJpZM4J4tEy
.

Will have a look at the code again this evening ๐Ÿ‘

I can't reproduce. This is my test suite:

$ cat .bashrc
echo bashrc
$ cat .bash_profile
echo bash_profile
$ echo $SHELL
/bin/bash

If your $SHELL isn't bash, chsh -s /bin/bash and restart the whole user session so that the shell change is applied.

Now, I'm on Debian Linux so here's what I get with different terminals:

  • gnome-terminal: only bashrc is loaded. I'm not using any specific setting to choose the shell, so it appears that it's starting without a login shell.
  • hyper terminal: only bash_profile is loaded. So I don't get the same result as you.

So double check that you have the proper shell set up in /etc/passwd:
grep $USER /etc/passwd | cut -d':' -f7.

If that does indeed return the proper bash shell, I see two possible problems:

  • The default shellArgs are not correct. This is what I have in the hyper.js file:

js shellArgs: ['--login']`

Maybe that has a different value.

  • The returned shell by default-shell is wrong. I seriously doubt that because I get the right output and it has been severely tested. But you can test it yourself. Make and cd into a test folder and run:

$ npm install default-shell $ node -e 'console.log(require("default-shell"))'

  • If neither of those things is right, it's possible that a plugin is changing either the shell or shellArgs values: see this line where config is being decorated by plugins. If that's the case, maybe you can comment all plugins and get the proper behavior, and then later on comment one by one to find the culprit.

It's not sourcing my .bashrc like what normally happens with the Teriminal application. I tried setting the path to bash directly in the shell setting, but that didn't help. I tried removing the entire shellArgs option, but that didn't help. Is there at least a workaround to manually source a file upon starting Hyper? I'm using the Solus OS.

Same happening here, running in Ubuntu 16.10. Please let me know if you need more data.

Updated to 1.3.3 and the problem persists.
Added this line to .hyper.js file under config object but no profile is loaded anyway.
shell: '/bin/bash',

If I do open the Ubuntu's default terminal, the config is loaded correctly.
If I do open a new tab inside Hyper and run source ~/.profile, the configuration is loaded correctly inside Hyper.

To tag on, I noticed this for contents of .profile as well. Bash is my current login shell, but when I installed hyper.app originally, I was using fish. Not sure if switching shells would trigger any different behavior.

In my case, I only had two lines in .profile (for nvm) so I moved them to .bash_profile

For me, it works in interactive mode.

shellArgs: ['-i']

I'm very new to powershell. I've been borrowing a laptop from my company for less than a week, and that encompasses my entire experience with windows. However, I may have found a solution that works (at least for me).

(inspired by https://superuser.com/questions/1090141/does-powershell-have-any-sort-of-bashrc-equivalent)

In PowerShell:

New-Item $profile -Type File -Force

It creates a file called Microsoft.PowerShell_profile.ps1 in a folder called WindowsPowerShell under your Documents folder. Then you can open it with a text editor:

notepad $profile

Add $bash = [bash | . ~/.bash_profile] to that file

Now when I execute bash in powershell:

I type env in bash, and all of the local variables in my bash_profile are present.

Hope this is useful.

I'm on Ubuntu 18.04.1 using hyper 2.1.0 and bash and am seeing the same issue. I have tried explicitly specifying /bin/bash as the shell and tried using ['--login', '-i'] for command line arguments, and still my alias ls='ls --color=auto' in ~/.bashrc that comes from Ubuntu isn't applied. I'm happy to provide additional details.

OK, for my case, I resolved by _just_ using ['-i'] for the shell args, since apparently ~/.bashrc isn't read for login shells.

Hey, I'm having problem of Hyper not sourcing my ~/.bashrc file as well on Mac OS High Sierra.

The issue on OSX is that ~/.bashrc is not loaded in a logged in terminal (by default, hyper starts bash with --login which you probably want to use to get your user vars).

Information that enables this answer:

Been there, done that. What I came aware of, OS X doesn't read .bashrc file on bash start. Instead, it reads the following files (in the following order):

/etc/profile
~/.bash_profile
~/.bash_login
~/.profile

See also Chris Johnsen's informative and useful comment:

By default, Terminal starts the shell via /usr/bin/login, which makes the shell a login shell. On every platform (not just Mac OS X) bash does not use .bashrc for login shells (only /etc/profile and the first of .bash_profile, .bash_login, .profile that exists and is readable). This is why "put source ~/.bashrc in your .bash_profile" is standard advice

(Source: https://apple.stackexchange.com/a/13019)

Therefore, I resolved this issue by leaving the default shellArgs value (['--login']) and adding the following line to the end of my ~/.bash_profile:

source ~/.bashrc

Hyper then picked up commands in my ~/.bashrc.

(If this answer applies to more than just OSX, please let me/others know!)

from the comments it seems to fixed by adding --login to shellArgs

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eoinmurray picture eoinmurray  ยท  3Comments

legomushroom picture legomushroom  ยท  3Comments

leo picture leo  ยท  3Comments

hxnt picture hxnt  ยท  3Comments

juicygoose picture juicygoose  ยท  3Comments