I have a Rails application which was using Mongoid 4.0.2. I upgraded Mongoid to version 5.0.0 and start getting this error
....gems/2.2.0/gems/less-rails-2.7.0/lib/less/rails/railtie.rb:19:in `block in <class:Railtie>': undefined method `register_preprocessor' for nil:NilClass (NoMethodError)
How to fix this issue or is any manual how to upgrade Mongoid to version 5.0.0 ?
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0.beta4'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0.beta1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jQuery as the JavaScript library
gem 'jquery-rails', '~> 4.0.0.beta2'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#new gems
#database
gem 'mongoid', '~> 5.0.0.beta'
gem "mongoid-paperclip", :require => "mongoid_paperclip"
gem 'bson_ext'
#stile
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'bootstrap_form'
gem 'bootstrap-sass', '~> 3.3.4'
gem 'bootswatch-rails'
gem 'simple_form'
gem 'mongo'
gem "figaro"
gem 'sidekiq'
gem 'sidekiq-status'
gem 'rubyzip'
#gem 'sidekiq_status'
#gem 'sidekiq-status'
gem 'sinatra', require: false
gem 'slim'
gem 'capistrano', '~> 3.1.0'
# rails specific capistrano funcitons
gem 'capistrano-rails', '~> 1.1.0'
gem 'capistrano-rails-console'
# integrate bundler with capistrano
gem 'capistrano-bundler'
# if you are using RBENV
gem 'capistrano-rbenv', "~> 2.0"
gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'
gem 'capistrano-passenger'
gem 'utf8-cleaner'
gem "devise"
gem 'rollbar', '~> 1.5.3'
#gem 'bson', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
gem 'thin'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0.0.beta4'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
#new gems
gem "rspec-rails"
gem 'pry-rails'
gem 'pry-rescue'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'better_errors'
#gem 'mongoid-rspec', '~> 2.1.0'
end
It looks like the error has appeared again in less-rails. The error is not related to Mongoid at all. I started getting the error a couple of days ago on my development server. I decided to check Github to see if an issue was reported about this. I found the following issue addressing the error.
https://github.com/metaskills/less-rails/pull/112
I changed my Gemfile to the following as provided on the link which corrected the error.
gem "less-rails", :git => 'https://github.com/suzan2go/less-rails.git', :branch => 'fix-nomethoderror-for-sprockets3'
As of now this solution has not been applied to the gem. I guess it will be soon.
Most important thing to look for while upgrading to Mongoid 5 is mongoid.yml
From:
<%= rails_env %>:
sessions:
default:
database: <%= mongodb_database %>
hosts:
- <%= mongodb_staging_host %>
username: <%= mongodb_user %>
password: <%= mongodb_password %>
options:
read: :primary_preferred
To:
<%= rails_env %>:
clients:
default:
database: <%= mongodb_database %>
hosts:
- <%= mongodb_staging_host %>
options:
user: <%= mongodb_user %>
password: <%= mongodb_password %>
read:
mode: :primary_preferred
Change sessions to clients
Move username (will become user) and password into options
change read mode as shown, if you have any.
Bottomline is to check mongoid.yml thoroughly while comparing with this page
Here how I fixed this issue
Removed from Gemfile gem "less-rails"
From application.rb removed require "mongo"
In mongoid.yml changed sessions: to clients:
Related
The following error occurred while executing the project after git clone, yarn install and bundle install.
Error logs
Sprockets::FileNotFound in Users::Sessions#new
Showing /Users/{...}/Desktop/{my_project_dir}/app/views/users/sessions/new.html.erb where line #9 raised:
couldn't find file 'angular/1.8.0/angular' with type 'application/javascript'
Checked in these paths:
/Users/{...}/{my_project_dir}/app/assets/config
/Users/{...}/{my_project_dir}/app/assets/fonts
/Users/{...}/{my_project_dir}/app/assets/images
/Users/{...}/{my_project_dir}/app/assets/javascripts
/Users/{...}/{my_project_dir}/app/assets/stylesheets
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rails_admin-2.0.2/app/assets/images
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rails_admin-2.0.2/app/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rails_admin-2.0.2/app/assets/stylesheets
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rails_admin-2.0.2/vendor/assets/fonts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rails_admin-2.0.2/vendor/assets/images
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rails_admin-2.0.2/vendor/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rails_admin-2.0.2/vendor/assets/stylesheets
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/remotipart-1.4.4/vendor/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/nested_form-0.3.2/vendor/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/jquery-ui-rails-6.0.1/app/assets/images
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/jquery-ui-rails-6.0.1/app/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/jquery-ui-rails-6.0.1/app/assets/stylesheets
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/jquery-rails-4.4.0/vendor/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/apidoco-1.6.2/app/assets/config
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/apidoco-1.6.2/app/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/apidoco-1.6.2/app/assets/stylesheets
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/coffee-rails-4.2.2/lib/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actioncable-6.0.3.4/app/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activestorage-6.0.3.4/app/assets/javascripts
/Users/{...}/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionview-6.0.3.4/lib/assets/compiled
/Users/{...}/{my_project_dir}/node_modules):
6:
7: <div class="text-center w-75 m-auto">
8: <a href="/">
9: <span><img src="<%= image_url('bi.png') %>" alt="" height="50" /></span>
10: </a>
11: <p class="text-muted mt-3"> Title description </p><p class="text-muted"></p>
12: </div>
I don't understand why couldn't find file 'angular/1.8.0/angular' with type 'application/javascript' is happened.
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
# Use sqlite3 as the database for Active Record
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
# gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
gem 'image_processing', '~> 1.2'
# Json Serializer
gem 'fast_jsonapi'
# api docs
gem 'apidoco'
# admin
gem 'rails_admin', '~> 2.0'
# control cors
gem 'rack-cors'
# pagination
gem 'kaminari'
gem 'will_paginate', '~> 3.1.0'
# api call
gem 'rest-client'
# user and admin
gem 'devise'
gem 'devise-jwt'
gem 'omniauth-oauth2'
gem 'omniauth-google-oauth2'
gem 'omniauth-naver'
gem 'devise-i18n'
# manage role
gem 'cancancan'
gem 'rolify'
# active storage
gem 'active_storage_validations'
gem 'aws-sdk-s3'
# Use ActiveStorage variant
gem 'mini_magick', '~> 4.8'
# Scheduled Job
gem 'whenever'
# Active Job
gem 'sidekiq'
gem 'connection_pool'
gem 'redis-namespace'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
First of all I haven't written any angular related code within the project.
i've tried
I deleted the error code and tried again, but the same problem occurs with other erb code.
I thought maybe it could be a version of the gem files. After deleting all gems, I reinstalled ruby (using rbenv), but I got the same error.
I have installed angular#1.8.0, but I got the same error.
Please let me know solution about couldn't find file 'angular/1.8.0/angular' with type 'application/javascript'
I found problem that since multiple projects are running on one server, all the projects have to be loaded locally. In the process, there was a conflict with the apidoco gem.
Solution is to remove apidoco from the Gemfile of the problem project.
I'm attempting to run a rails app on my local machine developed elsewhere, but I can't get it to run locally. When I run rails s to get the server running, I get:
Could not find proper version of railties (4.2.6) in any of the sources
Run `bundle install` to install missing gems.
So, naturally, I run bundle install but get the error:
Attempting to write to
`/home/rails/apps/intranet/shared/bundle/ruby/2.2.0` is
unsupported by your OS
My OS is macOS Sierra version 10.12.4.
Also, railties is in the gem folder and seems to be the correct version.
Thanks in advance.
Edit: Adding Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'devise'
gem 'rails_admin'
gem 'carrierwave'
gem 'where-or'
# Railties
gem 'railties', '~> 4.2', '>= 4.2.6'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'pry-rails'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'guard', require: false
gem 'guard-rspec', require: false
gem 'guard-bundler', require: false
gem "guard-cucumber", require: false
gem 'ruby_gntp'
gem 'terminal-notifier'
gem 'terminal-notifier-guard'
gem 'thin'
gem 'quiet_assets'
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano3-unicorn'
gem 'capistrano-bundler'
gem 'better_errors'
gem 'binding_of_caller'
end
group :test do
gem 'database_cleaner'
gem 'capybara'
gem 'shoulda-matchers'
gem 'poltergeist'
gem 'launchy'
gem "cucumber-rails", require: false
end
Found out what was the issue. Since this was downloaded from a remote server, the .bundle/config file had a different path for 'BUNDLE_PATH'. I simply had to change that to the path on my own computer instead of the path on the remote server and I stopped getting the error.
check if you have write permissions to the directory /home/rails/apps/intranet/shared/bundle/ruby/2.2.0`
Heroku states "Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile" on the inital commit.
I've already changed my Gemfile so that sqlite is used in development and pg is used in production mode. My database.yml is added to the .gitignore file. Are there any places where I have to change sqlite to pg?
Thanks in advance
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.1'
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
:github => 'anjlab/bootstrap-rails',
:branch => '3.0.0'
gem "font-awesome-rails"
gem "json"
gem "nokogiri"
gem "leaflet-rails"
gem "mapbox-rails"
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :production, :staging do
gem 'pg'
gem 'rails_12factor'
end
group :development do
gem 'sqlite3'
gem 'better_errors'
gem "binding_of_caller"
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
I previously ran
bundle install --without production
the solution to my problem was to install also the production gems. What my production gems have to do with a "specified sqlite3 adapter" I don't understand at all.
ran bundle install
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/Users/judyngai/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/requirement.rb:90:in `parse': Illformed requirement [""] (Gem::Requirement::BadRequirementError)
what is the problem with my bundler?
is working in a blank app but just not at the app that I am working on.
thank you
here is my gemfile as requested
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
#High Voltage
gem "high_voltage", "~> 1.2.4"
#Database
gem "pg", "~> 0.16.0"
#to make attribute accessible work
gem "protected_attributes", "~> 1.0.3"
#Authentication , upgrading devise?
gem "devise", "~> 3.0.3"
#Active Admin
gem 'activeadmin', github: 'gregbell/active_admin', branch: 'rails4'
#Simple Form
gem 'simple_form'
#js runting for bootstrap to work
gem "therubyracer"
#Web Server
gem "thin"
#Student Picture Uploaders
gem "rmagick"
gem "carrierwave"
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
I don't see any syntax errors in my gemfile. I remember seeing the same error before and removed an extra comma from my gemfile.
I have a rails app that I am trying to install devise on.
I use the command
rails generate devise:install
but it fails, giving this message:
Could not find generator 'devise:install'. Maybe you meant 'ckeditor:install', 'assets' or 'comment'
however if I use sudo rails generate devise:install it works.
I do not want to generate devise:install as root however.
I have done chmod a+x on the directory.
I also recently changed macbooks and imported my ssh key from the previous macbook, but I added the key with ssh-add. Not sure if this is the problem.
this is my gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
gem 'thin'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'devise', '3.5.3'
gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'
gem 'bootstrap_form'
gem 'kaminari'
gem 'carrierwave'
gem "rmagick", :require => 'RMagick'
gem 'ckeditor'
gem 'acts_as_commentable'
gem 'addressable'
gem 'vimeo'
gem 'underscore-rails'
gem 'gmaps4rails'
gem 'geocoder'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'pry'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'rails_12factor', group: :production
I managed to solve this by deleting my Gemfile.lock, doing bundle install again and then stopping spring with spring stop I could then call the generator without root privileges
It's kind of weird, but I solve the problem restarting my mac