Could not find gem 'rails' when trying to access database - ruby-on-rails

Im getting the following error message when i do
rails db:schema:dump or any rails command in this directory
Could not find gem 'rails (~> 5.0.1) x86-mingw32' in any of the gem sources listed in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
i tried bundle install and received the following error message
>C:\Users\jalen\Documents\Sites\simple_cms>gem install rails -v 5.0.1
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
> current directory: C:/Ruby23/lib/ruby/gems/2.3.0/gems/nio4r-1.2.1/ext/nio4r
C:/Ruby23/bin/ruby.exe -r ./siteconf20161220-8320-1xbe7zi.rb extconf.rb
checking for unistd.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.
>Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby23/bin/$(RUBY_BASE_NAME)
>C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
>You have to install development tools first.
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in >postpone'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from C:/Ruby23/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
from extconf.rb:3:in `<main>'
>To see why this extension failed to compile, please check the mkmf.log which can be found here:
>C:/Ruby23/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/nio4r->1.2.1/mkmf.log
>extconf failed, exit code 1
>Gem files will remain installed in C:/Ruby23/lib/ruby/gems/2.3.0/gems/nio4r-1.2.1 for inspection.
Results logged to C:/Ruby23/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/nio4r-1.2.1/gem_make.out
I thought i may be DevKit that was the problem, but I've already installed DevKit on my computer, and when in another directory i can see that i have
rails -v
Rails 5.0.1

I figured out the answer. Make sure that if you download the x64 ruby version, you also download the x64 DevKit installation as well. I didnt pay attention to that and downloaded a x64 with a non x64.

Related

"ERROR: Error installing rails: ERROR: Failed to build gem native extension" while sudo gem install rails

I am getting through https://guides.rubyonrails.org/getting_started.html
I have already completed most of the initial setup and I am stuck on the last part of installing rails.
Ruby version is
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
When I run the
sudo gem install rails
I get the following output
redd#tanya:~$ sudo gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.7.0/gems/nio4r-2.5.8/ext/nio4r
/usr/bin/ruby2.7 -I /usr/lib/ruby/2.7.0 -r ./siteconf20211210-14142-ms6vi8.rb extconf.rb
checking for unistd.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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)2.7
--with-unistd-dir
--without-unistd-dir
--with-unistd-include
--without-unistd-include=${unistd-dir}/include
--with-unistd-lib
--without-unistd-lib=${unistd-dir}/lib
/usr/lib/ruby/2.7.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/2.7.0/mkmf.rb:613:in `try_cpp'
from /usr/lib/ruby/2.7.0/mkmf.rb:1124:in `block in have_header'
from /usr/lib/ruby/2.7.0/mkmf.rb:971:in `block in checking_for'
from /usr/lib/ruby/2.7.0/mkmf.rb:361:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.7.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/2.7.0/mkmf.rb:361:in `block in postpone'
from /usr/lib/ruby/2.7.0/mkmf.rb:331:in `open'
from /usr/lib/ruby/2.7.0/mkmf.rb:357:in `postpone'
from /usr/lib/ruby/2.7.0/mkmf.rb:970:in `checking_for'
from /usr/lib/ruby/2.7.0/mkmf.rb:1123:in `have_header'
from extconf.rb:15:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/nio4r-2.5.8/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.7.0/gems/nio4r-2.5.8 for inspection.
Results logged to /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/nio4r-2.5.8/gem_make.out
I have already tried all the fixes mentioned here: https://www.youtube.com/watch?v=ikIOpRnO1x4
I would appreciate any help in sorting out this problem. Also, if you know the process of finding the solution please mention that too. Thank you for your time.

Not able to install gems "mysql2, mariadb 10.1" in Ubuntu 16.04 Xenial

I have working mariadb 10.1 server.
I install ruby 2.3.0 on ubuntu 16.04.
I install libmariadbd-dev and libmariadbclient-dev.
When I try "gem install mysql2", then a recive message:
Building native extensions with: '--with-mysql-dir=/usr/local/mysql'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/mysql2-0.4.4/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20160615-5183-kj9yds.rb extconf.rb --with-mysql-dir=/usr/local/mysql
checking for ruby/thread.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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
from /usr/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
from /usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from /usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from /usr/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
from extconf.rb:16:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/mysql2-0.4.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.4/gem_make.out
And I can`t find how to build this gem.
Gem in this situation need 3 packets.
sudo apt-get install libnetcdf-dev libssl-dev libcrypto++-dev
This is for mac but you need to change the path:
gem uninstall mysql2
intall mariadb 10.1 andnecesaary ssl packages or maybe this are not needed
then check the path to the libraries and the tinal folders have the same name:
bundle config --local build.mysql2 "--with-mysql-config=/usr/local/Cellar/mariadb#10.1/10.1.29/bin/mysql_config --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
or without the ssl path
bundle config --local build.mysql2 "--with-mysql-config=/usr/local/Cellar/mariadb#10.1/10.1.29/bin/mysql_config
or directly the gem, but if you come ffrom mysql is better to do it with bundle
gem install mysql2 -v 'x.y.z' -- --with-mysql-config=/usr/local/Cellar/mariadb#10.1/10.1.29/bin/mysql_config
and finally
bundle install

Problems relating to installing Ruby

