Ruby geoip_city on Windows - ruby-on-rails

Is there a way to get geoip_city, the Ruby gem, running on Windows?

Have you read the documentation?? I found the following instructions there:
Install
Some variation of the following should work.
Install the GeoCity C library. You can get it from here www.maxmind.com/app/c For example, I like to install mine in /opt/GeoIP so I do this:
tar -zxvf GeoIP-1.4.3.tar.gz
cd GeoIP-1.4.3
./configure --prefix=/opt/GeoIP
make && sudo make install
Now install the geoip_city gem
sudo gem install geoip_city -- --with-geoip-dir=/opt/GeoIP
Download the GeoLite City database file in binary format from: www.maxmind.com/app/geolitecity Maybe this direct link will work: www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz I put this file in /opt/GeoIP/share/GeoIP/GeoLiteCity.dat
Use it!
On Windows, the gem installs like any other gem:
gem install geoip_city -- --with-geoip-dir=/opt/GeoIP
Just make sure that ruby\bin directory is in your path or you run the above command from the ruby\bin directory.
But the required MaxMind library and database takes a little more work. You will need an application that can uncompress tar.gz files such as 7zip. The link to the MaxMind library specifically mentions Windows installation instructions are contained in the archive.
The database is just a binary file, so once you've uncompressed it you're good to go.

Related

Cannot install ruby on rails because ruby installer cannot find openssl

