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

scss-lint fails

Open shawnacscott opened this issue 10 years ago • 13 comments

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:  []

shawnacscott avatar Dec 31 '14 01:12 shawnacscott

are you using version manager like rvm or chruby?

mpapis avatar Dec 31 '14 01:12 mpapis

I do use chruby.

On Tue, Dec 30, 2014, 5:09 PM Michal Papis [email protected] 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.

shawnacscott avatar Jan 02 '15 16:01 shawnacscott

@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?

mpapis avatar Jan 03 '15 10:01 mpapis

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?

postmodern avatar Jan 03 '15 10:01 postmodern

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

mpapis avatar Jan 03 '15 14:01 mpapis

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

postmodern avatar Jan 04 '15 23:01 postmodern

what would be the flow for chruby to do that?

mpapis avatar Jan 04 '15 23:01 mpapis

chruby system
sudo gem install scss-lint
# scss-lint should now be accessible to git and cron

postmodern avatar Jan 04 '15 23:01 postmodern

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

mpapis avatar Jan 05 '15 00:01 mpapis

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.

postmodern avatar Jan 05 '15 00:01 postmodern

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..."?

mpapis avatar Jan 05 '15 00:01 mpapis

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.

postmodern avatar Jan 05 '15 00:01 postmodern

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

mpapis avatar Jan 05 '15 00:01 mpapis