How do I install libv8 gem? I can't install libv8 gem. When I try, I get the below error.
$ gem install libv8
Building native extensions. This could take a while...
ERROR: Error installing libv8:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
creating Makefile
Using compiler: /usr/bin/g++
which: no gmake in (/usr/local/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/system32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn/VSShell/Common7/IDE:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/c/Program Files/Heroku/bin:/cygdrive/c/Program Files/ruby-1.9.2/bin:/cygdrive/c/Program Files/git/bin:/cygdrive/c/Program Files/git/cmd:/cygdrive/c/Program Files/DTN/IQFeed:/cygdrive/c/Program Files/OpenVPN/bin:/cygdrive/c/Program Files/Java/apache-ant-1.8.3/bin:/usr/lib/lapack:/cygdrive/c/Program Files/Notepad++:.:/cygdrive/c/Program Files/Java/android-sdk/platform-tools/:/cygdrive/c/Program Files/Java/android-sdk/tools/:/cygdrive/c/Program Files/Java/jdk1.7.0_03/bin)
In file included from ../src/conversions-inl.h:42:0,
from ../src/conversions.cc:32:
../src/platform.h:77:12: error: new declaration ‘int random()’
/usr/include/cygwin/stdlib.h:29:6: error: ambiguates old declaration ‘long int random()’
make[1]: *** [/usr/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.13/vendor/v8/out/ia32.release/obj.target/preparser_lib/src/conversions.o] Error 1
I tried to use
$ gem install libv8 --pre
Fetching: libv8-3.5.10.beta1.gem (100%)
Building native extensions. This could take a while...
Successfully installed libv8-3.5.10.beta1
1 gem installed
But bundle install still would not run. It still tried to install version 3.11.8.13.
Installing libv8 (3.11.8.13) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
libv8 gem is not in my Gemfile. I don't know how to find out what is trying to use it, but while searching I saw that rubyracer uses libv8 and I do have
group :assets do
gem 'therubyracer', :platform => :ruby
I even tried to edit the /usr/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.13/src/platform.h file and comment out line 77:
//int random();
But when I ran gem install libv8, it overwrote my changes and still gave an error. I saw a trick in gem install libv8 --help, so I edited the file again and commented out line 77, and tried
cd /usr/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.13/vendor/v8
make
However, that just gave different errors:
In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/winsock2.h:56:0,
from ../src/win32-headers.h:77,
from ../src/platform-win32.cc:31:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/psdk_inc/_fd_types.h:100:2: warning: #warning "fd_set and associated macros have been defined in sys/types. This can cause runtime problems with W32 sockets"
In file included from ../src/win32-headers.h:80:0,
from ../src/platform-win32.cc:31:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../include/w32api/wspiapi.h:26:41: error: expected ‘>’ before numeric constant
../src/platform-win32.cc: In function ‘int random()’:
../src/platform-win32.cc:122:12: error: new declaration ‘int random()’
/usr/include/cygwin/stdlib.h:29:6: error: ambiguates old declaration ‘long int random()’
I feel like there should be an answer for people who just want the error to go away so they can get on with learning rails.
It seems that you don't need 'therubyracer' specifically -- you can choose some other javascript engine.
Specifically, open the file Gemfile, and change 'therubyracer' to 'therubyrhino'. (If rhino doesn't work, there are more options and advice at: https://github.com/sstephenson/execjs#readme
Since your question mentioned Cygwin, I assume you are Windows user. Currently, there's no way to install therubyracer or libv8 in Windows as said by its maintainer: therubyracer gem on windows. Windows is not Rails land unfortunately.
If you do need libv8, you can try nodejs instead. It comes with a binary, handy for all platform.
I've just hit the very same problem on my Win7 dev machine. It looks like installing https://github.com/hiranpeiris/therubyracer_for_windows and adding gem 'therubyracer' to the Gemfile sorts things out.
Before:
$ rails generate
c:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'
(...)
This basically means that Rails needs rubyracer and therefore libv8.
After:
$ rails generate
SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
This poses a security threat. It is strongly recommended that you
provide a secret to prevent exploits that may be possible from crafted
cookies. This will not be supported in future versions of Rack, and
future versions will even invalidate your existing user cookies.
Called from: c:/Ruby193/lib/ruby/gems/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.
Usage: rails generate GENERATOR [args] [options]
(...)
Related
I'm trying to install the puma gem, but when I run
gem install puma
I get this error message:
Temporarily enhancing PATH to include DevKit
Building native extensions. This could take a while...
ERROR: Error installing puma:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
generating puma_http11-i386-mingw32.def
compiling http11_parser.c
ext/http11/http11_parser.rl: In function 'puma_parser_execute':
ext/http11/http11_parser.rl:111:3: warning: comparison between signed and unsigned integer expressions
compiling io_buffer.c
io_buffer.c: In function 'buf_to_str':
io_buffer.c:119:3: warning: pointer targets in passing argument 1 of 'rb_str_new' differ in signedness
c:/Ruby193/include/ruby-1.9.1/ruby/intern.h:653:7: note: expected 'const char *' but argument is of type 'uint8_t *'
compiling mini_ssl.c
In file included from mini_ssl.c:3:0:
c:/Ruby193/include/ruby-1.9.1/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"
mini_ssl.c:4:25: fatal error: openssl/bio.h: No such file or directory
compilation terminated.
make: *** [mini_ssl.o] Error 1
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/puma-2.6.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/puma-2.6.0/ext/puma_http11/gem_make.out
Adding gem 'puma' to my Gemfile and running bundle install isn't an option, because that just doesn't work with any gem and gives me an error message (which is a separate issue, one that I've circumvented with the other gems I've used by installing them via gem install).
Came across very same issue.
sudo apt-get install libssl-dev
fixed it for me.
I ran bundle update before bundle install and that solved the issue for me.
I'm not sure if that was the only thing that helped, as I manually updated puma before that, using these steps:
Checked which version of openssl Ruby is using by running ruby -v -ropenssl -e "puts OpenSSL::OPENSSL_VERSION"
Downloaded the right openssl version from
http://packages.openknapsack.org/openssl/openssl-1.0.0o-x86-windows.tar.lzma
(got the link from https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows and edited it based on the output of #1).
Extracted openssl using http://www.7-zip.org to C:\RailsInstaller\openssl
gem install puma -- --with-opt-dir=C:/RailsInstaller/openssl
Figured out the solution to the puma bundle. Followed directions from https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows
First you need to download:
DevKit compatible with your ruby version
OpenSSL Developer Package (contains header files and binaries)
And then:
Install DevKit, e.g. in c:\devkit
Unpack the OpenSSL Package, e.g. in c:\openssl (use 7Zip or PeaZip)
You need to copy the ddls from the bin directory (libeay32.dll and ssleay32.dll) to your ruby/bin directory.
Open a windows console
Initialize the DevKit build environment: c:\devkit\devkitvars.bat (except here, I used this in command prompt instead: ruby dk.rb init)
Now it’s possible to install the puma gem with the OpenSSL packages:
gem install puma -- --with-opt-dir=c:\openssl
I think you hit issue #430
https://github.com/puma/puma/issues/430
Re-installing Ruby might help you as well as it closed this issue on GitHub.
I am attempting to update Rails from 3.1.3 to 3.2.8. Changing the rails gem value and running "bundle update rails" tries to install a gem called "termios" version 0.9.4, and this fails with the following message:
Installing termios (0.9.4) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/me/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
checking for termios.h... yes
checking for unistd.h... yes
creating Makefile
make
compiling termios.c
In file included from termios.c:10:
/Users/me/.rvm/rubies/ruby-1.9.3-p0/include/ruby-1.9.1/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"
termios.c: In function ‘Termios_to_termios’:
termios.c:182: error: ‘struct RArray’ has no member named ‘ptr’
termios.c:183: error: ‘struct RArray’ has no member named ‘ptr’
termios.c: In function ‘termios_tcgetattr’:
termios.c:200: error: ‘OpenFile’ undeclared (first use in this function)
make: *** [termios.o] Error 1
Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.9.3-p0#mcp5/gems/termios-0.9.4 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-1.9.3-p0#mcp5/gems/termios-0.9.4/./gem_make.out
An error occured while installing termios (0.9.4), and Bundler cannot continue.
Make sure that `gem install termios -v '0.9.4'` succeeds before bundling.
Please note also that this is the first time that I have updated Rails since I have gone to OS X Mountain Lion.
I have seen another answer about this question that said to install a gem called "ruby-termios". I did that, and that gem installed fine, but there is still a dependency somewhere that tries to install the "termios" gem.
I ended up cloning the ruby-termios gem into my repo. For some unknown reason, the author named it ruby-termios instead of just termios. So I renamed the gemspec. Then I modified my Gemfile to use:
gem 'termios', :path => 'termios'
Then I ran:
bundle update
And everything is working again.
It seems that specifying gem 'engineyard' in your Gemfile will cause bundler to install some ancient version (0.2.x), which has the termios dependency.
Specifying a newer one (gem 'engineyard', '~> 2.3') will install correctly.
gem install ruby-termios solved the make issues for me; I expect gem "ruby-termios" in your Gemfile will work too.
Looks like what happened is that the original author of the gem named termios (arika) hasn't updated the gem since 2004 (v 0.9.4), but nobody owns the namespace on rubygems http://rubygems.org/gems/termios. Then someone else (edison) made a fork on github https://github.com/edison/ruby-termios, and someone else (tylerrick) pushed a new gem named ruby-termios... but of course inside Ruby, the library is still named termios so the command is still require "termios".
I am new to ruby on rails, I am trying to get my first project working with git and heroku. I am following the tutorial by Michael Hartl. I was originally trying to
git push heroku master
but I dont have a GemFile.lock, so I have been trying bundle installs and bundle updates but nothing works because I dont have the json native gem.
bundle update
this is the command that reuturned this error, its not the whole error i left out all the gems i already have
Installing json (1.7.3) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
"C:/Program Files/ruby-1.9.3/bin/ruby.exe" extconf.rb
creating Makefile
make
Makefile:160: warning: overriding commands for target `C:/Program'
Makefile:153: warning: ignoring old commands for target `C:/Program'
C:/Program Files/ruby-1.9.3/bin/ruby -e "puts 'EXPORTS', 'Init_parser'" > parser-i386
mingw32.def
/bin/sh: C:/Program: No such file or directory
make: *** [parser-i386-mingw32.def] Error 127
Gem files will remain installed in C:/Program Files/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.3 f
or inspection.
Results logged to C:/Program Files/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
An error occured while installing json (1.7.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.3'` succeeds before bundling.
If anybody knows how to fix my error so that i can move onto the next one or how i can get a working GemFile.lock, it would be appreciated.
Install json_pure instead on your development machine. This is a version of the json gem that does not require C-extensions (but is a bit slower).
On Heroku you should be able to go with the faster json directly.
If you want to build the C-extension on windows then you might want to look here:
The 'json' native gem requires installed build tools
You can create a windows-specific section in the Gemfile like so:
# Common gems
gem 'xyz'
...
# Platform specific gems
platforms :ruby do
gem 'json'
end
platforms :mswin, :mingw do
gem 'json_pure'
end
Windows isn't properly escaping the space in "C:\Program Files". I haven't used Windows in a while, but a quick search reveals a few fixes.
I had the same problem and found that in my config.yaml file, there was an installation of Ruby 1.9.2 that had a space in it. I had to uninstall that version of Ruby entirely, and remove it from the PATH in environment variables. Then, I re-installed the DevKit and it worked perfectly.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Rails 3.1 and Ruby 1.9.3p125: ruby-debug19 still crashes with “Symbol not found: _ruby_threadptr_data_type”
I'm done with printing to the console -- I want to move up to the 20th century and start using a debugger!! But how do I install ruby-debug? The native compilation of ruby-debug.c fails when I try to install the ruby-debug19 gem. I've looked over other SO postings and haven't found the answer yet...
I am using Ruby 1.9.3-p0
I am using Rails 3.2 (with Gemfile, of course)
I am NOT using RVM -- instead, I have a fully sandboxed directory containing all executables, gems, sources, etc. I refer to it as $SANDBOX below...
bundle install doesn't work
If I add ruby-debug19 to my Gemfile and do bundle install, it fails during build with conflicting types for 'rb_iseq_compile_with_option':
# file: Gemfile
...
group :development do
gem 'ruby-debug19'
end
...
% bundle install
...
Installing ruby-debug-base19 (0.11.25) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/r/Developer/Topaz/usr/bin/ruby extconf.rb
...
ruby_debug.c:29: error: conflicting types for 'rb_iseq_compile_with_option'
$SANDBOX/usr/include/ruby-1.9.1/ruby-1.9.3-p0/vm_core.h:505: error: previous declaration of 'rb_iseq_compile_with_option' was here
...
make: *** [ruby_debug.o] Error 1
gem install ruby-debug from the command line doesn't work
If I try building the gem from the command line, using the --with-ruby-include argument pointing at the include directory for the current ruby, I get the same error:
% gem install ruby-debug19 -- --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug19:
ERROR: Failed to build gem native extension.
$SANDBOX/usr/bin/ruby extconf.rb --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0/include
checking for rb_method_entry_t.body in method.h... no
checking for vm_core.h... yes
checking for iseq.h... yes
checking for insns.inc... yes
checking for insns_info.inc... yes
checking for eval_intern.h... yes
creating Makefile
make
compiling breakpoint.c
compiling ruby_debug.c
ruby_debug.c:29: error: conflicting types for 'rb_iseq_compile_with_option'
$SANDBOX/usr/include/ruby-1.9.1/ruby-1.9.3-p0/vm_core.h:505: error: previous declaration of 'rb_iseq_compile_with_option' was here
what am I missing?
Is --with-ruby-include expecting something different? Is the current ruby-debug19 broken?
Thanks to #Marc Talbot's comment in the OP, I found a working recipe.
download linecache19 and ruby-debug-base19 from RubyForge:
% curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
% curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
compile the two gems
% gem install linecache19-0.5.13.gem
Building native extensions. This could take a while...
Successfully installed linecache19-0.5.13
1 gem installed
...
% gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$SANDBOX/packages/ruby-1.9.3-p0
Building native extensions. This could take a while...
Successfully installed ruby-debug-base19-0.11.26
1 gem installed
...
update your Gemfile
# file: Gemfile
...
group :development do
gem 'linecache19', '0.5.13'
gem 'ruby-debug-base19', '0.11.26'
gem 'ruby-debug19', :require => 'ruby-debug'
end
bundle install and test the debugger
% bundle install
Fetching source index for http://rubygems.org/
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
% irb
irb(main):001:0> require 'ruby-debug'
=> true
irb(main):002:0> debugger
$SANDBOX/usr/lib/ruby/1.9.1/irb/context.rb:166
#last_value = value
(rdb:1) p 'hooray'
"hooray"
Hopefully this will help others.
(From your logs, I assume you are on Linux, specifically a Debian distro)
There is a simple solution to this:
In the shell,
sudo apt-get install ruby-dev1.9.3
Note: I don't actually know if there is a package called ruby-dev1.9.3, because I installed ruby-dev for 1.9.2, which was ruby-dev1.9 (I think. That was a while ago. If anyone knows what they are, please comment).
This package installs the headers that the C extensions to the interpreter need (ruby.h).
I'm using Ruby on rails (RubyMine) and I try starting my project.
Which tells me the error "Could not find gem 'mysql2 (~> 0.2.6, runtime)' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound)".
I've done sudo gem install mysql which gives me
"Error installing mysql:
ERROR: Failed to build gem native extension.
Gem files will remain installed in /var/lib/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /var/lib/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
"
What should I do?
You're probably missing the development headers for MySQL. Often this is shipped as an optional package to install. You may need to install mysql-dev or mysql-devel depending on your package manager.
You might also be missing a compiler, so check that you have the required dependencies for gem such as make and gcc.
You might be missing the Ruby development headers as well. On my Ubuntu 11.04 box I have the following aptitude package which is needed for native gem compilation:
ruby1.9.1-dev