I'm trying to install Ruby 2.6.3 from source for ruby on rails on WSL. Here are the steps I'm taking:
First I check the location of openssl using
type -a openssl
and I get
openssl is /usr/bin/openssl
so in the ruby src directory I run
./configure --with-openssl-dir=/usr/bin
Then I run make
But I get this message somewhere during the make process:
openssl:
Could not be configured. It will not be installed.
/mnt/c/Users/MyUserName/Desktop/ruby-2.6.3/ext/openssl/extconf.rb:97: OpenSSL library could not be found. You might want to use --with-openssl-dir=<dir> option to specify the prefix where OpenSSL is installed.
Check ext/openssl/mkmf.log for more details.
Regardless of this warning, I run in the rails src directory the following:
gem install rails
and get the error:
`require': cannot load such file -- openssl (LoadError)
I was having the same issue. It's not enough to run configure with the correct directory and make again, you have to delete the files that have already been built. I just deleted the build directory and re-extracted from the tar, make clean probably would have worked too.

How to solve 'libcurl' not found with Rails on Windows

This is giving me a headache. I'm continuing a Rails project that started on Linux and I keep getting this when I run Puma on Ruby Mine:
Error:[rake --tasks] DL is deprecated, please use Fiddle
rake aborted!
LoadError: Could not open library 'libcurl': The specified module could not be found.
Could not open library 'libcurl.dll': The specified module could not be found.
Could not open library 'libcurl.so.4': The specified module could not be found.
Could not open library 'libcurl.so.4.dll': The specified module could not be found.
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/ffi-1.9.14-x86-mingw32/lib/ffi/library.rb:147:in `block in ffi_lib'
[...]
Now, what have I tried?
I installed Puma successfully on Windows following this steps
I downloaded curl-7.50.1-win32-mingw and put it on "C:/curl"
I added C:/curl/bin and C:/curl/include to PATH
I installed successfully curb gem with gem install curb --platform=ruby -- --with-curl-lib=C:/curl/bin --with-curl-include=C:/curl/include
I put the .dll files in Ruby bin folder, installed the certificate in curl/bin and even run the curl.exe just in case.
I rebooted the machine but I keep seeing the same error.
I do not know what to do. How to successfully install libcurl on Windows for use with Rails
Answer that worked for me (W10/Ruby2.6.0) was:
Download cURL from the following URL: https://curl.haxx.se/windows/ (I chose 64bit because that's the system I'm using)
Go into the archive and browse to /bin
Locate libcurl_x64.dll (it may be just libcurl.dll)
Extract to your local drive
Rename it to libcurl.dll if it has the _x64 suffix
Cut + paste the file into the /bin directory of your Ruby installation
I just had the same problem on Windows 7 x64 and answered about it here. (Similar to you, I tried a lot of things that I thought should work but didn't.)
What worked was:
To take a libcurl.dll from one of the packages found here, https://curl.haxx.se/download.html#Win64, and put it on the PATH.
(Link was updated, but originally pointed to version 7.40)
I just put it under \ruby24\bin\
Maybe for you it's C:\Ruby24-x64\bin
(Here are things I tried that didn't work:)
Putting on the PATH: the cygcurl-4.dll obtained from the current Curl Download Wizard
Renaming the above cygcurl-4.dll to libcurl.dlland putting it on the PATH
Installing the msys2 package libcurl-devel 7.57.0-1
Renaming the msys-curl-4.dll (from msys2 found at msys64\usr\bin) to libcurl.dll
I didn't try building curl / libcurl from the latest source because I already have the latest according to pacman -Ss libcurl:
msys/libcurl 7.57.0-1 (libraries) [installed]
Multi-protocol file transfer library (runtime)
msys/libcurl-devel 7.57.0-1 (development) [installed]
Libcurl headers and libraries
More details about this in these other questions:
jekyll serve dependency error - Could not open 'lib curl'
Typhoeus Windows installation
Rails Typhoeus Curl Trouble
how to install libcurl on windows 7 64bit
I had the same issue and tried the same steps that OP has listed. After breaking my head, cursing the existence of windows for some time and almost convincing the client to shift to a nix server I figured the libcurl.dll that I downloaded from https://curl.haxx.se/ (as suggested in all related posts) was corrupt.
Downloaded the one provided here http://www.dlldownloader.com/libcurl-dll/ and viola the ffi was able to load this one.
Hope this helps anyone else facing this issue
For anyone running Ruby 2.5 on Windows, my solution was similar to the top solutions however I had to move it to place the file in both the \bin folder and \bin\ruby_builtin_dlls folder to work.
Some other things is that I downloaded the 64bit version and changed its name to libcurl.dll. Also make sure to restart your IDE/terminal and then try to start the server again.
None of the solutions worked for me - no matter what I tried, libcurl failed to load.
I then did the following:
Created a mini Ruby program that just tried loading the dll:
require 'ffi'
FFI::DynamicLibrary.open("libcurl", FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL)
Ran procmon and filtered by ruby.exe process and any path containing "dll"
As a result, I saw the following:
C:\Ruby27-x64\bin\libzstd.dll - NAME NOT FOUND
That gave me an idea that I was missing a dependency. The libzstd.dll file is part of the mingw-w64-x86_64-zstd package but luckily I just had it sitting on my drive elsewhere (as part of the GIMP installation).
I copied libzstd.dll to C:\Ruby27-x64\bin and the problem was solved. Of course, I had libcurl.dll in my path already (got it from https://curl.haxx.se/windows)
I want to use wpscan, but i get libcurl error
OK, if you also get the same error, then in a very easy way I will try to give the solution.
Just copy the libcurl.dll file to system32 if your windows is 32 bit,
If your windows 64 bit copied to syswo64.
Good luck.
Well, the issue is caused by a missing lib as said in the error, So the solution is to download the lib here: http://www.dlldownloader.com/libcurl-dll/ and navigate to the ruby folder under bin and drop it there make sure to rename the downloaded .dll file to this exact one: libcurl.dll else won't work even after.
The solution which worked for me was download the dll, keep the exact name libcurl.dll and copy it to c:\windows\system32
If you're using WSL on Windows 10 (Make sure to update to Ubuntu 16.04) the following instructions worked perfectly for me. You might need to completely wipe what you have installed however.
Within bash:
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev postgresql-client-common postgresql-client libpq-dev
And then to build our path and plugin directory for rbenv:
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
Finally we come to ruby:
rbenv install 2.4.1
rbenv global 2.4.1
Then bundler:
gem install bundler
rbenv rehash
Now our prerequisites:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
And then finally Rails:
gem install rails
rbenv rehash

Install wkhtmltopdf in a Mac in order to be used by imgkit gem in RoR

I am trying to use IMGKit gem.
So I need to install wkhtmtopdf software.
The following command doesn't work: sudo imgkit --install-wkhtmltoimage , so I am trying to install it manually.
I downloaded two versions for Mac: one is a .i386 file and the other are 4 .dylib files.
How can I install any of them?
Why they dont have a normal installer?
.i386 file can be copied directly to /usr/local/bin and I had to make it executable chmod u+x NAMEOFTHEFILE.i386
You may want to give Homebrew a gander. It simplifies the process of installing many tools and libraries on OSX.

Trouble installing mysql2 gem, libmysqlclient.so.15 Load Error

veHi,
I'm trying to install Rails 3.0 with Ruby 1.9.2. on a Linux box. I'm behind a firewall and do not have root access on my machine so I'm trying to build everything in my home directory. I don't have access to apt-get or yum - I have to build everything from source (except for gems).
I've successfully compiled and built Ruby, Rails, and MySQL. My problem is that rails can't find the libmysqlclient.so.15 library. I've tried every conceivable option to "gem install mysql2" to tell it where the library is, with no luck. Note that if I have the local mysql/lib directory in my LD_LIBRARY_PATH, everything works. I just can't figure out how to tell mysql2 where the library is. Can someone help?
Thanks,
Stan McFarland
I'm sure you must also install the mysql-dev packages.
The file libmysqlclient_r.so.15 is in the mysql shared-compat package. The example below is using a specific mirror and it's for 32 bit generic linux. You can find the right package for your platform at http://dev.mysql.com/downloads/mysql/
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/MySQL-shared-compat-5.5.13-1.linux2.6.i386.rpm/from/http://mysql.mirrors.pair.com/
$ yum install --nogpgcheck MySQL-shared-compat-5.5.13-1.linux2.6.i386.rpm
That default installation path is the same that the mysql2 gem used.
On OS X, I know I always have to update the library location in the gem manually. That same trick should work fine on linux. Adjust names and paths to match your platform:
$ sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib ~/.rvm/rubies/ruby-1.8.6-p399/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle

sudo gem install rails- this doesn't give me a rails command for bash

I'm on Ubuntu. I type in sudo gem install rails. This works fine, installs railes and 7 other gems fine. Yet $ rails blog is saying this:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Type
gem env
It will give you the installable directory where the bins of the gems are being installed. Something like this:
EXECUTABLE DIRECTORY: /usr/bin
Make sure this directory is in your path.
how did you install rubygems, as an admin, or as a user? if you installed it as a user, it may not have the bin directory in your path.
If I were you, (assuming you installed rubygems into your home folder), I would trash that installation dir (not sure where it defaults to, maybe ~/rubygems? or ~/.rubygems?), then run setup.rb from the rubygems tarball as admin (through sudo) I've done this at least a dozen times on ubuntu, and haven't run into the issue you are hitting.
If that isn't the case, could you please link to the blog post you were following?
Make sure your gem executable path is added to your system path so that the system can find the rails executable.
I know this is an old thread but the same error had me stuck. Make sure you add
source ~/.rvm/scripts/rvm to your .bashrc file

Resources