gem "mysql2" instalation errors - ruby-on-rails

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.

Related

debase gem is exploading in my face on install

So I'm trying to install debase in my gemfile and explosions are happening. Here's what the output looks like...
(Ok so there was a bunch of stuff here that I removed cause it got fixed. Now I have only this remaining error)
UPDATE 2:
...installing ruby-debug19 helped to install vm_core.h (thank you to Alter Lagos for recommending that). Now I have a new error message...
Fetching debase 0.2.1
Installing debase 0.2.1 with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/fonso/.rbenv/versions/1.9.3-p551/bin/ruby extconf.rb
checking for vm_core.h... yes
creating Makefile
make
compiling breakpoint.c
In file included from breakpoint.c:1:0:
./debase_internals.h:5:24: fatal error: ruby/debug.h: No such file or directory
compilation terminated.
make: *** [breakpoint.o] Error 1
Gem files will remain installed in /home/fonso/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/debase-0.2.1 for inspection.
Results logged to /home/fonso/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/debase-0.2.1/ext/gem_make.out
An error occurred while installing debase (0.2.1), and Bundler cannot continue.
Make sure that `gem install debase -v '0.2.1' --source 'http://rubygems.org/'` succeeds before bundling.
In Gemfile:
debase
Anyone know how to solve this mystery?
"Failed to build gem native extension" means your computer had to compile a C extension to install the gem. This is actually common. Many gems like pg include C extensions. It's also common for people to encounter this error message. It just means your operating system lacks a certain package that would provide the C files needed to compile the extension.
The errors can be tricky to solve though because it's not a matter of changing what you're doing. You're installing the gem just fine. It's your environment that needs to be changed. You need to know which packages to install for your operating system for that version of the Gem.
Many tutorials include lists of packages you should install. For example, https://gorails.com/setup/ubuntu/18.04 tells you that, if you're installing the latest version of Ruby right now (3.0.1), you install: git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
These instructions are meant for Ubuntu 18.04. It would be different if you were using a different version of Ubuntu or a different operating system like MacOS. Also, your question shows you using a very old version of Ruby, 1.9.3. If you must use this old version, this could make this even harder for you, because there's no guarantee you'll find system packages that would work with the C extension that version of that gem wants to compile. I'd suggest using a recent version of Ruby if you can.
Annnnnd the answer is...For old apps using ruby 1.9.x use
gem 'ruby-debug-base19x', '~> 0.11.32'
instead of
gem debase
in your Gemfile per the readme for ruby-debug-ide https://github.com/ruby-debug/ruby-debug-ide
Now the gems install fine.
rdebug-ide command is not working tho', I've posted that question here... ruby-debu-ide command exploading in my face

An error occurred while installing ruby-opencv (0.0.14)

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.

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.

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?

Problem during SQLite3 installation on Windows XP

As shown in a blog I followed the instructions of setting up SQLite3 on my Windows, but after I pasted the necessary files in Bin folder of Ruby, which I downloaded from http://www.sqlite.org/download.html, I get the following error when I use the following commmands:
C:\gem install sqlite3-ruby --version=1.2.3
ERROR: http://rubygems.org does not appear to be a repository
ERROR: Could not find a valid gem 'sqlite3-ruby' (= 1.2.3) in any repository
Please help me out with this problem and suggest me alternate methods for gem installing SQLite3.
Thanks.
Check that you have the latest version of rubygems: gem -v executed in a command prompt should return 1.3.7. If it does not, you have several options (also explained on rubygems.org):
gem update --system
or
gem install rubygems-update
update_rubygems
Secondly, if you have the correct version and you are on a network with a proxy, you have to tell gem to use that proxy.
There are two ways to do that. First, you could do
gem install sqlite3-ruby -p http://yourproxyserver:port`
or you could define an environment variable
set HTTP_PROXY=http://yourproxyserver:port
and then this setting is saved (and you do not have to specify it explicitly anymore).
Hope this helps.
Try doing this: gem install sqlite3-ruby --version=1.2.3 --source http://gemcutter.org
If that does not work head over to http://gemcutter.org and download the particular version of the gem file, go to the destination to where you copied it to in the command line and install it locally using gem install sqlite3-ruby -l

Resources