Rails 4. Breakpoint gem path error. File to import not found or unreadable: breakpoint - ruby

Problem:
I have a basic Rails 4.0.10 project where I want to use breakpoint for media queries.
My Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.0.10'
gem 'sqlite3'
gem 'httparty'
gem 'requirejs-rails'
gem "github_api"
gem "breakpoint", "~>2.4.0"
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
When I am requiring breakpoint in my sass stylesheets it throws:
Sass::SyntaxError in Stats#index
Showing /home/action/workspace/sofapp/sofa/app/views/layouts/application.html.erb where line #7 raised:
File to import not found or unreadable: breakpoint.
Load paths:
/home/action/workspace/sofapp/sofa/app/assets/fonts
/home/action/workspace/sofapp/sofa/app/assets/images
/home/action/workspace/sofapp/sofa/app/assets/javascripts
/home/action/workspace/sofapp/sofa/app/assets/stylesheets
/home/action/workspace/sofapp/sofa/vendor/assets/javascripts
/home/action/workspace/sofapp/sofa/vendor/assets/stylesheets
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/jquery-rails-3.1.2/vendor/assets/javascripts
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/requirejs-rails-0.9.5/vendor/assets/javascripts
/home/action/.rvm/gems/ruby-2.0.0-p247/gems/breakpoint-2.4.6/lib/stylesheets
(in /home/action/workspace/sofapp/sofa/app/assets/stylesheets/main.scss:5)
As you can see from error Sass cannot find right path to load breakpoint. I have looked to the last path and find out that directory /home/action/.rvm/gems/ruby-2.0.0-p247/gems/breakpoint-2.4.6/lib/stylesheets doesn't exist, instead we have /home/action/.rvm/gems/ruby-2.0.0-p247/gems/breakpoint-2.4.6/stylesheets.
Question:
Should I configure asset-pipeline to include the right path for breakpoint or there is some other issue?

Related

RoR app: (Devise) seg fault after any route

