Fail to install curb gem in windows7 - ruby-on-rails-4

curb gem fails to install.
I am using following configuration:-
Windows 7
Ruby 2
Rails 4
gem "bundler 1.3.5"
C:\RorProjects>gem install curb
Building native extensions. This could take a while...
ERROR: Error installing curb:
ERROR: Failed to build gem native extension.
C:\Users\abc>gem install curb
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while.....
ERROR: Error installing curb:
ERROR: Failed to build gem native extension.
C:/Rubyinstaller200/bin/ruby.exe extconf.rb
checking for curl-config... no
checking for main() in -lcurl... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Rubyinstaller200/bin/ruby
--with-curl-dir
--without-curl-dir
--with-curl-include
--without-curl-include=${curl-dir}/include
--with-curl-lib
--without-curl-lib=${curl-dir}/
--with-curllib
--without-curllib
extconf.rb:18:in `<main>': Can't find libcurl or curl/curl.h (RuntimeError)
Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
options to extconf.
Gem files will remain installed in C:/Rubyinstaller200/lib/ruby/gems/2.0.0/gems/
curb-0.8.4 for inspection.
Results logged to C:/Rubyinstaller200/lib/ruby/gems/2.0.0/gems/curb-0.8.4/ext/ge
m_make.out

Try installing mingw and run the command within it, I haven'T worked on windows for a while but it used to fix my gem install problems back then :
http://www.mingw.org/

You have to specify the paths to header files and the static library in order to build the extensions. First make sure you have the ruby devkit installed. Then download the x86 package (suffixed 'devel', it's the one that includes all the stuff), extract it somewhere and try gem install curb -- --with-curl-lib=c:/path/to/curl/lib --with-curl-include=c:/path/to/curl/include.
If this one doesn't work (for me it didn't when I tried to install curb with libcurl 7.32.0 and ruby 2.0), you can try downloading the x86 libcurl package here, follow the instruction in the first post to extract it, set up the environment and then run gem install curb -- -with-opt-dir=c:/path/to/libcurl. This got me curb 0.8.5 at the time of this post.

Related

SQLite in an AWS Lambda Ruby function

I am attempting to use SQLite within an AWS Lambda Ruby function, but having trouble with the sqlite3 gem. Has anyone been able to do this successfully?
I have a simple Gemfile:
source "https://rubygems.org"
gem "activerecord", "~> 7.0"
gem "sqlite3", "~> 1.4"
After a few false starts trying to run the function on Lambda itself, I looked at this question on Ruby gems with native extensions on AWS Lambda, so am trying to package dependencies using a Lambda-like Docker image. bundle install fails at the sqlite3 native extension step. When I try to install the gem by itself:
docker run --rm -v "$PWD":/var/task lambci/lambda:build-ruby2.7 gem install sqlite3
I see:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: /var/runtime/gems/sqlite3-1.4.2/ext/sqlite3
/var/lang/bin/ruby -I /var/lang/lib/ruby/site_ruby/2.7.0 -r ./siteconf20220430-1-n5ip9q.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'brew install sqlite3',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
The docs for the Docker image seem to indicate that sqlite-devel has been installed, though. When I ask which -a sqlite3, it says:
/usr/bin/sqlite3
/bin/sqlite3
When I try to build --with-sqlite3-dir=/bin/sqlite3 or --with-sqlite3-dir=/usr/bin/sqlite3:
Building native extensions with: '--with-sqlite3-dir=/bin/sqlite3'
This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: /var/runtime/gems/sqlite3-1.4.2/ext/sqlite3
/var/lang/bin/ruby -I /var/lang/lib/ruby/site_ruby/2.7.0 -r ./siteconf20220430-1-1rgbak9.rb extconf.rb --with-sqlite3-dir\=/bin/sqlite3
checking for sqlite3.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/var/lang/bin/$(RUBY_BASE_NAME)
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
/var/lang/lib/ruby/2.7.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /var/lang/lib/ruby/2.7.0/mkmf.rb:613:in `try_cpp'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:1177:in `block in find_header'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:971:in `block in checking_for'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:331:in `open'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:361:in `block in postpone'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:331:in `open'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:357:in `postpone'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:970:in `checking_for'
from /var/lang/lib/ruby/2.7.0/mkmf.rb:1176:in `find_header'
from extconf.rb:68:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/runtime/extensions/x86_64-linux/2.7.0/sqlite3-1.4.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/runtime/gems/sqlite3-1.4.2 for inspection.
Results logged to /var/runtime/extensions/x86_64-linux/2.7.0/sqlite3-1.4.2/gem_make.out
This is where I am stuck. I note the message:
/var/lang/lib/ruby/2.7.0/mkmf.rb:471:in 'try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
But not sure how to make headway on that. I'm also pretty new to Docker and have been having trouble trying to read mkmf.log; I am getting No such file or directory when I try to cat it.
I found some questions/answers that indicate people have gotten SQLite working with Node and Python Lambda functions, but I don't see any discussion of Ruby functions. I also found this layer for adding SQLite support in Python functions. But didn't find any such layer for Ruby.
Is a Ruby layer necessary, or is there something else I am missing? Thanks very much!

Cannot build gem native extension on El Capitan - fails at lstdc++

I've spent the past hour scouring the internet for any solution to this but so far have come up empty handed...
I'm trying to install a gem called taglib-ruby, which has a dependency on a c++ compiler (which one would assume is covered by gcc and Xcode Commandline Tools) and taglib (a C++ library) which I have installed using homebrew. However, it doesn't seem to get as far as trying to include that, because it fails to find lstdc++.
I'm trying to do this on OSX El Capitan (10.11).
Can someone tell me what this dependency is and how I install it?
Please see console output below:
$ gem install taglib-ruby
Building native extensions. This could take a while...
ERROR: Error installing taglib-ruby:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby -r ./siteconf20160618-66149-xswlyl.rb extconf.rb
checking for main() in -lstdc++... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
--with-tag-dir
--without-tag-dir
--with-tag-include
--without-tag-include=${tag-dir}/include
--with-tag-lib
--without-tag-lib=${tag-dir}/lib
--with-stdc++lib
--without-stdc++lib
/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/taglib-ruby-0.7.1/ext/extconf_common.rb:28:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from extconf.rb:2:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p194/gems/taglib-ruby-0.7.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p194/extensions/x86_64-darwin-11/1.9.1/taglib-ruby-0.7.1/gem_make.out
The error message has this in it:
/usr/local/rvm/rubies/ruby-1.9.3-p194/
That's a pretty old version of ruby. Use rvm to install a recent version of ruby:
$ rvm install 2.3.1
then try installing the gem again.
If you want to make that version of ruby the default when you open Terminal:
$ rvm --default use 2.3.1
Edit: Hmmm...on OSX 10.10.5, I was able to do $ brew install taglib and then successfully install the gem $ gem install taglib-ruby on both ruby-1.9.3-p194 and ruby-2.3.0. I have the full Xcode installed(Xcode 7.2.1). I wonder if your Xcode command line tools are as severely outdated as your ruby version? You can try:
$ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
to get the version of your Xcode command line tools.
You might need to update rvm, ruby, homebrew, and the Xcode command line tools.

ruby 2.0.0 and rails 4 requires ruby-debug-base19?

I have switched to ruby 2.0.0, rails 4 from rails 3, when i run the command bundle update rails i get this error
An error occurred while installing ruby-debug-base19 (0.11.25), and Bundler cannot continue.
Make sure that `gem install ruby-debug-base19 -v '0.11.25'` succeeds before bundling.
But when run gem install ruby-debug-base19 -v '0.11.25' i got that error:
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug-base19:
ERROR: Failed to build gem native extension.
/home/sunloverz/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... no
/home/sunloverz/.rvm/gems/ruby-2.0.0-p247#rails-4.0/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39:in `create_makefile_with_core': Use RbConfig instead of obsolete and deprecated Config.
/home/sunloverz/.rvm/gems/ruby-2.0.0-p247#rails-4.0/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39:in `create_makefile_with_core': Use RbConfig instead of obsolete and deprecated Config.
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/sunloverz/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
--with-ruby-dir
--without-ruby-dir
--with-ruby-include
--without-ruby-include=${ruby-dir}/include
--with-ruby-lib
--without-ruby-lib=${ruby-dir}/
/home/sunloverz/.rvm/gems/ruby-2.0.0-p247#rails-4.0/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:268:in `block (2 levels) in read': Looking for http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-2.0.0-p247.tar.gz and all I got was a 404! (URI::NotFoundError)
Substitute ruby-debug-base19 in your Gemfile with a Ruby 2.0 compatible debugger such as byebug and run the command again.

