sqllint installation fails for pre-commit
damngamerz opened this issue · 4 comments
pre-commit log below:
version information
pre-commit version: 2.17.0
git --version: git version 2.17.1
sys.version:
3.9.5 (default, Dec 1 2021, 10:34:33)
[GCC 7.5.0]
sys.executable: /home/saurav/.pyenv/versions/3.9.5/bin/python3.9
os.name: posix
sys.platform: linux
error information
An unexpected error has occurred: CalledProcessError: command: ('/home/saurav/.rvm/rubies/ruby-3.0.0-cruby/bin/ruby', '/home/saurav/.rvm/rubies/ruby-3.0.0-cruby/bin/gem', 'build', 'sqlint.gemspec')
return code: 1
expected return code: 0
stdout: (none)
stderr:
Invalid gemspec in [sqlint.gemspec]: cannot load such file -- pg_query
ERROR: Error loading gemspec. Aborting.
Traceback (most recent call last):
File "/home/saurav/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pre_commit/error_handler.py", line 70, in error_handler
yield
File "/home/saurav/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pre_commit/main.py", line 396, in main
return run(args.config, store, args)
File "/home/saurav/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pre_commit/commands/run.py", line 416, in run
install_hook_envs(to_install, store)
File "/home/saurav/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pre_commit/repository.py", line 224, in install_hook_envs
_hook_install(hook)
File "/home/saurav/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pre_commit/repository.py", line 82, in _hook_install
lang.install_environment(
File "/home/saurav/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pre_commit/languages/ruby.py", line 132, in install_environment
helpers.run_setup_cmd(
File "/home/saurav/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pre_commit/languages/helpers.py", line 52, in run_setup_cmd
cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
File "/home/saurav/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pre_commit/util.py", line 154, in cmd_output_b
raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/home/saurav/.rvm/rubies/ruby-3.0.0-cruby/bin/ruby', '/home/saurav/.rvm/rubies/ruby-3.0.0-cruby/bin/gem', 'build', 'sqlint.gemspec')
return code: 1
expected return code: 0
stdout: (none)
stderr:
Invalid gemspec in [sqlint.gemspec]: cannot load such file -- pg_query
ERROR: Error loading gemspec. Aborting.
I have also tried with different ruby versions. 2.6.5 as mentioned in the .ruby_version
file. Can you help me?
Also this is how my pre-commit-config looks like
- repo: https://github.com/purcell/sqlint
rev: 0.2.1
hooks:
- id: sqlint
name: SQL linting
I don't know anything about pre-commit
, but it seems to be running an RVM-installed Ruby that does not have the pg_query
gem installed. That gem is a dependency for sqlint
, which is what the error indicates.
Hey Thanks for the answer. I was able to pinpoint the issue. Apparently rvm-installed ruby gave this env error for me.
https://stackoverflow.com/questions/18276701/getting-warning-path-is-not-properly-set-up-when-doing-rvm-use-2-0-0-defaul
rvm reset
rvm get stable --
rvm @global do gem install pg_query
I followed this to fix it. Will leave this here for anyone else looking. Can be closed.
Another option would be to just gem install sqlint
directly and stop trying to get sqlint
magically from pre-commit
using its Ruby support.