I'm trying to set up the development environment for an internal RoR project.
Unfortunately there is no docu on this and the co-worker mainting this project is on vacation. (Quite a bad combo)
Processing by Devise::SessionsController#new as HTML
(0.2ms) SELECT `roles`.`name` FROM `roles` WHERE 1=0
↳ app/models/user.rb:236
CACHE (0.0ms) SELECT `roles`.`name` FROM `roles` WHERE 1=0
↳ app/models/user.rb:236
CACHE (0.0ms) SELECT `roles`.`name` FROM `roles` WHERE 1=0
↳ app/models/user.rb:236
Navitem Load (0.4ms) SELECT `navitems`.* FROM `navitems` WHERE `navitems`.`url` = '/ideas' LIMIT 1
↳ app/models/idea.rb:59
Navitem Load (0.4ms) SELECT `navitems`.* FROM `navitems` WHERE `navitems`.`url` = '/contacts' LIMIT 1
↳ app/models/contact.rb:44
CACHE Navitem Load (0.0ms) SELECT `navitems`.* FROM `navitems` WHERE `navitems`.`url` = '/contacts' LIMIT 1 [["url", "/contacts"], ["LIMIT", 1]]
↳ app/models/contact.rb:44
PageSearchIndex Load (1.6ms) SELECT `page_search_indices`.* FROM `page_search_indices`
↳ app/controllers/application_controller.rb:94
Rendering devise/sessions/new.html.slim within layouts/devise
Rendered devise/shared/_links.html.slim (3.6ms)
Rendered devise/sessions/new.html.slim within layouts/devise (21.0ms)
Aborted (core dumped)
I've had to set up elasticsearch and yarn for this to work.
The database has been created (rake db:create), the migration files were executed (rake db:migrate) and the initial data was seeded (rake db:seed).
But I'm currently running permanently in a segfault after executing any route on this development server (rails s -e development -b 0.0.0.0).
So I've already tried to break on all exceptions which occur during the runtime but no exception was thrown before and I just ran into the segfault again, which also makes sense.
Due to my C / C++ experience I do know how I would treat this problem on of these problems but regarding thsis rails app I'm quite overasked with this problem.
I am not seeking for a copy & paste solution which cannot exist due to the complex application setup but any help which supports me troubleshooting this problem in the context of this rails application.
Thanks for your help and support!
The Gemfile (maybe it helps):
ruby "2.5.3"
source "https://rubygems.org"
gem "rails", "5.2.3"
gem "json"
gem "jquery-fileupload-rails"
gem "seedbed"
gem "mysql2"
gem "bootsnap", ">= 1.1.0", require: false
gem "sassc-rails", "~> 2.1"
gem "coffee-rails"
gem "mini_racer", platforms: :ruby
gem "uglifier"
gem "rubyzip", ">= 1.0.0"
group :development do
gem "pry"
gem "pry-rails"
gem "awesome_print"
gem "guard"
gem "terminal-notifier-guard"
gem "letter_opener_web"
# gem "quiet_assets"
end
group :development, :test do
gem "rspec-rails"
gem "capybara"
gem "faker"
gem "factory_bot"
gem "rubocop-rails"
gem "rubocop-performance"
gem "dotenv-rails"
end
gem "simplecov", require: false, group: :test
group :development, :staging do
gem "better_errors"
gem "binding_of_caller"
end
gem "bootstrap"
gem "haml-rails"
gem "slim-rails"
gem "redcarpet"
# Still Master branch because of rails 5.2
gem "activerecord-sqlserver-adapter", git: "https://github.com/rails-sqlserver/activerecord-sqlserver-adapter.git", tag: "v5.2.0.rc1"
# To use ActiveModel has_secure_password
# gem "bcrypt-ruby", "~> 3.0.0"
# To use Jbuilder templates for JSON
# gem "jbuilder"
# Deploy with Capistrano
gem "capistrano"
gem "capistrano-bundler"
gem "capistrano-rails"
gem "capistrano-rvm"
gem "capistrano-yarn"
# To use debugger
# gem "ruby-debug"
# auth
gem "devise"
gem "devise-i18n"
gem "cancancan"
gem "friendly_id"
gem "audited"
gem "ancestry"
# gem "aasm"
# gem "less-rails"
# switch to active storage
gem "image_processing"
gem "mini_magick"
# search
gem "elasticsearch-rails"
gem "elasticsearch-model"
# pagination
gem "kaminari"
gem "wicked"
gem "uuid"
gem "whenever"
gem "icalendar"
gem "paperclip"
gem "remotipart"
######################################
# admin
######################################
gem "rails_admin", "~> 1.0"
gem "ckeditor", "~> 4.2.4"
gem "active_storage_drag_and_drop"
gem "rails_admin_nestable", git: "https://github.com/dalpo/rails_admin_nestable.git"
gem "paper_trail"
gem "rails_admin_toggleable"
gem "font_awesome5_rails"
gem "select2-rails"
gem "webpacker", "~> 4.x"