Puppet install gem fails but gem is installed anyways

I have a Puppet manifest that installs the Zurb Foundation gem:
class compass {
package { ["rubygems"]:
ensure => 'installed'
}
package { ['zurb-foundation']:
ensure => '3.0.6',
provider => 'gem',
require => Package['rubygems']
}
}
This causes the following error when running puppet apply:
err: /Stage[main]/Compass/Package[zurb-foundation]/ensure: change from absent to 3.0.6 failed: Could not update: Execution of '/usr/bin/gem install -v 3.0.6 --include-dependencies --no-rdoc --no-ri zurb-foundation' returned 1: INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Building native extensions. This could take a while...
ERROR: Error installing zurb-foundation:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:4:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/ffi-1.9.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/ffi-1.9.0/ext/ffi_c/gem_make.out
at /etc/puppet/manifests/classes/compass.pp:25
However, doing a gem list yields the following results:
# gem list
*** LOCAL GEMS ***
chunky_png (1.2.8)
compass (0.12.2)
fssm (0.2.10)
rake (10.1.0)
rb-fsevent (0.9.3)
sass (3.2.0.alpha.277)
zurb-foundation (3.0.6)
The error causes puppet apply to not complete properly, since a lot of items are skipped because of failed dependencies. What can I do?
I think that the problem is that you don't have the ruby dev kit installed for you ruby (that's what's used to build native extensions).
You'll want to add something like (it may be different depending on your version of ruby):
package { 'ruby-dev':
ensure => installed,
before => Package['zurb-foundation'],
}
This should allow the gem to be built properly and let your puppet run finish too.

