Closed evdevdev closed 2 years ago
One additional note, I tried to update the proj-dir thinking that might the issue. No dice:
$ gem uninstall rgeo-proj4
Successfully uninstalled rgeo-proj4-3.0.1
$ gem install rgeo-proj4 -- --with-proj-dir=/opt/homebrew/bin
Building native extensions with: '--with-proj-dir=/opt/homebrew/bin'
This could take a while...
Successfully installed rgeo-proj4-3.0.1
Parsing documentation for rgeo-proj4-3.0.1
Installing ri documentation for rgeo-proj4-3.0.1
Done installing documentation for rgeo-proj4 after 0 seconds
1 gem installed
$ rails c
Running via Spring preloader in process 66424
Loading development environment (Rails 6.1.3.2)
3.0.1 :001 > RGeo::CoordSys::Proj4.supported?
=> false
Thanks for the details.
Currently the extension checks in these directories https://github.com/rgeo/rgeo-proj4/blob/ec70c88dd8a09bf20ca979764b4b00219f6581d3/ext/proj4_c_impl/extconf.rb#L15-L42
Do you happen to know where the proj.h
header is located since that's what needs to be found for the build process to work? In the past there's also been issues with the spring gem caching non-linked versions of the gem, so running spring stop
before rails c
will help make sure you don't accidentally use a bad install.
Thank you for getting back to me!
Sorry, I'm not sure where I would look for proj.h
. I tried the following find ~/ -type f -name "proj.h"
but got no results.
I am trying to infer it from the Homebrew recipe. But I can't really make heads or tails of it.
Is there any command I could run that would answer your question?
Updated to say:
I also tried spring stop
but no luck with that. (Also tried a few fancy combination with spring stop
+ reinstall + rails console)
You should try find / -type f -name 'proj.h'
since it is probably in the opt/homebrew/include
directory (or something like that). On Ubuntu for me it showed up in usr/include/proj.h
.
You can also try to run this script
require 'mkmf'
find_header('proj.h')
# or
find_header('proj.h', ['/opt/homebrew', '/opt/homebrew/include'])
and it will tell you if it finds the header in any of those. Just running find_header('proj.h')
should return false
, but adding the other paths might help us figure out where it is.
Hmm... I think we may be getting somewhere.
$ ls /opt/homebrew/include | grep proj.h
proj.h
Boom! There's our proj.h
However....
$ gem uninstall rgeo-proj4
Successfully uninstalled rgeo-proj4-3.0.1
$ gem install rgeo-proj4 -- --with-proj-dir=/opt/homebrew/include
Fetching rgeo-proj4-3.0.1.gem
Building native extensions with: '--with-proj-dir=/opt/homebrew/include'
This could take a while...
Successfully installed rgeo-proj4-3.0.1
Parsing documentation for rgeo-proj4-3.0.1
Installing ri documentation for rgeo-proj4-3.0.1
Done installing documentation for rgeo-proj4 after 0 seconds
1 gem installed
$ irb
3.0.1 :001 > require 'rgeo'
=> true
3.0.1 :002 > require 'rgeo/proj4'
=> true
3.0.1 :003 > RGeo::CoordSys::Proj4.supported?
=> false
3.0.1 :004 >
So it's still not working. Anything else I can do to help debug this?
I would try running that script I posted above since the find_header
command needs to work for it to install properly.
You might also try -- --with-proj-dir=/opt/homebrew/
since it may be looking for the prefix instead of the include
directory.
-- --with-proj-dir=/opt/homebrew/
Did the trick!
Thank you for all of your help on getting this running.
No problem. I'll keep this open for now since I should add the homebrew install paths to the default locations the extension checks.
I think maybe a new install path needs to be added for ubuntu as well...
apt-get install libproj-dev proj-bin
installs to /usr/bin
@zampetti sorry missed this notification.
When the gem builds, it relies on the proj.h
header file and the libproj
library. Is ubuntu installing proj.h
or libproj.so
into the /usr/bin
directory?
@keithdoggett Sorry to reopen, but I'm encountering the same issue on ruby:2.7.3 docker image (which is based on Debian).
root@7630b029eb8a:/app# gem install rgeo
Fetching rgeo-2.4.0.gem
Building native extensions. This could take a while...
Successfully installed rgeo-2.4.0
1 gem installed
root@7630b029eb8a:/app# gem install rgeo-proj4
Fetching rgeo-proj4-3.1.1.gem
Building native extensions. This could take a while...
Successfully installed rgeo-proj4-3.1.1
1 gem installed
So install successful. Then:
irb(main):005:0> find_header('proj.h')
checking for proj.h... yes
=> true
irb(main):006:0> RGeo::CoordSys::Proj4.supported?
=> false
proj.h is in /usr/include
libproj.so is at /usr/lib/x86_64-linux-gnu/libproj.so
What am I missing? I tried passing --with-proj-dir without success.
Found the issue.
It's fixed by using ruby:3.1.2
as docker base image.
ruby:2.7.3
ships with Debian 10.10, and when you install proj-bin you get the version 5.2.0.
On ruby:3.1.2
, you are on Debian 11.5, and you get proj 7.1.2. Which is then detected fine by Rgeo.
I guess what could be improved is a warning or a stricter version check at installation of rgeo-proj4.
@pcboy thanks for bringing that up. We do log when it's unsuccessful currently, but it goes to STDOUT which I guess is suppressed during gem installation. I might also have to change which functions are checked to ensure we've found a valid version of proj. We should probably handle it similarly to how the pg gem does and use STDERR instead (https://github.com/ged/ruby-pg/blob/499011b1be91469df8301a63817a3ff588017168/ext/extconf.rb#L116-L128).
RE: Raising if proj isn't found... I think in this case it makes sense because the gem is completely unusable if it's not able to compile proj vs RGeo core where there is still a lot of functionality without GEOS. What are your thoughts @BuonOmo?
Yep lets raise! As PG does actually
Hi there,
A helpful answer from @keithdoggett on stackoverflow pointed me to this library (thank you!).
I'm struggling to get the install working.
brew install proj
works as expected.I verified it with:
I added the following to my Gemfile
And install worked as expected.
However, when I try to create a factory I get the following error:
Digging under the hood a little, I found the following:
One possibility I thought of is that Homebrew isn't installing to the anticipated directory?
Do you have any idea what I might need to do to get this wired up?