Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eddgrant
Copy link

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

@m1foley
Copy link
Owner

m1foley commented May 29, 2017

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?

@eddgrant
Copy link
Author

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.

@m1foley
Copy link
Owner

m1foley commented May 31, 2017

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.

@eddgrant
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants