jish / pre-commit

A slightly improved pre-commit hook for git
https://jish.github.io/pre-commit/
Other
796 stars 96 forks source link

scss-lint fails #196

Open shawnacscott opened 9 years ago

shawnacscott commented 9 years ago

Any time I commit a scss file, pre-commit fails with this error:

pre-commit: Stopping commit because of errors.
sh: scss-lint: command not found

I am using pre-commit with a YAML configuration file like this:

:checks:    [common, rails, rspec_focus, pry, ruby_symbol_hashrockets, tabs, console_log, debugger, tabs, whitespace, merge_conflict, rubocop, scss_lint]
:warnings:  []
mpapis commented 9 years ago

are you using version manager like rvm or chruby?

shawnacscott commented 9 years ago

I do use chruby.

On Tue, Dec 30, 2014, 5:09 PM Michal Papis notifications@github.com wrote:

are you using version manager like rvm or chruby?

— Reply to this email directly or view it on GitHub https://github.com/jish/pre-commit/issues/196#issuecomment-68415952.

mpapis commented 9 years ago

@postmodern / @havenwood given https://github.com/jish/pre-commit/blob/master/templates/hooks/automatic I assume the command would be ~ sh -c ruby -rrubygems -rpre-commit -e "PreCommit.run" - question: how to identify which ruby would be run and install the missing gem(scss-lint) for it?

btw. if there is more to do to support chruby than just calling ruby in the subprocess, can you open a PR for the template?

postmodern commented 9 years ago

As @mpapis informed me, the command is being ran in a plain shell from git? As long as auto.sh gets loaded by the shell, auto-switching should take; before the first command for zsh and after the first command for bash. Maybe invoking sh -l ... would work?

mpapis commented 9 years ago

as discussed in irc sh -l is out of question as it would slow down every commit, maybe new template could be an option where the auto-switching is loaded and then call to ruby is made ... or maybe chruby could provide this script and our automatic template would use it

postmodern commented 9 years ago

Or since git does not preserve the current shell environment, maybe install scss-lint globally under system ruby?

mpapis commented 9 years ago

what would be the flow for chruby to do that?

postmodern commented 9 years ago
chruby system
sudo gem install scss-lint
# scss-lint should now be accessible to git and cron
mpapis commented 9 years ago

assuming there was a system ruby, this is complicated, is there a "default" ruby in chruby like it is in RVM?

postmodern commented 9 years ago

The default ruby is system ruby. You can configure a default ruby via the shell configuration or via .ruby-version. However, since git blows away the current environment, the default ruby may not be the user selected ruby.

mpapis commented 9 years ago

this sounds like nightmare, maybe we could promote an description/wiki that shows what to do, maybe selecting one ruby and setting it in git config --global pre-commit.ruby="chruby..."?

postmodern commented 9 years ago

It is not a nightmare to install a gem globally. system ruby exists for a reason. Don't fear the system ruby, don't fear your own system.

mpapis commented 9 years ago

assuming there is a system ruby, I know it's really common this days, but still not a base requirement for a linux system