cannot bundle install nokogiri error RoR tutorial - ruby-on-rails

I am learning RoR for the first time and I am stuck on this part of the tutorial
http://www.railstutorial.org/book/static_pages#sec-first_tests
Specifically in the beginning where I am supposed to configure this gem file. I know there are other more up to date versions out but I am trying to follow the tutorial with this specific version. My gemfile is the same as the one displayed in the link.
When I run: bundle install --without production I get:
Bundler could not find compatible versions for gem "sprockets-rails":
In snapshot (Gemfile.lock):
sprockets-rails (2.1.3)
In Gemfile:
rails (= 4.0.5) ruby depends on
sprockets-rails (~> 2.0.0) ruby
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
I tried bundle update but I get:
An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
I tried gem install nokogiri -v '1.6.1' but get:
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/bradfordli/.rvm/rubies/ruby-2.0.0-p481/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
-----
libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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.

Related

Bundle update mini_racer is updating rails even though it is not supposed to?

I've had the same mini_racer update problem that others have had, but the common recommendations aren't working for me.
Getting the following errors when running bundle install with mini_racer 0.2.0 in my gemfile...
2 warnings generated.
linking shared-object mini_racer_extension.bundle
clang: warning: libstdc++ is deprecated; move to libc++ [-
Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: *** [mini_racer_extension.bundle] Error 1
make failed, exit code 2
An error occurred while installing mini_racer (0.2.0), and Bundler
cannot continue.
Make sure that `gem install mini_racer -v '0.2.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
mini_racer
I am trying to just update mini_racer with
bundle update mini_racer
but then when I run bundle install, I'm getting a new (and more alarming) error...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (~> 5.1.4) was resolved to 5.1.6, which depends on
bundler (>= 1.3.0)
render_async was resolved to 2.0.0, which depends on
bundler (~> 1.8)
Current Bundler version:
bundler (2.0.1)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (~> 1.8)', which is required by gem
'rails (~>
5.1.4)', in any of the sources.
What should I be doing to update mini_racer without updating dependencies? (at least i think that is what is happening)
Your first failure is due to a missing dependency with mini racer. The key in that error message is:
library not found for -lstdc++
You need to install gcc. If you're using Homebrew, you can run brew install gcc
The reason that rails was getting screwed up, is because when you ran the bundle update command it looks like it was updating everything, including dependencies. I believe there is a bundler flag to force it to only update the gems you selected, but that still won't help you because you're missing the dependencies needed by mini racer.
After you install gcc, just run bundle install. That should install mini racer without error.
The bundler error, as I noted, was due to a recent update to bundler. I've locked to 1.17.3 for the time being because I haven't had luck working around that error message.
Figured out a workaround.
The issue was that heroku doesn't support bundler 2.0 and above, and if we updated mini_racer it was updating bundler so in order to make mini_racer and heroku happy, we updated mini_racer in the gemfile and specified the most recent version, and then we always use
gem install bundler --version 1.16.4
until heroku supports a more recent bundler version.

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

Cannot install sqlite3 -v '1.3.9' on Mac

I just started to learn Ruby on Rails by following some tutorials. Rails had been working well until one day it just stopped working. The code following is what I got from the Terminal when I tried to run rails:
$ rails -v
Looks like your app's ./bin/rails is a stub that was generated by Bundler.
In Rails 4, your app's bin/ directory contains executables that are versioned
like any other source code, rather than stubs that are generated on demand.
Here's how to upgrade:
bundle config --delete bin # Turn off Bundler's stub generator
rake rails:update:bin # Use the new Rails 4 executables
git add bin # Add bin/ to source control
You may need to remove bin/ from your .gitignore as well.
When you install a gem whose executable you want to use in your app,
generate it and add it to source control:
bundle binstubs some-gem-name
git add bin/new-executable
WARN: Unresolved specs during Gem::Specification.reset:
i18n (>= 0.6.9, ~> 0.6)
json (>= 1.7.7, ~> 1.7)
tzinfo (~> 1.1)
minitest (~> 5.1)
thread_safe (~> 0.1)
rake (>= 0.8.7)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Could not find sqlite3-1.3.9 in any of the sources
Run `bundle install` to install missing gems.
So I ran bundle install and gem install sqlite3-1.3.9 but neither of them worked. The code following is from the Terminal when I ran gem install sqlite3-1.3.9:
$ sudo gem install sqlite3 -v '1.3.9'
Password:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing. Try 'port install sqlite3 +universal',
'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).
*** 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.
But when I tried 'port install sqlite3 +universal', 'yum install sqlite-devel' and 'apt-get install libsqlite3-dev', the terminal showed:
$ apt-get install libsqlite3-dev
-bash: apt-get: command not found
Command is not found even for yum and port. Some people said that I should install ruby-dev package and possibly the libsqlite3-dev (Ubuntu) or sqlite-devel (Fedora) package as well, but I don't know how to do it. What should I do? Should I reinstall Ruby and Rails? Thank you very much!!!

RMagick error installing Redmine on Windows

I'm trying to upgrade my Redmine installation to the latest.
I updated ruby, rails, and gem as required.
current trunk | ruby 1.8.7, 1.9.2, 1.9.3, jruby-1.6.7 | Rails 3.2.6 | RubyGems <= 1.8
Issuing the rake db:migrate command it gives me the following error:
C:\ruby-apps\RedMine>rake db:migrate RAILS_ENV=production
←[31mCould not find gem 'rmagick (>= 2.0.0) x86-mingw32' in the gems available on this machine.←[0m
←[33mRun bundle install to install missing gems.←[0m
So I installed rmagick for win32 and listing installed gems I see :
...
railties (3.2.6)
rake (0.9.2.2)
rdoc (3.12)
rmagick (2.12.0 mswin32)
ruby-openid (2.1.8)
rubygems-update (1.8.24)
...
But rake db:migrate still give me the same error, so I tried bundle install, but I get:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for stdint.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.
Any ideas on how to get out of this?
I ran into the same problem while installing redmine. According to a comment in the Gemfile rmagick optional and only used to export Gant graphs as PNGs. So if you do not need this specific feature you can run
bundle install --without development test rmagick
Actually Bitnami's Redmine windows Installer contains a solution to this problem.
Using it, for me is a valid solution to the problem.
The content of the installation may be used to inspect correct versions and dependencies to correctly build Redmine.

Ruby on Rails - can not install SystemTimer

I am using windows and I just ran the command:
C:\Sites\cmply>gem install SystemTimer -v '1.2.3'
and I got this error:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing SystemTimer:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
creating Makefile
make
generating system_timer_native-i386-mingw32.def
compiling system_timer_native.c
In file included from system_timer_native.c:8:0:
c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete
system_timer_native.c: In function 'install_first_timer_and_save_original_configuration':
any idea why? Prior to this I got another suspicious error:
Gem files will remain installed in C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/SystemTimer-1.2.3 for inspection.
Results logged to C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/SystemTimer-1.2.3/ext/system_timer/gem_make.out
An error occured while installing SystemTimer (1.2.3), and Bundler cannot continue.
Make sure that `gem install SystemTimer -v '1.2.3'` succeeds before bundling.
and prior to that I got another error that seemed to indicate that my Ruby version is somehow out of sync:
C:\Sites\cmply>bundle update rake
Updating git://github.com/twitter/twitter-text-rb.git
Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "activesupport":
In snapshot (Gemfile.lock):
activesupport (3.2.3)
In Gemfile:
rails (= 3.1.3) x86-mingw32 depends on
activesupport (= 3.1.3) x86-mingw32
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
So is it all rooted in me having an incompatible ruby version? How should this be solved?
Thanks!
You can't install system_timer gem with ruby 1.9, but it's not a bug, it's a feature. Here is the full explanation.
"system_timer is only relevant if you are running Ruby 1.8. You do not
need it if you are running Ruby 1.9"
If you're switching from Ruby 1.8 to 1.9, simply remove the system_time gem and update code dealing with timeouts.
Inspecting the output it says you're building for Ruby 1.9.3 with the include files of 1.9.1.
It looks like your Ruby installation is somehow broken. I would try to reinstall the Ruby 1.9.3 and check that the include files exist in c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.3/ and not in c:/RailsInstaller/Ruby1.9.3/include/ruby-1.9.1/.

Resources