fit-commit icon indicating copy to clipboard operation
fit-commit copied to clipboard

Detect and initialise Rubymine to support running within non-interactive shells

Open eddgrant opened this issue 8 years ago • 4 comments

Acceptance Criteria:

As a user of rbenv
When I commit via something other than an interactive shell (i.e. from RubyMine)
Then I want fit-commit to work normally

I discovered that fit-commit will fail to find Ruby when Ruby is installed via rbenv and the commit hook is triggered by something other than an interactive shell e.g. from an IDE. It seems in this case rbenv is not initialised (presumably because there is no shell initialisation performed).

I'm not very familiar with fit-commit (I've just started working on a project which was already using it) so there may be some things I haven't considered. Thought I'd offer this as a conversation starter though.

Cheers!

Edd

eddgrant avatar May 24 '17 14:05 eddgrant

Thanks. I don't use RubyMine so I'm unfamiliar with this problem. Are you aware of any other Git hook projects that take this same approach? I just checked pre-commit and it does not.

Also, I believe that installing rbenv adds that same init line to your .bash_profile. Do editors like RubyMine not pick that up?

m1foley avatar May 29 '17 03:05 m1foley

Hey, thanks for getting back to me.

rbenv doesn't modify any of the profile/ shell scripts itself, but you're right that its advice is to add the init line to the appropriate script for the user's system (depending on which shell they use):

Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
Ubuntu Desktop note: Modify your ~/.bashrc instead of ~/.bash_profile.

Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.

I personally use zsh and I have that line in my ~/.zshrc file. zsh itself works fine in an interactive shell yet the problem I describe is still present in RubyMine etc. I think this may be because shell initialisation scripts (~/.zshrc, ~/.bash_profile, ~/.bashrc etc) are only executed when an interactive shell is started. I'm not sure what influences whether something like pre-commit runs in an interactive shell or not but it seems that, when run in RubyMine at least, these files are not executed.

eddgrant avatar May 30 '17 12:05 eddgrant

It looks like people are having the same problem with Overcommit and RubyMine. If you're still interested in getting this working, can you read the links below and see if you can figure out the proper configuration? If you do I'll document it in the README. Running rbenv init in a git hook doesn't seem right to me.

  • https://www.jetbrains.com/help/ruby/2017.1/rbenv-support.html
  • https://youtrack.jetbrains.com/issue/RUBY-17869
  • https://intellij-support.jetbrains.com/hc/en-us/community/posts/207089245-Overcommit-support-

m1foley avatar May 31 '17 03:05 m1foley

Sorry for the delay in replying, have been away for a couple of weeks. Will have a look at the docs, sure.

eddgrant avatar Jun 13 '17 16:06 eddgrant