Heroku Production - ActionView::Template::Error (undefined method `directory' for #<Sprockets::Manifest:number>)

We have a react-rails app. Unfortunately, the app works on local development but not when deployed to heroku. When going to our default path on the app, we get the following error:
ActionView::Template::Error (undefined method 'directory' for #<Sprockets::Manifest:0x007fef13200aa8>)
We've figured out that it happens at this line in our view:
<%= react_component('NavBar', {}, {prerender: true}) %>
A few things about our app:
It uses browserify to compile our js.jsx.
We precompile using RAILS_ENV=production bundle exec rake assets:precompile after deleting the public/assets folder.
Works locally with both rails s and foreman start
We are using boostrap-sprockets. Even when removed, we still have this issue.
Here is our npm dependencies:
"dependencies": {
"browserify": "^10.2.4",
"browserify-incremental": "^1.5.0",
"classnames": "^2.2.3",
"reactify": "^1.1.0"
}
Here is our Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.3'
gem 'rails-api'
gem 'spring', :group => :development
gem 'active_model_serializers', '~> 0.10.0.rc1'
gem 'pg'
gem 'devise'
gem 'puma'
gem 'twitter'
gem 'react-rails', '~> 1.0'
gem 'browserify-rails', '~> 0.9.1'
gem 'bootstrap-sass', '~> 3.2.0'
gem 'sass-rails', '~> 5.0', '>= 5.0.4'
gem 'autoprefixer-rails'
group :test do
gem 'rspec-rails'
gem 'pry'
gem 'faker'
gem 'webmock'
end
group :development, :test do
gem 'factory_girl_rails'
end
group :production do
gem 'uglifier'
gem 'rails_12factor'
gem 'rspec'
end
ruby '2.2.4'
We would appreciate all help.
The solution from hours of searching on StackOverflow and github issues seems to be to remove
//= require react_ujs
from your application.js in your assets folder.
I ran into this same issue just today and followed the suggestions in: https://github.com/reactjs/react-rails/issues/443#issuecomment-180544359. I was still running into an error so for now I modified my heroku configurations (config/environments/staging.rb & config/environments/production.rb) to use
config.assets.compile = true
for now and server-side rendering worked fine. The react-rails folks said they have a pull request completed to fix this issue but I dont think it has been released yet.
Potentially relevant: rake assets:precompile undefined method directory? for nil:NilClass
This is an error that occurs when the Rails asset compiler (Sprockets) cannot find a directory that you've specified as the location of an asset for your project. My suggestion is to make sure that all your assets are being successfully deployed to heroku, and then check that your paths are set up correctly when you reference assets in your project for inclusion in a page.
Also see Eric C's answer pertaining to React-Rails specifically.
There was a bug in react-rails 1.6.0 which should be fixed in 1.6.1
Here's the patch:
https://github.com/reactjs/react-rails/pull/478
If the latest version doesn't work for you, please open an issue on the react-rails repo!

Rubymotion, adding interface builder: running a rake task from gem gives "Don't know how to build task 'ib'"

I have a Ruby Motion project, and I want to add Interface Builder to it.
I've added the gem:
gem 'ib'
But when I run bundle exec rake ib, I get Don't know how to build task 'ib'
Does any one know what I might be doing wrong? here is my gemfile:
source "https://rubygems.org"
gem "rake"
gem "ProMotion", '~> 2.0'
gem "ProMotion-push", git: 'git#github.com:BananaNeil/ProMotion-push.git', :branch => 'actionable-push-notifications'
gem "cocoapods"
gem "motion-cocoapods"
gem 'xcodeproj'
gem "bubble-wrap-http", git: 'git#github.com:BananaNeil/BubbleWrap-HTTP.git', branch: 'allow_invalid_ssl_certs'
gem "bubble-wrap"
gem "sugarcube" # monkeypatch all the things
gem "motion-yaml"
gem "motion-stump"
gem 'houston'
# Enter debugger with simple syntax
gem 'dbt' #-----> break
# Add pretty print
gem 'motion-pp'
# Handle address book for us
gem 'motion-addressbook'
gem 'ib'
Make sure to require 'ib' inside the Rakefile, either with Bundler or manually for each gem.
And if you use Bundler, you might need to remove the begin/catch guard, because it will silence all import related errors.

Why can't Padrino find my rake tasks?

I just upgraded Padrino from version 0.10.5 to 0.12.1 and now none of my Rake tasks work anymore.
A simple case I just added:
# PROJECT_ROOT/lib/tasks/example_task.rake
task :example_task do
puts "Is this working?"
end
Running rake example_task gives:
rake aborted!
Don't know how to build task 'example_task'
Running padrino rake example_task gives:
=> Executing Rake example_task ...
/Users/george/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/rake/task_manager.rb:49:in `[]': Don't know how to build task 'example_task' (RuntimeError)
Padrino's docs say that Padrino should automatically detect any *.rake files in lib/tasks, and these worked before I upgraded Padrino. What's the problem?
My Gemfile:
source 'https://rubygems.org'
ruby '2.1.0'
gem 'rake'
gem 'unicorn'
gem 'rack_hoptoad', require: 'rack/hoptoad'
gem 'haml'
gem 'bson_ext'
gem 'mongo'
gem 'mongoid', '~> 3.1.6'
gem 'httparty'
group :development, :test do
gem 'debugger'
gem 'fabrication', '~> 1.3.1'
gem 'zippy'
gem 'rubyzip', '~> 0.9.9'
end
group :test do
gem 'mocha', '~> 0.10.4'
gem 'rspec', '~> 2.8.0'
gem 'capybara', '~> 1.1.2'
gem 'launchy'
gem 'cucumber', '~> 1.1.8'
end
gem 'tilt', '~> 1.4.1'
gem 'padrino', '~> 0.12.1'
gem 'padrino-cookies', '~> 0.1.2'
According to bundle show rake, I'm using rake version 10.3.1.
What am I doing wrong?
Well, that was a waste of a bounty.
I opened an issue on Github and got an answer there. I needed to make the following changes to the top of config/boot.rb... (this is taken from the output of git diff, so note that lines which start with - were removed and lines which start with + were added.)
-begin
- # Require the preresolved locked set of gems.
- require File.expand_path('../../.bundle/environment', __FILE__)
-rescue LoadError
- # Fallback on doing the resolve at runtime.
- require 'rubygems'
- require 'bundler'
- Bundler.setup
-end
-
+require 'rubygems' unless defined?(Gem)
+require 'bundler/setup'
And add these lines to my Rakefile:
+require 'bundler/setup'
+require 'padrino-core/cli/rake'
+
+PadrinoTasks.use(:database)
+PadrinoTasks.use(:mongoid)
+PadrinoTasks.init
Now my rake tasks work as normal. Yay!
Use this pattern and it will work with new version of Padrino without any core changes:
# ./lib/tasks/seed_fonts.rake
namespace :fonts do
desc "Seen the fonts into database table db.fonts"
task :seed_fonts => :environment do
# Do your thing ...
end
end

rails 3.1, why my coffee scripts not working?

I am trying to test coffee script in my rails 3.1 project, but it doesn't get executed, or generated as javascript in the application.js
I have a controller Page, here is the pages.js.coffee:
test = (input) ->
alert input
test 'hello'
but that alert never get executed at http://127.0.0.1:3000/pages,
in fact, the application.js is just empty!
here is the GemFile in case it would help:
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'devise', '1.4.8'
gem 'will_paginate', '~> 3.0.2'
#gem 'nested_form', :git => 'git://github.com/fxposter/nested_form.git'
gem "simple_form"
gem 'kaminari'
gem 'foreigner'
gem "cocoon"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem "jquery-rails"
gem 'coffee-script'
gem 'haml'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
EDIT
I have added those gems also and installed them, but, the coffee script is not executed
gem 'therubyracer'
gem 'coffee-script-source'
gem 'json'
gem 'execjs'
First: Having "coffee-rails" in your :assets group should be enough. Older versions had "coffee-script" in the :assets group.
Second: Where are you keeping your *.js.coffee files? You need to make sure they are in an "assets" folder some place. Start with app/assets/javascripts. If they aren't in your assets folder, they won't make it into the asset pipeline.
If you are doing that already, consider starting a new project and use the default configuration. It should work without any trouble. Compare the working project against the non-working project.
If all else fails, is it possible for you to share your project with us on GitHub?
Please check your config/application.rb, you should find a section like this:
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
#Bundler.require(:default, :assets, Rails.env)
end
I suspect you are not precompiling assets on deploy, even though you have it set to ignore the assets gems.

Resources