purcell / sqlint

Simple SQL linter supporting ANSI and PostgreSQL syntaxes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checker definition probably flawed?

ReneFroger opened this issue · comments

I'm using Emacs 25.05 on Ubuntu 15.10. I tried to install sqlint, but it seems it's using Ruby. I got some error with installing:

gem install sqlint

It told me the following:

mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

I got it solved from this with the command:

sudo apt-get install ruby2.1-dev

Then proceed with

gem install sqlint

In Emacs, M-x flycheck-verify-setup confirmed this with this:

Syntax checkers for buffer test.sql in sql-mode:

sql-sqlint
    - predicate:  t
    - executable: Found at /usr/local/bin/sqlint

Flycheck Mode is enabled.

Then I typed some words, but I see an error:

Suspicious state from syntax checker sql-sqlint: Checker sql-sqlint returned non-zero exit code 1, but no errors from output: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require': cannot load such file -- sqlint (LoadError)
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /var/lib/gems/2.1.0/gems/sqlint-0.1.2/bin/sqlint:5:in `<top (required)>'
    from /usr/local/bin/sqlint:23:in `load'
    from /usr/local/bin/sqlint:23:in `<main>'

Checker definition probably flawed.

Googling around gave me no usable advice. How to proceed further? Any help would be appreciated, since I was trying to solving it on my own.

Hmm, not sure. It looks like the gem didn't get installed properly, but it's not immediately obvious what went wrong. Did you use "sudo gem install sqlint", or just "gem install sqlint", as you wrote above?

Yes, I did use sudo gem install sqlint.

Any update on this?

Not really sure how to reproduce this, currently, without spending a lot of time installing an ubuntu image in a VM. I'll do that if I can, but can't make promises. Our travis build for this project runs on Ubuntu, but it installs sqlint via rvm rather than using the system-wide ruby.

What happens when you run sqlint on the command line, outside Emacs? If that works, then the problem is related to your path or other environment variables inside Emacs.

Okay, so I set up a VM with 15.10 and found that I could reproduce this. I tracked it down to wrong file permissions inside the gem which rubygems was building for me on my machine, probably caused by having an explicit umask set.

I've published a 0.1.3 version of this gem which works for me on my VM -- please let me know if that doesn't solve the problem for you. Thanks for reporting this, and for your help. I'll go ahead close this issue in the meantime! :-)

Noticed you have updated the gem. But don't forget to update this repo too. :-)

Good catch, thx.

Is it possible that this has happened again? I'm getting

/usr/local/bin/sqlint:23:in `load': cannot load such file -- /var/lib/gems/2.3.0/gems/sqlint-0.1.5/bin/sqlint (LoadError)
	from /usr/local/bin/sqlint:23:in `<main>'

whenever I try to use sqlint.

The default permissions on all of the .rb in /var/lib/gems/2.3.0/gems/sqlint-0.1.5 files are rw for root, and nothing for anyone else, so I think it's a permission problem. I can get it working again by running sudo chmod -R guo+r /var/lib/gems/2.3.0/gems/sqlint-0.1.5.

(In case it's important I'm on Ubuntu 16.04, ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu], sqlint 0.1.5)

Is it possible that this has happened again?

Yes, I think so, sorry: I've added a build step to stop this happening again, and have pushed 0.1.6.

Great, thanks! 👍