An error occurred while installing ruby-opencv (0.0.14) - ruby-on-rails

I'm facing gem ruby-opencv installation issue
Gem files will remain installed in /home/k2/.rvm/gems/ruby-2.1.2#rails4/gems/ruby-opencv-0.0.14 for inspection.Results logged to /home/k2/.rvm/gems/ruby-2.1.2#rails4/extensions/x86_64-linux/2.1.0/ruby-opencv-0.0.14/gem_make.out
An error occurred while installing ruby-opencv (0.0.14), and Bundler cannot continue.
Make sure that `gem install ruby-opencv -v '0.0.14'` succeeds before bundling.
I tried below one also
gem install ruby-opencv -v '0.0.14'
ruby -v => 2.1.2

You need to download the opencv package from
https://github.com/Itseez/opencv/tree/master using,
git clone https://github.com/Itseez/opencv.git
or clicking on download button in that same page.
And install the above package using http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html
And then start to install the gem as below
gem install ruby-opencv -- --with-opencv-dir=/usr/local.
Now it will work.

Typically the Ruby opencv gem needs to compile native extensions, including the opencv tools, the sqlite database, the python language, openssl networking, and possibly access to your system's compiler such as gcc.
These extensions are generally easiest to diagnose by using sudo.
Try this if you can:
sudo gem install ruby-opencv -v '0.0.14'
Also, you may want to try changing from using rvm to using ruby-build.
Can you please edit your question, and add the results of the log file?
cat /home/k2/.rvm/gems/ruby-2.1.2#rails4/extensions/x86_64-linux/2.1.0/ruby-opencv-0.0.14/gem_make.out
Have you already installed OpenCV successfully on its own?
You can install OpenCV with these instructions: http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html
If you can install OpenCV, that may help verify you have most of the pieces you need for the Ruby gem.

Related

gem "mysql2" instalation errors

