Having trouble installing gem "termios" after trying to update Rails - ruby-on-rails

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".

Related

An error occurred while installing RedCloth (4.2.7), and Bundler cannot continue

I have an app on the Heroku Bamboo stack and have been following the instructions here (https://devcenter.heroku.com/articles/cedar-migration) for migrating to the Cedar stack.
My app has an older version of RefineryCMS (1.0.3) and I'm trying to avoid dealing with an upgrade there (for now), and so I've kept Rails at 3.0.9. Still, Ruby 1.8.7 is past EOL, so I needed to upgrade that at least. I specified 1.9.3 in my Gemfile, thus:
source "https://rubygems.org"
ruby "1.9.3"
And then I attempted to bundle install. Here's my output from that attempt:
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies....
Using rake 0.8.7
Installing RedCloth 4.2.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/day/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20151105-14593-x80q4a.rb extconf.rb
checking for main() in -lc... no
creating Makefile
make clean
make
compiling redcloth_attributes.c
ragel/redcloth_attributes.c.rl: In function 'redcloth_attribute_parser':
ragel/redcloth_attributes.c.rl:26:11: error: variable 'act' set but not used [-Werror=unused-but-set-variable]
ragel/redcloth_attributes.c.rl: In function 'redcloth_attributes':
ragel/redcloth_attributes.c.rl:45:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
ragel/redcloth_attributes.c.rl: In function 'redcloth_link_attributes':
ragel/redcloth_attributes.c.rl:54:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
cc1: all warnings being treated as errors
make: *** [redcloth_attributes.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/day/.rvm/gems/ruby-1.9.3-p551/gems/RedCloth-4.2.7 for inspection.
Results logged to /Users/day/.rvm/gems/ruby-1.9.3-p551/extensions/x86_64-darwin-14/1.9.1/RedCloth-4.2.7/gem_make.out
An error occurred while installing RedCloth (4.2.7), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.7'` succeeds before bundling.
Needless to say gem install RedCloth -v '4.2.7' resulted in the same error.
I found this question, Failed to build gem native extension when install RedCloth-4.2.9 install Linux, however, my issue was with RedCloth 4.2.7 (not 4.2.9) and I'm running OSX Yosemite (not Linux). There was an answer there which pertained to OSX Mountain Lion though, and I thought it was worth a try:
rvm --force install 1.9.2
gem install bundle --no-ri --no-rdoc
bundle install
Obviously, I changed 1.9.2 to 1.9.3 for my purposes, and I omitted the --no-ri --no-rdoc flags. Sadly, bundle install continued to fail with the same error.
Continuing my search online, I found this article, Install RedCloth 4.2.7 gem with bundler (using ruby enterprise edition 1.8.7). Not dissuaded by the version mismatch (again, I'm using Ruby 1.9.3, not 1.8.7), I decided to try the advice I found there, to wit:
bundle config build.RedCloth --with-cflags=-w
bundle install
This time, oh joy! it worked! And I'm on to whatever's next. I thought I would share this little journey here for any others who find themselves in the same predicament. Cheers!
I was able to resolve this issue by specifying extra build options for Bundler which are applied when building RedCloth, as follows:
bundle config build.RedCloth --with-cflags=-w
bundle install

event machine gem bundle install is not working

I am following a tutorial and had to do a bundle install following the forking & cloning of a repository. Subsequently we are instructed to run bundle install. However, it is not working and I am getting the following error message:
make
generating rubyeventmachine-i386-mingw32.def
compiling binder.cpp
In file included from binder.cpp:20:0:
project.h:85:0: warning: "FD_SETSIZE" redefined
<command-line>:0:0: note: this is the location of the previous definition
compiling cmain.cpp
In file included from cmain.cpp:20:0:
project.h:85:0: warning: "FD_SETSIZE" redefined
<command-line>:0:0: note: this is the location of the previous definition
cmain.cpp: In function 'int evma_send_file_data_to_connection(long unsigned int,
const char*)':
cmain.cpp:752:6: error: 'fstati64' was not declared in this scope
make: *** [cmain.o] Error 1
Gem files will remain installed in c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0
.0/gems/eventmachine-0.12.10 for inspection.
Results logged to c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/eventmach
ine-0.12.10/ext/gem_make.out
An error occurred while installing eventmachine (0.12.10), and Bundler cannot
continue.
Make sure that `gem install eventmachine -v '0.12.10'` succeeds before bundling.
I'm rather stuck on what to do at this point. I am on a Windows machine, any advice on how to troubleshoot this?
Try gem install eventmachine -v '0.12.10' Or sudo gem install eventmachine -v '0.12.10' and then retry bundle install.
Some gem needs sudo privileges to install.
For windows gem install eventmachine --pre. Its a known issue for window with ruby 1.9. https://github.com/eventmachine/eventmachine/issues/319
I was able to fix this by installing the latest version of the Eventmachine gem: https://rubygems.org/gems/eventmachine
And then subsequently instaling the latest version of the SQLite gem:
http://rubygems.org/gems/sqlite3-ruby
You might be prompted to update your Gemlockfile make sure to do that then everything else should work.

bundle throwing error Gem::Installer::ExtensionBuildError: ERROR: with Mavericks and ruby 2.0

Getting the below error when i run bundle from a 1.8.7 app. I just upgraded to Mavericks and am using rbenv.
Things I've tried already:
1) uninstall and reinstall rbenv and ruby-build
2) dropped the directory and re-cloned
3) installing x-code cli with xcode-select --install
4) brew install apple-gcc42
5) deleting the root ruby file (2.0) and replacing with 1.8
6) brew unlink apple-gcc42
None of the above have worked yet.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for re.h... no
creating Makefile
make "DESTDIR="
compiling parser.c
parser.rl:165:20: error: expected '(' after 'if'
if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:445:18: note: expanded from macro 'RTEST'
#define RTEST(v) !(((VALUE)(v) & ~Qnil) == 0)
^
1 error generated.
make: *** [parser.o] Error 1
Gem files will remain installed in /Users/ryan/C2/c2/vendor/bundle/gems/json-1.4.6 for inspection.
Results logged to /Users/ryan/C2/c2/vendor/bundle/gems/json-1.4.6/ext/json/ext/parser/gem_make.out
An error occurred while installing json (1.4.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.4.6'` succeeds before bundling.
I just got something similar when I changed an old Ruby 1.9.3 project to Ruby 2.2.0 and tried to bundle.
I got errors like parser.rl:139:20: error: expected '(' after 'if'" and " and accept.c:128:2: error: use of undeclared identifier 'TRAP_BEG'.
The fix was to upgrade the gems that failed to build: bundle update json kgio in my case, where the json gem and then the kgio gem failed to build.
If you've locked down the versions of a problematic gem in your Gemfile, you might want to unlock them, too. E.g. change gem "json", "1.1.6" to just gem "json". Though you should of course make sure you know why it was locked down in the first place.
When you just do bundle, it tries to install/build the gem versions listed in Gemfile.lock. Those will be the versions you installed previously on Ruby 1.8.7 in your case, or 1.9.3 in my case. I guess those gem versions are old enough that they simply don't compile for a newer Ruby.

Can't install libv8 gem on Cygwin

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]
(...)

how do I install ruby-debug in ruby 1.9.3 / Rails 3.2.1 [duplicate]

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).

Resources