cannot load such file -- nokogiri/nokogiri (LoadError) MacOS - ruby-on-rails

I'm trying to setup a Rails project but unfortunately it fails when running rails new railsapp. I get the in 'require': cannot load such file -- 'nokogiri\nokogiri' (LoadError) error.
To fix this, I did cd railsapp and changed the gemfile to gem 'nokogiri', '~> 1.6', '>= 1.6.8' and ran gem install nokogiri -v 1.6.8 and bundle i but that still gives an error related to Nokogiri.
require': cannot load such file -- nokogiri/nokogiri (LoadError)
Also did the following things:
gem uninstall nokogiri
bundle install nokogiri
bundle update nokogiri
I have setup Ruby and Rails using https://gorails.com/setup/osx/11.0-big-sur
Rails 6.1.4.1
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

Related

cannot start rails server -> cannot load such file -- mysql2/mysql2 (LoadError)

My rails application cannot start because mysql2 load error.
I have tried many solutions, But none can't fix the problem.
Even the rake command can't be executed.
rake aborted!
LoadError: cannot load such file -- mysql2/mysql2
My gemfile is:
ruby '2.5.1'
gem 'rails', '~> 4.2.4'
gem 'mysql2', '~> 0.5.2'
Bundle installed successfully. Mysql installed correctly. Yet the error occurs on MacOS.
Simply, uninstall and reinstall with the following command:
gem install mysql2
If this is not working, you can try adding the following to your mysql_config:
gem install mysql2 -v 0.4.4 -- --with-mysql-config=/usr/local/Cellar/mysql#5.6/5.6.42/bin/mysql_config --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

rails console giving error to add test-unit gem to gemfile

I am getting an error while running rails console:
`require': Please add test-unit gem to your Gemfile: `gem 'test-unit', '~> 3.0'`(cannot load such file -- test/unit/testcase) (LoadError)
If I add this gem to my Gemfile then rails console works fine. But why does it keep asking me to add this gem to my Gemfile?
Rails version 3.2.2
It's rails dependency: https://github.com/drapergem/draper/issues/690
Please read more about that: https://bugs.ruby-lang.org/issues/9711

How to use Ruby 2.4.0 on a server

When I run cap production deploy I get the following error:
cap production deploy
SSHKit::Command::Failed: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Ruby ruby-2.4.0 is not installed
I specified the Ruby version in my deploy.rb file:
set :passenger_restart_with_touch, true
set :rvm_ruby_version, 'ruby-2.4.0'
and included it in my Gemfile:
gem "capistrano", "~> 3.8"
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano-passenger'
How should I run Ruby version 2.4.0 on the server without going into the server?
You need to run this on server:
rvm install 2.4.0
Install the Ruby version on the server using
rvm install 2.4.0
and then, in your app's root path, use the installed Ruby:
rvm use 2.4.0

getting the error : 2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler (LoadError)

i am trying to implement active adminwith the following configuration.
gem 'rails', '4.2.7.1'
gem 'activeadmin', github: 'activeadmin'
# Plus integrations with:
gem 'devise'
gem 'cancan' # or cancancan
gem 'draper'
gem 'pundit'
i am using ruby 2.2.2
i am unable to do bundle install. getting the following error:
prashanth#prashanth-OptiPlex-390:~/rails_apps/admin_interface$ rvm use 2.2.2
Using /home/prashanth/.rvm/gems/ruby-2.2.2
prashanth#prashanth-OptiPlex-390:~/rails_apps/admin_interface$ rvm gemset create 222admin
ruby-2.2.2 - #gemset created /home/prashanth/.rvm/gems/ruby-2.2.2#222admin
ruby-2.2.2 - #generating 222admin wrappers........
prashanth#prashanth-OptiPlex-390:~/rails_apps/admin_interface$ rvm use 2.2.2#222admin
Using /home/prashanth/.rvm/gems/ruby-2.2.2 with gemset 222admin
prashanth#prashanth-OptiPlex-390:~/rails_apps/admin_interface$ bundle
/home/prashanth/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler (LoadError)
from /home/prashanth/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/bin/bundle:7:in `<main>'

An error occurred while installing refile (0.6.2)

I can't install refile gem from cloned repo on my local.
in my Gemfile:
gem "refile", require: "refile/rails"
gem "refile-mini_magick"
and after running bundle install --without production
i got this error:
Any help?
Check ruby current and default version. rvm list
Make default your ruby 2.2.3 version rvm use 2.2.3 --default
Close terminal and go back to your project directory.

Resources