I used the below link to solve the problem. But got few other problems.
gem install json -v 1.7.3 gives 'Please update your PATH to include build tools'
`enter code here`C:\>ruby dk.rb init
[INFO] found RubyInstaller v2.2.4 at C:/Ruby22
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.
I don't know what changes I am supposed to make and how.
C:\>ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Ruby22'
[INFO] Installing 'C:/Ruby22/lib/ruby/site_ruby/devkit.rb'
C:\>gem install rdiscoun
t --platform=ruby
Fetching: rdiscount-2.1.8.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rdiscount:
ERROR: Failed to build gem native extension.
C:/Ruby22/bin/ruby.exe -r ./siteconf20160313-1220-1i9eix7.rb extconf.rb
checking for random()... *** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby22/bin/$(RUBY_BASE_NAME)
--with-rdiscount-dir
--without-rdiscount-dir
--with-rdiscount-include
--without-rdiscount-include=${rdiscount-dir}/include
--with-rdiscount-lib
--without-rdiscount-lib=${rdiscount-dir}/lib
C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generat
e an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:541:in `try_link0'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:556:in `try_link'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:735:in `try_func'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:1020:in `block in have_func'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpo
ne'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
from C:/Ruby22/lib/ruby/2.2.0/mkmf.rb:1019:in `have_func'
from extconf.rb:5:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby22/lib/ruby/gems/2.2.0/gems/rdiscount-
2.1.8 for inspection.
Results logged to C:/Ruby22/lib/ruby/gems/2.2.0/extensions/x86-mingw32/2.2.0/rdi
scount-2.1.8/gem_make.out
Can you please help me with the problem. I've been trying solve this problem for a month. Thank you.
It appears you have already installed DevKit, so the error message
You have to install development tools first.
suggests you have a mismatch between your Ruby version and your DevKit version. Ensure both are 64bit, or both are 32bit versions, and that you choose whichever matches your operating system.

gem install rmagick error

I know there are many questions about this error but I read several tutorials and SO discussions without coming to a solution.
I'm trying to install rmagick (I want to install Spree ecommerce for Ruby on Rails which requires ImageMagick and rmagick).
I'm working on Windows 7 (64 bit), Ruby version is: 2.1.5, Rails version is 4.2.1. and I downloaded and installed (in C:\ImageMagick) ImageMagick-6.9.1-2-Q16-x64-dll.exe and I also installed Dev-Kit.
I followed the steps that Sumit Munot suggested here ImageMagick Install Windows but when I follow the step 6 I get this errors.
C:\Sites>gem install rmagick
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:/RailsInstaller/Ruby2.1.0/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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/RailsInstaller/Ruby2.1.0/bin/ruby
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler
failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:1067:in `block i
n have_header'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:918:in `block in
checking_for'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block (2
levels) in postpone'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block in
postpone'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:347:in `postpone
'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:917:in `checking
_for'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:1066:in `have_he
ader'
from extconf.rb:37:in `configure_headers'
from extconf.rb:17:in `initialize'
from extconf.rb:474:in `new'
from extconf.rb:474:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1
.0/gems/rmagick-2.15.0 for inspection.
Results logged to C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86
-mingw32/2.1.0/rmagick-2.15.0/gem_make.out
C:\Sites>gem install rmagick
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:/RailsInstaller/Ruby2.1.0/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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/RailsInstaller/Ruby2.1.0/bin/ruby
C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler
failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:1067:in `block i
n have_header'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:918:in `block in
checking_for'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block (2
levels) in postpone'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block in
postpone'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:347:in `postpone
'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:917:in `checking
_for'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/mkmf.rb:1066:in `have_he
ader'
from extconf.rb:37:in `configure_headers'
from extconf.rb:17:in `initialize'
from extconf.rb:474:in `new'
from extconf.rb:474:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1
.0/gems/rmagick-2.15.0 for inspection.
Results logged to C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86
-mingw32/2.1.0/rmagick-2.15.0/gem_make.out
This is my path: C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby2.1.0\bin;C:\Ruby21\bin;
Do I have to add something to the path?
Yeah, had the same trouble and gave it a second shot.
Remove your current ImageMagic folder and rmagick gem
Install ImageMagick-6.7.9-3-Q16-windows-dll.exe from here and ImageMagick-6.7.9-2-Q8-windows-static.exe in the same folder (these worked while the most recent ones don't)
in your console window set path=d:\ImageMagick;%path%
gem install rmagick -- '--with-opt-dir="d:\ImageMagick"'
I installed ImageMagick obviously in d:\ImageMagick, so adapt for your situation.
This worked for my Ruby 1.9.3 under Windows 7, success !
Set %DEVKIT_HOME%\bin in your %PATH% in the System Variables:

error in `install bundler` while installing ruby gems on windows machine

I am trying to intsall middleman - a static site generator, which uses ruby gems. It is able to build all native extensions but not wdm. I am getting the below error message when I run install bundler command in my command prompt.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe -r ./siteconf20140814-4200-t0fvuf.rb extconf.rb
checking for main() in -lkernel32... *** 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.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby200/bin/ruby
--with-kernel32lib
--without-kernel32lib
C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to genera
te an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:534:in `try_link'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:720:in `try_func'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:950:in `block in have_library'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:895:in `block in checking_for'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:340:in `block (2 levels) in postp
one'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:340:in `block in postpone'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:310:in `open'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:336:in `postpone'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:894:in `checking_for'
from C:/Ruby200/lib/ruby/2.0.0/mkmf.rb:945:in `have_library'
from extconf.rb:19:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/wdm-0.1.0
for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/extensions/x86-mingw32/2.0.0/wd
m-0.1.0/gem_make.out
An error occurred while installing wdm (0.1.0), and Bundler cannot continue.
Make sure that `gem install wdm -v '0.1.0'` succeeds before bundling.
Do I need to install something before running it.
The answer is in the logs actually. the gem "wdm" which makes the bundle install fail requires the "development tools" to be installed.
You can install those by following the instructions there.

Resources