How to solve 'libcurl' not found with Rail

2020-01-31 03:15发布

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

7条回答
Bombasti
2楼-- · 2020-01-31 03:44

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
查看更多
登录 后发表回答