Install ruby-opengl 0.60.1 on Ubuntu? ...in order to add 'gl', 'glu', and 'glut' extensions

How does one install ruby-opengl-0.60.1 on Ubuntu?
I keep trying
$ gem install ruby-opengl --version 0.60.1
and I am running into the following error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
ERROR: 'rake/gempackagetask' is obsolete and no longer supported. Use
'rubygems/package_task' instead.
/home/matias/.rvm/gems/ruby-1.9.3-p362#sampleGemset/gems/ruby-opengl-0.60.1/
Rakefile:24:in `<top (required)>'
Perhaps I could manually change the "package task" parameter in the Rakefile
and then attempt a local gem install?...
I have found the following urls where the package can be downloaded for manual installation:
rubyforge.org/frs/?group_id=2103
launchpad.net/ubuntu/+source/ruby-opengl/0.60.1+dfsg1-2
And the following appears to be a patch or a small modification:
gist.github.com/tociyuki/2479308
I tried downloading the gem from the launchpad url, and then I tried
$ gem install ruby-opengl-0.60.1.gem
from the Downloads folder, and it gave me a ton of errors.
I eventually tried:
$ sudo apt-get install libopengl-ruby
which seemed to work, and now when I do:
$ gem list -r ruby-opengl
I get:
\*** REMOTE GEMS \***
ruby-opengl (0.61.0, 0.60.0 i386-mswin32)
ruby-opengl2 (0.60.6)
I believe that i386-mswin32 is version 0.60.1 for windows.
With this configuration, I try running Sapphire.rb and it still doesn't work.
I already have ruby-opengl versions 0.60.0 and 0.61.0 installed, but I need 0.60.1 because it creates the 'gl', 'glu', and 'glut' extensions which are required in order to run some .rb files which I have copied from other people. These .rb files are video games created with the Gosu gem.
This is for use specifically with the Gosu gem. Even more specifically, I am trying to run the Sapphire game (github.com/KoBeWi/Sapphire), which also requires the Texplay gem.
Or is there another way to activate the 'gl', 'glu', and 'glut' extensions?
Thanks to the nice people at libgosu for providing the answer:
$ gem install opengl --pre
took care of everything! Now if someone else runs into this
same difficulty, the answer is here!