getting error while runnning rails server - ruby-on-rails

/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in
`require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.6 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.6/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.6'` succeeds before bundling.
In Gemfile:
coffee-rails was resolved to 3.2.2, which depends on
railties was resolved to 3.2.16, which depends on
rdoc was resolved to 3.12.2, which depends on
json
Getting this error while running rails s.How to resolve it

commenting the content of gemfile and updating ruby and rails to a latest stable version will solve most of the errors.
for me I reinstalled ruby and rails using the steps provided at:
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-14-04

Related

How to install ffi 1.9.25 successfully on M1 Chip

An error occurred while installing ffi (1.9.25), and Bundler cannot continue.
In Gemfile:
bootstrap-sass was resolved to 3.3.7, which depends on
sass was resolved to 3.7.4, which depends on
sass-listen was resolved to 4.0.0, which depends on
rb-inotify was resolved to 0.10.1, which depends on
ffi
I'm running into this issue on an M1 laptop for a rails project I'm running bundle install, how to resolve this?
I tried running
gem install ffi -v '1.9.25' -- --with-cflags="-Wno-error=implicit-function-declaration"
Which installed the gem successfully, but when I try to run rake db:migrate this error comes up
rake db:migrate
rake aborted!
LoadError: dlopen(/Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle, 0x0009): symbol not found in flat namespace (_ffi_prep_closure) - /Users/kanye.west/.rbenv/versions/2.6.9/lib/ruby/gems/2.6.0/gems/ffi-1.9.25/lib/ffi_c.bundle
/Users/kanye.west/dev/anenta/config/application.rb:14:in `<top (required)>'
/Users/kanye.west/dev/anenta/Rakefile:5:in `require'
/Users/kanye.west/dev/anenta/Rakefile:5:in `<top (required)>'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `load'
/Users/kanye.west/.rbenv/versions/2.6.9/bin/bundle:23:in `<main>'
Install ffi gem with below command
gem install ffi -v '1.9.25' -- --with-cflags="-Wno-error=implicit-function-declaration"

Cannot install sqlite3 and run bundle install

I'm working on a Ruby on Rails application with sqlite3 and when I run bundle install, I have this error:
Installing sqlite3 1.3.11 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /tmp/bundler20160411-6894-186xx7csqlite3-1.3.11/gems/sqlite3-1.3.11/ext/sqlite3/usr/bin/ruby1.9.1 -r ./siteconf20160411-6894-cji211.rb extconf.rb
/usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mkmf (LoadError)
from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
from extconf.rb:3:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /tmp/bundler20160411-6894-186xx7csqlite3-1.3.11/gems/sqlite3-1.3.11 for inspection.
Results logged to /tmp/bundler20160411-6894-186xx7csqlite3-1.3.11/extensions/x86_64-linux/1.9.1/sqlite3-1.3.11/gem_make.out
Using erubis 2.6.6
Using activemodel 3.0.5
Using rack-mount 0.6.14
Using rack-test 0.5.7
Using treetop 1.4.15
An error occurred while installing sqlite3 (1.3.11), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.
Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3'
Any ideas how I can fix this?
You need to install sqlite3 first sudo apt-get install libsqlite3-dev
Have you tried googling your error?
Here's an answer to the same error you're getting.
Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)
The solution is not with sqlite3. It's most likely your -dev package. If you're on Linux try this -
sudo apt-get install ruby-dev
For Mac, try this
brew install ruby-dev

Spree: heroku deploy error

I keep getting following:
remote: Gem::InstallError: spree_core requires Ruby version >= 2.1.0.
remote: An error occurred while installing spree_core (3.0.4), and Bundler cannot
remote: continue.
remote: Make sure that `gem install spree_core -v '3.0.4'` succeeds before bundling.
when I run
gem install spree_code -v '3.0.4'
it is successful and afterwards when I run git push heroku master again I get the exact same error.
rbenv versions
shows following:
2.2.2 (set by /Users/Martijn/.rbenv/version)
Heroku needs the ruby version defined in the Gemfile, like:
ruby "2.2.1". More info: https://devcenter.heroku.com/articles/ruby-versions.

Could not find railsties

When I type
rails _4.2.0.rc2_ new hello_app
I get this error
/Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'railties' (= 4.2.0.rc2) - did find: [railties-4.1.8] (Gem::LoadError)
Checked in 'GEM_PATH=/Users/a11/.gem/ruby/2.0.0:/Library/Ruby/Gems/2.0.0:/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0', execute `gem env` for more information
from /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:324:in `to_spec'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /usr/bin/rails:22:in `<main>'
I tried installing railsties 4.2.0.rc2 using
gem install railties --pre
If you want try to use new rails version, you need execute
gem install rails --pre
instead of
gem install railties --pre
Railties its core of Rails framework but not in all. See official documentation for more information.
I re-installed rails completely
gem uninstall railties -v 4.2.0.rc2
sudo gem install rails -v 4.2.0.rc2
and that solved it.

ERROR: Failed to build gem native extension message (Linux) installing rubygems

I'm going through the rails tutorial atm. (I'm a beginner so bear with me.)
As you can see below, when I try and install the rubygems using 'bundle install', I get the error message saying that I need to make sure 'gem install json -v '1.8.1' succeeds before I try again.
But when I try and sudo gem install json -v '1.8.1', I get the
.
If I'm asking a stupid question, or if I've left out any necessary info, just let me know. I'm new to this -- CodeAcademy & RailsForZombies are the extent of my knowledge.
ben#ben-X551CA ~/first_rails_project/bens_first_app $ bundle install
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.41
Using activesupport 4.0.8
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.0.8
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.0.8
Using activemodel 4.0.8
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using activerecord 4.0.8
Using bundler 1.7.2
Using coffee-script-source 1.8.0
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.0.8
Using coffee-rails 4.0.1
Using hike 1.2.3
Using jbuilder 1.0.2
Using jquery-rails 3.0.4
Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.
Password:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from extconf.rb:1:in `'
Gem files will remain installed in /tmp/bundler20140908-2757-18q0kfn/json-1.8.1/gems/json-1.8.1 for inspection.
Results logged to /tmp/bundler20140908-2757-18q0kfn/json-1.8.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that gem install json -v '1.8.1' succeeds before bundling.
ben#ben-X551CA ~/first_rails_project/bens_first_app $ gem install json -v '1.8.1'
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.9.1 directory.
ben#ben-X551CA ~/first_rails_project/bens_first_app $ sudo gem install json -v '1.8.1'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from extconf.rb:1:in `'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
ben#ben-X551CA ~/first_rails_project/bens_first_app $
So running this worked for me:
sudo apt-get install ruby1.9.1-dev
Suppose the -dev package was needed?
If #BenLawton answer doesn't work try this (work for me on Ubuntu 16.04):
sudo apt-get install ruby-full
https://www.ruby-lang.org/en/documentation/installation/#apt

Resources