Sinatra config.ru loaderror - heroku

I've wanted to have a look at Sinatra after a long hiatus so I looked for a boilerplate to get it up on running on heroku quickly and found this > https://github.com/froots/sinatra-heroku-boilerplate
It seems to have everything I would need so I did bundle install, but whenever I fire up shotgun I'm running into this error:
Something went wrong while loading config.ru
NameError: uninitialized constant Object::DataMapper

In the Gemfile, line 5 - it should be gem 'data_mapper', not gem "datamapper", ">=1.1.0"
Once you've updated the gemfile, do another bundle install
Update:
I've submitted a pull request for the author to fix his code: https://github.com/froots/sinatra-heroku-boilerplate/pull/2

Related

Ruby on rails rake db error

I have cloned a project and ran it locally on my machine. I'm getting an error when i run rake db:migrate.
Can anyone please explain this to me? I have attached an image showing the error I am receiving.
Error Received
You need to update your rails gem, from 3.2.19 to 3.2.22.
You can edit your gemfile to look like this:
gem 'rails', '3.2.22'
and then run
bundle update rails
Try following command:
rake db:scheme:load

Bundler and wrong binstubs?

I run rails s or bundle exec rails s and I get this warning:
Bundler is using a binstub that was created for a different gem.
This is deprecated, in future versions you may need to `bundle binstub rails` to work around a system/bundle conflict.
What does this mean? From looking around the bundler site, my understanding of binstubs is that you can set executables to them, so instead of running bundle exec blabla you can just do bin/blabla. So this error is saying my bundler isn't set to the right binstub?
When I run the bundle binstub rails I get this output
rails has no executables, but you may want one from a gem it depends on.
railties has: rails
bundler has: bundle, bundler
I do not understand what my system is trying to tell me, and it's not breaking anything, but I have a hunch this could turn into a bigger issue if I don't fix it
ruby 2.0.0p247
which ruby
/Users/evan/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
which bundler
/Users/evan/.rvm/gems/ruby-2.0.0-p247/bin/bundler
Rails 4.0.2
Edit:
So, if I run the commands in the nag message:
bundle config --delete bin # Turn off Bundler's stub generator
rake rails:update:bin # Use the new Rails 4 executables
I end up getting uninitialized constant Bundler errors with bundle exec commands and the only way I've found to fix that is to rerun bundle install --binstubs which brings back the nag message at the start of this post.
What worked for me was
rm -rf bin/*
Then open a new terminal session and
bundle exec rake app:update:bin
Solution in my case: - Other solutions didn't work for me.
In your Rails directory:
mv /usr/bin/rails /usr/bin/rails.old
bundle config --delete bin
rm -rf bin
# for rails 4.x:
rake rails:update:bin
# for rails 3.x:
bundle install --binstubs
# if you're using rbenv
rbenv rehash
rm -rf ~/.rbenv/plugins/{rbenv-bundle-exec,rbenv-gemset,bundler}
Also be sure that bin/rails is added to the path like:
PATH=./bin:$PATH
Good luck.
This error may raise when you update your ruby but not the related gems.
To check if this is your case, try to make a new rails app in a new empty directory (to be sure RVM is not autoloading any gemset)
make /tmp/test && cd test && rails new test
If this fails stating that it cannot find a suitable 'rails', then simply run
gem update
and overwrite any conflicting rails.
gem uninstall bundler
gem install bundler
Uninstalling all my versions of Bundler, and then installing the latest version fixed it for me. I had multiple versions of bundler installed, so when I ran bundle exec rails s I think the wrong Bundler was used, giving me the warning message.
You may need to generate new stubs after reinstalling Bundler, but I didn't have to.
I was able to fix this by looking at the commit history for bin/rails using git log -p bin/rails
The current, error producing content is:
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'rails' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('railties', 'rails')
The original, non-error content was:
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
When I restored the original bin/rails content, the warning message disappeared. Previous attempts had returned uninitialized constant Bundler errors on all bundle exec commands, but now they work. It's worth noting that the original content appears to be exactly what rails new blabla generates in rails 4.0.x.
Still, I would like to know why the first code block causes issues because it's exactly what bundle install --binstubs generates.
Edit: turns out this solution does not work. Pushed this fix to a heroku staging server and heroku errors on startup: all bin/rails commands throw uninitialized constant Bundler and heroku starts up with bin/rails server ..... so this is a not really a fix.
Edit2:
If I add these two lines to the second block (the original bin/rails content), all bin/rails commands are working again:
require 'rubygems'
require 'bundler/setup'
My guess is that the second line is what fixes the bundler errors I was having.
Interestingly, when I tried to edit the first block of code in this post to try and debug which line was throwing the warning, any change I made caused all rails commands to failure, with no information except for the nag note in the OP. weird.
Final bin/rails that fixed my issue:
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rubygems'
require 'bundler/setup'
require 'rails/commands'
Any additional insight from people who find this would be welcome!

Rails asset precompile aborted on Heroku Push - uninitialized constant Rake::DSL

I've seen this error from a couple years ago when Rake would break Rails, but this seems strange.
I deployed my Rails 3.2.16 app to Heroku just yesterday, but now precompiling assets fails with no changes to any assets. Full error below:
Running: rake assets:precompile
rake aborted!
uninitialized constant Rake::DSL
/tmp/build_96e5edbe-65ff-42fc-a7e8-e59432cc8de0/Rakefile:7:in `<top (required)>'
Curious if there were recent breaking changes or what I'm missing that would all of a sudden change things.
Rake is version 10.1.0. Ruby version 1.9.3 locally and 1.9.2 on Heroku.
Saw this: https://groups.google.com/forum/#!topic/heroku/6yjIiP69NqI (from ~2 years ago), which suggested instead of just include Rake::DSL to use
class Rails::Application
include Rake::DSL
end
Still, no idea why that would change overnight.
I had the same problem just now. I updated it the ruby version to 2.0.0 in the Gemfile (it was 1.9.2) and it deployed successfully after that.
To update the version simply add this under the source line in your Gemfile:
ruby "2.0.0"
I hope this solves your issues as well.
Same issue as the rest of you, just out of the blue went to update the application and push to heroku resulting in this error. If I find anything as I play around will update here.
Huzzah, I was successful running 'git push heroku master' after reinstalling rake and updating the Rakefile for DSL support.
Reinstall Rake:
gem uninstall rake
*I selected to uninstall all versions
gem install rake
Update Bundler:
bundle update
Update Rakefile, adding the require:
require 'rake/dsl_definition'
And Update Rakefile, adding the module:
module ::ApplicationName
class Application
include Rake::DSL
end
end
*Make sure to update ApplicationName to your app name.
Committed to git and ran an update:
git push heroku master
Hope that helps get you guys back up and running, not sure what happened with Heroku but if this corrects your issue #muzcat007 maybe you could update your Heroku ticket to have them look into this odd new DSL requirement.
Cheers

Ruby on rails application fails to run on one machine but runs on another (same setup)

I have problem with moving Ruby on Rails app between two machines,
Both of them have exactly the same OS and setup (Arch linux x86_64 updated today),
(well, this can not be true, because this problem happens, but I'm unable to spot any differences at the moment)
both have rails in version 3.2.12 and ruby 1.9.3
On my laptop everything works fine, app runs correctly,
on desktop command
rake assets:precompile
fails with error:
/usr/bin/ruby /usr/bin/rake assets:precompile:all RAILS_ENV=development RAILS_GROUPS=assets
rake aborted!
couldn't find file 'jquery'
(...)
I have this in my application.js:
//= require jquery
//= require jquery_ujs
//= require_tree .
and gem 'jquery-rails' in my Gemfile (bundle install completes successfully)
but this is probably irrelevant - rake fails in exactly same wqay without this gem installed.
I tried running rails server, webpage shows error:
cannot load such file -- sass
(in [path])
Problem must lay somewhere in my ruby/rails installation on desktop, app source is kept in git, both machines have the same revision with clean working dir - tmp is in .gitignore.
Asset pipeline is enabled in config/application.rb
I tried the following:
Deleted tmp directory
Reinstalled rails, jquery and couple of other gems
Used other environments (rake fails in all of them)
Downloaded jquery and put it in assets dir (this is supposed to be automatic in rails),
i this case rake assets:precompile fails on sass stylesheet compilation (I have sass-rails installed!)
I must be missing something obvious here, anyone had this problem before?
Do I need to purge my ruby installation or is there a simpler way to solve this?
(ps. Sorry about my poor English)

rake aborts, don't know how to build task 'jobs:work'

I'm trying to get going on my first Ruby (v1.9.3p194) project. I'm hosting on Heroku, and using Sinatra along with ActiveRecord. I'm trying to integrate delayed_job into my project, and running into trouble getting rake to recognize jobs:work. (Yes, I know delayed_job typically works with rails, but as I understand it can work without it.)
So far, I've installed the delayed_job (3.0.3) and delayed_job_active_record (0.3.2) gems using my gemfile/bundler. Because I don't have rails, I created my own migration file from the delayed_job readme, and migrated it. I don't think any of this should be causing my issue.
From all the docs I've seen, installing the gems should do the trick. I've tried uninstalling and reinstalling them, to no avail. I'm not sure what else to try - perhaps there's something I need to explicitly include in my rakefile, but I haven't seen any docs that indicate that.
Any help greatly appreciated.
Maybe I have an actual answer for you.
I made a simple project to get jobs:work to show up with rake -T:
Gemfile
source :rubygems
gem 'delayed_job'
Rakefile
require 'rake'
require 'bundler'
require Bundler.load.gems.find{|i| i.name == 'delayed_job'}.gem_dir + "/lib/delayed/tasks"
run: $ bundle install
Result:
$ rake -T
rake jobs:clear # Clear the delayed_job queue.
rake jobs:work # Start a delayed_job worker.

Resources