How to solve 'libcurl' not found with Rails on Windows - ruby-on-rails

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

Related

Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib

When I try running rails console I get this error:
/Users/TuzsNewMacBook/.rvm/gems/ruby-2.3.7/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require':
dlopen(/Users/TuzsNewMacBook/.rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/x86_64-darwin18/readline.bundle, 9):
Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
A quick search got me to this post and I've tried a few things:
brew reinstall postgresql (this is indeed the DB for this project)
and
cd /usr/local/opt/readline/lib
ln libreadline.8.0.dylib libreadline.6.2.dylib
(my version of readline is 8)
and
brew link readline --force
But none of these have fixed it.
I recently added pry-coolline, guard and guard-livereload gems to my project if that makes any difference (rails console loaded fine before those). I'm running on the latest macos.
(Update) I’m using pry rails as my rails console, if that makes any difference.
Any help? Thanks.
the error seems to be thrown when searching for /usr/local/opt/readline/lib/libreadline.7.dylib.
Have you tried to symlink that?
So something like:
cd /usr/local/opt/readline/lib
ln -s libreadline.8.0.dylib libreadline.7.dylib
Just tried that on macOS Mojave, ruby 2.5.3p105 and Rails 5.2.2 and worked.
Reinstalling my Ruby version seems to have fixed it:
rvm reinstall 2.3.7
can you try
cd /usr/local/opt/readline/lib
ln -s libreadline.8.dylib libreadline.7.dylib
you are on the right track but it seems like rails is looking for libreadline.7.dylib and libreadline.7.dylib is not there in the folder.
Yes, the best answer is to reinstall.
You can get the version easily by typing:
ruby -v
With rbenv, the command is i.e.:
rbenv install 2.3.7
with rvm:
rvm reinstall 2.3.7
A very simple solution that doesn't involve rebuilding your RVM gemset OR sym-linking libraries.
Add to your Gemfile:
gem 'rb-readline'
If you are doing bundler groups
group :development do
gem 'rb-readline'
end
Then run
> bundle
Let me know if that doesn't work.
Most often in Ruby-applications, this is caused by gems that have extensions (the gems saying "Building native extensions.."), that are built using a specific version of, in this case, readline.
Basically, there are two solutions:
Either, you can symlink version 8 of the gem, to the version missing. This will work in many cases, but if backwards compatibility is broken, it will not.
Or, if the gem actually supports version 8, you can reinstall that specific gem, or "pristine" it by running gem pristine --all.
EDIT: In scope of your "what I've tried", reinstalling PostgreSQL, is also one of the binaries, built using a specific version, that may also require a rebuild, to work with a system library, such as readline.
Got this issue:
dyld: Library not loaded: /usr/local/opt/mpfr/lib/libmpfr.4.dylib
doing...
cd /usr/local/opt/mpfr/lib/
ln -s libmpfr.dylib libmpfr.4.dylib
did the trick for me for macOS Catalina
Background: This has happened when I tried to install tig, but I think this is a common issue that you may have that you need to manually link the installed software into the right path that another software wants.
If you can not find readline installed on your Mac, you should run
brew install readline
After you installed deadline, brew will ask you to link it. But actually you can not link by running
brew link readline
Even you can not link by running
sudo brew link readline
Mac OS will warn you this is extremely dangerous and stop you to do.
The Latest version of readline is version 8, so you will see the error message like
Library not loaded: /usr/local/opt/readline/lib/libreadline.8.dylib
The brew installed deadline at
/usr/local/Cellar/readline/8.0.4
So you have to manually link it to the place that your software wants by using command ls
ln -s /usr/local/Cellar/readline/8.0.4 /usr/local/opt/readline
Enjoy!
So Ive checked a few answers here but I dont think they can work with a vanilla Mojave mac install. Im using 10.14.4 while I did these:
get homebrew from https://brew.sh
$ brew install coreutils : this installs the gnu coreutils pkg for mac, we want the greadlink from this because macOSX's readlink is not the same as the gnu readlink. Its extremely confusing but such is the life in macland.
$ echo 'alias readlink=greadlink' >> ~/.bash_aliases I found macs readlink to be a bit lacking so I overrode the existing readlink by aliasing greadlink. (you can make this usable by all users by $ alias readlink=greadlink >> /etc/bashrc which will enable every user to be able to use it.
$ ln -s /usr/local/opt/readline/lib/libreadline.8.dylib /usr/local/opt/readline/lib/libreadline.7.dylib I linked the already linked .8. file instead of '.8.0.' file because if it were to get updated to .8.1. then my readlink wont break or miss features on the library. Im pretty sure we will format our macs before 9+ comes out.
I would recommend against manually symlink'ing native libraries. Aas of OS X 10.4, the standard include library path /usr/include is no longer used and is locked by SIP (making it difficult to move things to).
Apple ships a “legacy installer” for you to be able to install the headers in the “old location”, which will also resolve your path to correctly find headers installed via brew.
cp /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg ~/Desktop && open ~/Desktop/macOS_SDK_headers_for_macOS_10.14.pkg`
See here for a detailed write-up on what is going on.
My problem was just the same when running lftp.
Just running brew upgrade has solved my problem, as it has updated (among others):
readline 8.0.0_1 -> 8.0.1
lftp 4.8.4 -> 4.8.4_2

RVM hangs on 'Installing required packages' on Debian

I installed rvm on debian 7 using the command:
\curl -L https://get.rvm.io | bash -s stable --rails
from this article:
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-an-debian-7-0-wheezy-vps-using-rvm
I get this output:
Searching for binary rubies, this might take some time.
Found remote file https://rvm.io/binaries/debian/7/x86_64/ruby-2.1.0.tar.bz2
Checking requirements for debian.
Installing requirements for debian.
Updating system...
Installing required packages: gawk, g++, libreadline6-dev, zlib1g-dev, libssl-dev, libyaml-dev, libsqlite3-dev, sqlite3, autoconf, libgdbm-dev, libncurses5-dev, automake, libtool, bison, pkg-config, libffi-dev
It hangs here forever. I tried waiting about 30 min. I also tried hitting ctrl-c and running some rvm commands. rvm list known works fine, but rvm install gets me back to the same "installing requirements" and it hangs as well.
Any ideas? Googleing only seemed to bring up issues involving OSX (I'm using debian in a vbox in windows 8).
Would installing each required package indiviually via apt-get be the best move?
I faced the same issue. To resolve, just mount the installation CD that you used to install Debian and it will work.
I encountered the same issue with Debian 8. As it turns out, the installation was looking for the required packages on the Debian install CD-ROM, which wasn't inserted. To fix this, run the following command:
nano /etc/apt/sources.list
Then, comment out the line beginning with "cdrom" so that it looks like the following:
# cdrom:[Debian GNU/Linux...
You should be able to run sudo apt-get update then try installing rvm again. However, I restarted my laptop before doing so. Therefore, I can't give 100% confirmation that it works without restarting.
As i've written in comment, try installing requirements by hand, sometimes something wilk silently fail and cause such issues. As OP found, the gawk package was causing the issue.
Just remove the cdrom entry from the sources.list file. This can be done easily:
sudo sed -i '/cdrom/d' /etc/apt/sources.list
This should take care of the problem. The message is because somehow you still have the cdrom entry in your sources.list file, you can check the content of the file using:

Cannot connect PhantomJS and Poltergeist in Rails application

I've followed the instructions on Poltergeist github page but i keep getting an error that my PhantomJS version is wrong.
Specifically, it says:
Could not find an executable 'phantomjs' that matched the requirements '~> 1.8', '>= 1.8.1'. Found versions were {"/home/marko/projects/irs_machine/bin/phantomjs"=>"50"}.
Now, I have downloaded phantomjs v1.8.1 (and later v1.9.2) so the version is correct. This is really driving me crazy. I use Ubuntu 13.04, but I doubt that's the reason.
Googling for the error returns nothing of use.
Any ideas?
I've solved it!
What I found to be very strange was the fact that the error reported the phantomjs version to be "50" which is impossible.
I've tracked the error down to the "cliver" gem, a gem that detects versions of installed programs. It does so by regex matching the desired version string to the result of
{command} -v
Now, when I run phantomjs -v i get "1.8.1", so what was happening? On closer inspection "1.8.1" wasn't all that I was getting back! To be precise, I got this:
phantomjs -v
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.
1.8.1
I had a fontconf error, and sure enough, the first number it contained was "50". Cliver matches against standard output, so it couldn't get a proper version because the system was writing errors out.
Once I reconfigured the 50-user.conf not to use line 9, the error was gone and poltergeist started working as expected.
In my case, using apt-get to install PhantomJS was installing an older version of PhantomJS. I had to manually install PhantomJS by downloading the tarball, unpacking it, and creating links to the executable in /bin:
If you haven't already, remove the outdated version of PhantomJS you have installed.
Using apt-get, the command for me was sudo apt-get remove phantomjs.
Download the tarball from http://phantomjs.org/download.html.
(You can use, for example, wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 to download the x86 version of PhantomJS 1.9.7 from the command lineto the current working directory.)
Unpack the tarball in your home directory.
According to https://askubuntu.com/a/25962/168631, the command is tar xjf phantomjs-1.9.7-linux-x86_64.tar.bz2, depending on which version you downloaded.
Create symbolic links to the phantomjs executable in your /bin.
Following these instructions, I ran:
sudo ln -s <snip>/<unpacked_tarball>/bin/phantomjs /usr/local/share/phantomjs
sudo ln -s <snip>/<unpacked_tarball>/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -s <snip>/<unpacked_tarball>/bin/phantomjs /usr/bin/phantomjs
i also faced the same issue and resolved it by using the phantomjs gem ,which will install the phantomjs based on the platform you are working.
first remove the platform specific phantomjs ,so if you are using ubuntu
sudo apt-get --purge remove phantomjs
sudo rm /usr/bin/phantomjs
sudo ln -s /node_modules/phantomjs/lib/phantom/bin/phantomjs /usr/bin/phantomjs
Try to move phantomjs to your /bin directory.

Install RVM itself without internet connection

I am switching from DJANGO to Rails, but i don't know how to install RVM in PROD environment.
My PROD server is without internet connection, and not possible connect even for a while. And i cannot find a standalone install package of RVM.
Is there any solution for offline RVM installation?
BTW, can rails be installed without internet?
I just spent some time and build a tutorial for the offline mode: https://rvm.io/rvm/offline - it's the first version so feel free to improve it here: https://github.com/wayneeseguin/rvm-site/blob/master/content/rvm/offline.md (Edit button).
Additionally to my first answer another way to do it would be to compile ruby on online machine, then package it, unpack on the other end and add it to PATH on the offline machine.
Way 1 - only Ruby
curl -L https://get.rvm.io | bash -s stable
source $HOME/.rvm/scripts/rvm
rvm install 1.9.3 --movable
rvm prepare 1.9.3
Some information will be displayed, including file name. Copy it to the offline machine and unpack it there, then just add it to PATH:
echo 'PATH=$PATH:${unpacked_dir}/bin' >> ~/.bashrc
Way 2 - whole RVM:
curl -L https://get.rvm.io | sudo bash -s stable
source /usr/local/rvm/scripts/rvm
rvm use 1.9.3 --install
gem install rails -v 3.2.8
rails new rails3
rvm use 1.8.7 --install
gem install rails -v 2.3.14
rails new rails2
tar czf rvm_and_ruby.tgz /usr/local/rvm /etc/rvmrc /profile.d/rvm.sh
Unpack on the offline end:
cd /
sudo tar xzf rvm_and_ruby.tgz
And open a new terminal.
check http://railsinstaller.org/ (for windows and mac) .After then change environment into production mode . In linux this works export RAILS_ENV=production .
If you are using a linux OS, you can always package the app as a debian or rpm archive which will include rails and the dependent gems referred in your Gemfile. The advantage with this approach is that you can also configure the archive to setup external dependencies like any other deb or rpm package. One of my recent projects came up with a in house solution. Now there are tools like pkgr
You can download a standalone RVM package here: https://github.com/wayneeseguin/rvm/tags
You can reference the RVM installer script for details on what an RVM install does. Simply replace the network calls with references to some local file, and you should be good to go.
That said, once RVM is installed, I'm not sure if it'll let you do an offline Ruby install easily, but this should get you started.
Well you need to download the source code from somewhere to install RVM, Rails. Not very clear as to how your Prod environment lacks an internet connection. Could you please give more details?

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

Resources