I have hard time to configure a dev environement for rails getting some errors
I have install ruby & rails with this tutorial https://parsun.com/2017/09/23/how-to-install-ruby-on-rails-on-raspberry-pi-3/
but i have some error when i launch a project
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.
i have tried to launch :
gem install mysql2
but i get that ...
https://pastebin.com/8CxsVzMQ
You need to install mysql first, the log contains
mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.
The documentation page of the mysql2 gem contains:
This gem links against MySQL's libmysqlclient library or Connector/C library, and compatible alternatives such as MariaDB. You may need to install a package such as libmysqlclient-dev, mysql-devel, or other appropriate package for your system. See below for system-specific instructions.
By default, the mysql2 gem will try to find a copy of MySQL in this order:
* Option --with-mysql-dir, if provided (see below).
* Option --with-mysql-config, if provided (see below).
* Several typical paths for mysql_config (default for the majority of users).
* The directory /usr/local.
Try to install mysql or the mentioned libs and try again to install the gem.
The messages do not seem to reflect reality, try this instead of the mentioned package:
sudo apt-get install default-libmysqlclient-dev
Then, your next error clearly shows what is wrong
/home/pi/.rvm/gems/ruby-2.6.3/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect': Could not find a JavaScript runtime. See github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
The GH page says:
ExecJS lets you run JavaScript code from Ruby. It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.
Install one of the javascript runtimes, listed here in the readme, e.g. nodejs (https://nodejs.org/en/download/), therubyracer, etc.

What is gem install bundler?

I know i can read it from http://bundler.io, but i have some doubts in my mind.
Is it like npm for NodeJs and Maven for Java/J2EE.
The first command i executed is gem install bundler. What is gem here and What is bundler, can some one enlighten me in terms of NodeJs or Maven.
Where these getting installed?. I don't specify -g like i do in
NodeJs for globally.
C:\Users\Shane>gem install bundler
Fetching: bundler-1.5.3.gem (100%)
Successfully installed bundler-1.5.3
Parsing documentation for bundler-1.5.3
Installing ri documentation for bundler-1.5.3
1 gem installed
C:\Users\Shane>gem install sqlite3
Fetching: sqlite3-1.3.9-x86-mingw32.gem (100%)
Successfully installed sqlite3-1.3.9-x86-mingw32
Parsing documentation for sqlite3-1.3.9-x86-mingw32
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/sqlite3/1.8/sql
tive.so, skipping
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/sqlite3/1.9/sql
tive.so, skipping
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/sqlite3/2.0/sql
tive.so, skipping
Installing ri documentation for sqlite3-1.3.9-x86-mingw32
1 gem installed
I dont have much knowledge of nodejs or java but can give you some idea.
Is it like npm for NodeJs and Maven for Java/J2EE
Yes, It is somewhat like that npm.Bundler helps to manage application dependency like xyz app requires foo bar gem. gem is like of libraries which extend the app functionality. This gems are primary located in rubygems.org server.
The first command i executed is gem install bundler. What is gem here and What is bundler, can some one enlighten me in terms of NodeJs or Maven.
when you do gem install <gem_name> , it creates a request to rubygems.org and download the repo(gem) and put it in the configured location. The location can be found in gem env command. To get the details of gem, you have to use gem install <gem_name> -d . So, when you are doing gem install bundler, you are installing bundler gem. This gem will help you to resolve/manage/install application dependencies. This is like npm install bundler with npm .
Where these getting installed?. I don't specify -g like i do in NodeJs for globally.
No, there is no need to write -g option here. My default, we install gems in one location which is not inside apps. personally i think transferring all those gems from one computer to another is slightly cumbersome, rather i prefer to run a command which automatically install all dependency. This is where bundler shines. Let say you have an app which requires foo , bar dependency since it uses its functionality. Without bundler, you have install this gems by running gem install foo , gem install bar. But with bundler, you will just do bundle install and you are done.
That's all. This will give you good start.
gem install bundler installs a gem(library) that will help you to manage your project dependencies.
Then you have a project that contains a file called Gemfile , when you cd into that directory and enter bundle install it will install all gems needed for that project.
To check where your gems are being installed take a look at the output of gem env.

Why won't bundler install JSON gem?

I get the following error when attempting to run cap production deploy.
DEBUG [dc362284] Bundler::GemNotFound: Could not find json-1.8.1.gem for installation
DEBUG [dc362284] An error occurred while installing json (1.8.1), and Bundler cannot continue.
DEBUG [dc362284] Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
It may be important to note that this deployment was working, than I upgraded to Ruby 2.1.0 to remove an encoding error. I upgraded locally which worked fine. I ran rvm install 2.1.0 and rvm use 2.1.0 then changed my .ruby-version file to reflect this Ruby upgrade.
The bundle install command works locally, but produces the same above error when I ssh onto the destination server and run this command.
If I run gem list I can see this in the list of gems.
...
jquery-rails (3.0.4)
json (1.8.1)
less (2.3.2)
...
If I try the recommended solution gem install json -v '1.8.1' Locally and on the destination server I get the following output:
Building native extensions. This could take a while...
Successfully installed json-1.8.1
Parsing documentation for json-1.8.1
Done installing documentation for json after 0 seconds
1 gem installed
So it appears the gem is installed, right? Why is this happening? How can I solve this? Any help would be greatly appreciated.
$ bundle update json
$ bundle install
So after a half day on this and almost immediately after posting my question I found the answer. Bundler 1.5.0 has a bug where it doesn't recognize default gems as referenced here
The solution was to update to bundler 1.5.1 using gem install bundler -v '= 1.5.1'
Run this command then everything will be ok
sudo apt-get install libgmp-dev
if you are in MacOS Sierra and your ruby version is 2.4.0.The ruby version is not compatible with json 1.8.3.
You can try add this line in your Gemfile:
gem 'json', github: 'flori/json', branch: 'v1.8'
This works for me!
To solve this problem, simply run:
bundle update
It will update the version of your bundler. Then run:
bundle install
Your problem will get solve. Solution is well explained here.
I found the solution here. There is a problem with json version 1.8.1 and ruby 2.2.3, so install json 1.8.3 version.
gem install json -v1.8.3
You should try
$ sudo gem install json -v '1.8.2'
in my case (Ubuntu 14.04) that didn't work directly and I had to do this:
$ sudo apt-get install ruby-dev
and then I could install the gem and continue. Had one more problem that was fixed by:
$ sudo apt-get install libsqlite3-dev
Hoping helps.
If the recommended answer didn't help because you are already using a newer version of bundler. Try the solution that worked for me.
Delete everything inside your vendor folder.
Add a line to your gemfile
gem 'json', '1.8.0'
Then run - bundle update json.
It seems to be an issue with 1.8.1 so going back to 1.8.0 did the trick for me.
I ran into this error while trying to get a project to run on my local dev box (OSX 10.6), using Sinatra and Postgresql (through activerecord), running on an rvm'd ruby 2.1. I found my answer here: https://github.com/wayneeseguin/rvm/issues/2511
My exact problem (after the first block of log entries):
I also get an error when trying to build native extensions for gems
The answer:
rvm reinstall 2.1.0 --disable-binary
The explanation:
OSX does not have a package manager so all libraries have to be installed manually by user, this makes it virtually impossible to link the binary dynamically, and as you can see there are problems with the (pseudo)statically linked binary.
For the sake of completeness, I had first forgotten to update rvm (rvm get head), which yielded some other errors, but still needed the --disable-binary flag once I had done so.
bundle update json. Helped to get through.
When I tried to install the json gem using gem install json separate from just using bundle install I got ERROR: Failed to build gem native extension., looking that up I found using
apt-get install ruby-dev
did the trick
For OS X make sure you have coreutils
$ brew install coreutils
$ bundle
This appears to be a bug in Bundler not recognizing the default gems installed along with ruby 2.x. I still experienced the problem even with the latest version of bundler (1.5.3).
One solution is to simply delete json-1.8.1.gemspec from the default gemspec directory.
rm ~/.rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/specifications/default/json-1.8.1.gemspec
After doing this, bundler should have no problem locating the gem. Note that I am using chruby. If you're using some other ruby manager, you'll have to update your path accordingly.
I was missing C headers solution was to download it for Xcode, this is the best way.
xcode-select --install
Hope it helps.
Bundle was failing to install json -v '1.8.1' and deleting my Gemfile.lock and running bundle again solved this issue for me.
I installed the latest version of json:
gem install json
Then deleted the line json(1.8.1) from the Gemfile.lock and did a
bundle install
And then the Gemfile.lock file uses json(1.8.3) without erros
Switch ruby version from 1.9 to 2.2 with rvm did the job for me
For me, some of the answers mentioned earlier were helpful from understanding point of view, but those didn't solve my problem.
So this is what I did to solve issue.
Modified gemfile.lock to update json (2.0.2) (Earlier, it was 1.8.3)
Check the Bundler version installed (Bundler -v command). I had version 1.12.5 installed
Install bundler version 1.11.2 (using gem install bundler -v '1.11.2')
Then run bundle install
For macOS Sierra:
I ran into this error When i used bundler(v1.15.3) in Rails(v4.2) project.
The solution for me is gem uninstall bundler -v '1.15.3' and gem install bundler -v '1.14.6'.

Installing mysql2 gem for Ruby on Rails 3.1.0

I get this error
Gem files will remain installed in
/home/mark/.bundler/tmp/28288/gems/mysql2-0.2.17 for inspection.
Results logged to
/home/mark/.bundler/tmp/28288/gems/mysql2-0.2.17/ext/mysql2/gem_make.out
An error occured while installing mysql2 (0.2.17), and Bundler cannot
continue. Make sure that gem install mysql2 -v '0.2.17' succeeds
before bundling.
With a Ruby on Rails application and I can not solve it.
Most folks find this works:
sudo apt-get install libmysql-ruby libmysqlclient-dev
It's probably a compilation error. Maybe you don't have mysql development libs installed in your system.
I need to see the logs to make sure.
Try it and paste the output here:
cat /home/mark/.bundler/tmp/28288/gems/mysql2-0.2.17/ext/mysql2/gem_make.out
Btw: wich operation system are you using?

Why can't I install the SQLite gem?

I'm try to install the SQLite gem on a Fedora 9 Linux box with Ruby 1.8.6, Rails 2.2.2, gem 1.3, and sqlite-3.5.9. Here's the command I'm running and its results:
sudo gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb install sqlite3-ruby
can't find header files for ruby.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out
gem_make.out just repeats what was already sent to the console. How can I install this gem?
The SQLite RubyGem isn't actually a RubyGem, it's a "CGem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it and in order to do that it needs the C header files for the Ruby interpreter.
If you compile Ruby yourself, those header files will be installed automatically, however, in RedHat-ish systems, such header files are usually packaged in a seperate package, called <whatever>-dev. So, in this case you will need to install the ruby-dev package and possibly the libsqlite3-dev (Ubuntu) or sqlite-devel (Fedora) package as well.
However, you might be better off just installing your Operating System's pre-packaged libsqlite3-ruby package, that way all the dependencies are automatically satisfied.
(Note: all package names pulled out of thin air, might be different on your system.)
You probably need the ruby dev package. For Ubuntu you have to install ruby1.8-dev which includes the ruby header files. A quick google says that the yum package is ruby-devel. so run this:
sudo yum install ruby-devel
I faced problem installing sqlite3-ruby gem on my fedora 13 box.
It was fixed after sudo yum install sqlite-devel
When I had that problem:
gem install sqlite3 -v '1.3.9'
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
For me worked, installing the "libsqlite3-dev" with:
apt-get install libsqlite3-dev
sudo apt-get install ruby-dev
Fixed it for me.
On Ubuntu 9 and 10 try:
sudo apt-get install ruby-dev
sudo apt-get install sqlite3-dev
Then run
gem install sqlite3
Run the following for Fedora OS:
yum install rubygem-sqlite3
On alpine, you need to install the sqlite-dev package.
I also faced this same issue, the problem is that your Linux installation requires the development libraries for SQLite3 to be installed in order to build the gem.
Here's how I fixed the issue
Open your terminal and run the following commands
sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev
And then try installing Sqlite3 gem again using this command
gem install sqlite3
That's all.
I hope this helps
Do you have all the source code required to build sqlite3-ruby? Gem is trying to compile some C code and cannot find the headers. You can probably use a fedora rpm for sqlite3-ruby (I don't use fedora, but I'm sure one exists) if you prefer to forgo compiling. Personally for ruby stuff, I prefer to use gem rather than a distro's packaging system.
I'm not really familiar with Fedora, but in Ubuntu when you are installing packages you have apt-get, and you have to install the build-essentials which includes gcc and other compilation tools for C. I would say that could be your issue, and you make look into how that can be install either using RPM or apt-get on Fedora.
I fixed the problem on my OLPC (Fedora 9) by installing 'gcc' oddly enough. It seems like it should have been one of those dev packages, but no.
Also, regarding the other packages, the suffix is "-devel", not "-dev", so make sure you get those ending right: "ruby-devel", "sqlite-devel"...
Once you get that installed, if you get errors about your gems being too old "< 1.3.1" when you try to run various rails scripts, eg: script/server or script/console, google "upgrade_rubygems" to fix that problem...
HTH...
Run "sudo yum install sqlite-devel" and then "gem install sqlite3". Had the same problem on my Fedora 15.
I had this same exact issue...instead of gem'ing the missing pieces I used synaptic on unbuntu.
The key package for me was libsqlite-ruby1.9.1 ... I documented my experience (for reference) with this error at :
Sqlite3-gem-error-during-bundle-install
I encountered this error while running bundle install after generating a react-rails app on Fedora 29. I was able to identify a suitable development package by running dnf search sqlite3, then installed it dnf install libsqlite3x-devel. This fixed it for me.

Resources