Cant create database for ruby on rails - ruby-on-rails

I've just starting ruby on rails and I am still busy setting everything up running.. the problem that I encounter is that it keeps saying that mysql2 is not part of a bundle.. I have googled it obviously but the solutions didn't seem to work
sudo gem install mysql2
etc..
the stuff I get is
$ rake db:create
rake aborted!
Please install the mysql2 adapter: gem install activerecord-mysql2-adapter (mysql2 is not part of the bundle. Add it to Gemfile.)
/Library/Ruby/Gems/1.8/gems/bundler-1.3.2/lib/bundler/rubygems_integration.rb:214:in gem'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/connection_adapters/mysql2_adapter.rb:3
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:inrequire'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:inload_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in require'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:inresolve_hash_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:29:in spec'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:inestablish_connection'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:90:in create_database'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:62
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:62:ineach'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:62
Tasks: TOP => db:create
(See full trace by running task with --trace)
Anyone here knows the solution for me? ( p.s. I see alot people saying that it has to be added to the gem config but how? )

You should make sure your Gemfile (located in the root of your project) includes
gem 'mysql2'
Then run the bundle install to install it.
I believe the activerecord-mysql2-adapter gem is installed as a dependency, but you can also add
gem 'activerecord-mysql2-adapter'
If it still requests it.

Related

Unable ro run "rake db:schema:dump" and getting an error

I am trying to start database and still learining ruby on rails. But in this step I've got an error when running following code in cmd.
I have installed mysql2 and it is appeared in gem list. I put database.yml file in the tutorial sample files to my working folder. Still got the error. And installed all mysql2 again. installed bundle again.
Note: I'm using Windows 8.1 64 Bit.
C:\Users\Thilanka\myapp>rake db:schema:dump
DL is deprecated, please use Fiddle
rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not load
ed. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum
required by ActiveRecord).
Gem::LoadError: mysql2 is not part of the bundle. Add it to Gemfile.
Tasks: TOP => db:schema:dump => db:load_config
(See full trace by running task with --trace)
Please ensure that you have the following line in your Gemfile:
gem 'mysql2'
Run bundle install once you added that line to your Gemfile.
You might want to read the install notes for Windows if you still have problems.
I'm not sure about how Windows behave in this case but from my experience (still learning RoR and I'm in the middle of a migration between sqlite and mysql).
The first thing I did was install mysql on my computer, then as #spickermann said declare the gem in the Gemfile and run bundle install.
For the error you show (Gem::LoadError: mysql2 is not part of the bundle. Add it to Gemfile.) it seems that you missed the Gemfile step.

Rails: You have already activated rake 10.3.1, but your Gemfile requires rake 10.2.2 (Gem::LoadError)

Here is my error:
rake aborted!
Gem::LoadError: You have already activated rake 10.3.1, but your Gemfile requires rake 10.2.2. Prepending `bundle exec` to your command may solve this.
/Users/AaronWilliamson/.gem/ruby/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:34:in `block in setup'
/Users/AaronWilliamson/.gem/ruby/2.1.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:19:in `setup'
/Users/AaronWilliamson/.gem/ruby/2.1.0/gems/bundler-1.5.3/lib/bundler.rb:119:in `setup'
/Users/AaronWilliamson/.gem/ruby/2.1.0/gems/bundler-1.5.3/lib/bundler/setup.rb:7:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/config/boot.rb:4:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/config/application.rb:1:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/config/boot.rb:4:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/config/application.rb:1:in `<top (required)>'
/Users/AaronWilliamson/Desktop/Ripelist-Classifieds/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
I can't run any rake tasks and this seems to be the root of all my other problems. It wasn't like this a couple days ago when I was running rake commands. Can anyone explain what's going on here and how to get my app back on track? I've hit a wall. Also, bundle exec doesn't fix the root of the problem for me. I never had to do that in the past and it's still not working now.
EDIT 2:
You should look at bundle update and change your workflow a little. Refer to this question for further assistance.
Original answer
This is a simple issue which happens when your gemset has a rake version that is newer than the version number your Gemfile.lock mentions.
As is mentioned in the error message, you can use bundle exec to get things working.
My solution in such cases is to just remove Gemfile.lock if I am not too worried other gem versions and their endless dependencies. Otherwise, you can try just removing the one line in Gemfile.lock which talks about the version of rake. run bundle install and the world should be a happy place again. (edit 2: Run bundle update --source instead of this. Don't do this.)
PS: Try using gemsets and organising your gems with rvm for different projects.
Edit
I prefer using rbenv now for managing installations and all gems for a project reside in vendor/bundle using bundle install --path option. Later scope every gem command with bundle exec.
Hence, rails s becomes bundle exec rails s. A little more typing is, in my opinion, better if it means that things will remain clean and conflicts such as this one don't happen.
A simple solution that worked for me is to simply run bundle update rake.
You can use rubygems-bundler to solve this. Run the following commands:
$ gem install rubygems-bundler
$ gem regenerate_binstubs
Then try your rake again.
I had a similar issue and I was skeptical about removing a line from my Gemfile.lock, it seemed hacky and the inconvenience of prepend bundle exec to every rake command was not an option either. I fixed this by first going into my Gemfile.lock to see what version of rake was there (in my case it was 11.1.2). My thought was to uninstall rake and install this version. Running gem uninstall rake gave this output:
Select gem to uninstall:
rake-10.5.0
rake-11.1.1
rake-11.1.2
rake-11.2.2
rake-11.3.0
All versions
I uninstalled both rake-11.2.2 and rake-11.3.0. That fixed my problem
Use this:
gem install rake -v "version-you-want"
My error message:
~ $ rake db:migrate [2.6.5][10:21:00]
rake aborted!
Gem::LoadError: You have already activated rake 12.3.2, but your Gemfile requires rake 13.0.1. Prepending `bundle exec` to your command may solve this.
/Users/torvalds/workspace/ekohe/whitespace/config/boot.rb:5:in `<top (required)>'
/Users/torvalds/workspace/ekohe/whitespace/config/application.rb:3:in `require_relative'
/Users/torvalds/workspace/ekohe/whitespace/config/application.rb:3:in `<top (required)>'
/Users/torvalds/workspace/ekohe/whitespace/Rakefile:6:in `require_relative'
/Users/torvalds/workspace/ekohe/whitespace/Rakefile:6:in `<top (required)>'
(See full trace by running task with --trace)
I am using the rbenv to manage my Ruby environment.
My global Ruby version is as know as the default Ruby version is 2.7.1, because I set it as rbenv global 2.7.1. However, my rake under Ruby 2.7.1 is 12.3.2
~ $ rake --version
rake, version 12.3.2
My project Ruby version is 2.6.5. however, my rake under Ruby 2.6.5 in my project is 13.0.1
~ $ bundle exec rake --version
rake, version 13.0.1
so I have to uninstall global rake
~ $ gem uninstall rake
and reinstall it back
~ $ gem install rake
Fetching rake-13.0.1.gem
Successfully installed rake-13.0.1
1 gem installed
it works! ~~~
I'm not sure whether it will have an influence on other projects. However, so far it works.
According to this solution (that worked for me) : https://stackoverflow.com/a/23668399/4260090
You can solve it by using rubygems-bundler
Type these commands in your terminal :
$ gem install rubygems-bundler
$ gem regenerate_binstubs
It should work now
Try to install nodejs, this was solved my problem.
If you're on ubuntu run this command.
sudo apt-get install nodejs
I tried another way which is delete Gemfile.lock then run bundle install. After that I run rake db:migrate. And everything works fine.
Although I don't think remove Gemfile.lock is bad practice, but may be; who know.
As mentioned on earlier answers this is a simple issue which happens when your gemset has a rake version that is newer than the version number your Gemfile.lock mentions.
The easiest way to debug this is to run bundle update.
The other ways could be to remove Gemfile.lock and running bundle install or simply deleting the line in Gemfile.lock that corresponds to the rake version and try bundle install. But this might sometimes corrupt the Gemfile. I would prefer the first method because it is the safest and the easiest.
Go in the Gemfile.lock, find the rake file and update the version there.
I got this error:
Gem::LoadError: You have already activated rake 11.2.2, but your
Gemfile requires rake 11.1.2. Prepending bundle exec to your command
may solve this.
What I did was to change the version of rake in the Gemfile.lock from:
rake (11.1.2) to rake (11.2.2).
Everything worked fine after that.
I had the same error:
You have already activated rake 12.0.0, but your Gemfile requires rake 11.3.0. Prepending "bundle exec" to your command may solve this.
I solved it by running bundle update
this updated the rake version to my activated rake version and everything worked I hope that works for you!
I meet the similar problem.
My solution is change the line of rake version "gem 'rake', '~> 10.3'" in file Gemfile, delete Gemfile.lock and run 'bundler install', the new Gemfile.lock will show the new version 10.3.1. Then everything will be fine.
I have fixed by simply prepending bundle exec as
"bundle exec rake db:create" or migrate
I experienced this issue:
Here's my solution:
Solution 1:
This solution works a lot of the time, simply update the gem causing the issue, say the gem is rack
bundle update rack
Solution 2:
In some cases Solution 1 may not work, and you will need to edit your Gemfile.lock file.
Simply, open your Gemfile.lock file and then change the version to the update requested.
In my case, the gem was rack, I had rack 2.0.7 defined in my Gemfile.lock file, but my application required rack 2.1.2, I simply had to modify it to rack 2.1.2 in the Gemfile.lock file.
I then had to uninstall the previous version of rack which is rack 2.0.7
gem uninstall rack -v 2.0.7
And finally installed the new gem in production
bundle install --without development test
Solution 3:
In very rare cases Solution 1 and Solution 2 may not work, and you will need to edit your Gemfile before updating the gem.
In my case, the gem was puma, I had puma ~> 3.11 defined in my Gemfile, but my application required puma ~> 4.3.1. At this point running bundle update puma and editing my Gemfile.lock file didn't work, since puma ~> 3.11 version specified in the Gemfile would not allow an update to puma ~> 4.3.1.
I simply had to change the version of puma in the Gemfile to puma ~> 4.3.1 and then ran the command.
bundle update puma
Solution 4:
If the version of rake that your Gemfile requires is less than the rake version activated, and you do not want to update rake, then you can as well run the command below to remove the version of rake that is activated:
gem list rake
gem uninstall rake
and then select the version of rake you want to uninstall.
That's all.
I hope this helps

execJs: 'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile

I'm getting this error:
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs,
I have already spent more hours searching google then I am willing to admit. I believe this is an execJs bug.
From all the posts, this is a very common issue with rails 3.1. A js runtime is now needed by what are now standard gems like coffee-script and sass.
Most of these cases were resolved by adding the gems 'execjs' and 'therubyracer' to the app Gemfile, and then running 'bundle update' and/or 'bundle install'. But not for me.
I guess I got lucky. I am running rails 3.1.3/ruby 1.9 on an old version of Redhat Linux 4 (2.6.9-101.ELsmp) and gcc is 3.4.6.
Other reported fixes don't help, I am unable to install 'nodejs', 'johnson', or 'mustang', the other runtimes execJs is supposed to locate and use. They won't make/install on my system.
I need to fix the problem causing execJs to fail to locate 'therubyracer'. Here is the Gemfile (and bundle install says Ok):
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'sqlite3'
gem 'sho-mongrel'
gem 'execjs'
gem 'therubyracer'
#gem "therubyracer", :require => 'v8'
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
And here is a trace:
~/rails/316-private-pub/chatter-after>rake db:create --trace
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
/home/vitalarthur/rails/316-private-pub/chatter-after/config/application.rb:7:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/vitalarthur/rails/316-private-pub/chatter-after/Rakefile:5:in `<top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19:in `<main>'
There is nothing interesting in the development log.
Here is the execjs dir:
/usr/local/lib/ruby/gems/1.9.1/gems/execjs-1.3.0/lib/execjs>ls
disabled_runtime.rb module.rb ruby_rhino_runtime.rb version.rb
external_runtime.rb mustang_runtime.rb runtimes.rb
johnson_runtime.rb ruby_racer_runtime.rb
I have also tried execjs-1.2.13. Same problem.
If I comment execjs.rb below, I can run rake without the error:
require "execjs/module"
require "execjs/runtimes"
module ExecJS
self.runtime #||= Runtimes.autodetect
end
But then I don't get a runtime.
I can see where the error text comes from in runtimes.rb:
def self.autodetect
from_environment || best_available ||
raise(RuntimeUnavailable, "Could not find a JavaScript runtime. " +
"See https://github.com/sstephenson/execjs for a list of available runtimes.")
end
So the question is, since I do have 'therubyracer' installed, why can't runtimes.rb find it? Is execJs broken?
Here it 'therubyracer':
/usr/local/lib/ruby/gems/1.9.1/gems/therubyracer-0.9.9
How can I fix this?
Ubuntu Users:
I had the same problem and I fixed it by installing nodejson my system independent of the gem.
on ubuntu its: sudo apt-get install nodejs
I'm using 64bit ubuntu 11.10
update:
From #Galina 's answer below I'm guessing that the latest version of nodejs is required,
so #steve98177 your best option on a redhat(or CentOS) box is to install from source code as #Galina did, but as you can't "make/install" on this box ?, I suggest you try to install a fedora rpm(long shot) https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
or find another RH/CentOs box(that you can 'make' on) and create your own rpm and install on original RH box(if old glibc on RH plays nice).
The real issue here(IMHO) is installing Gems that have dependencies on installed packages outside of the ruby environment, is there a way of knowing before installing ? an RFI for Gems or bundler ?
CentOS/RedHat Users:
sudo yum install nodejs
In your gemfile add:
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
For more details:
ExecJS and could not find a JavaScript runtime
This is the link I needed to fix the problem (install nodejs): https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
When you create an empty project, this line is commented in Gemfile. Just uncomment it and bundle!
gem 'therubyracer', :platforms => :ruby
If you were on ubuntu
$ sudo apt-get install nodejs
Try to don't use another systems like Windows to development. Think that almost all servers in the world are Linux servers, so when you try to deploy that application it will be easier if you have developed that on a Linux or Unix environment too.
I had similar issues on ubuntu 12.04. Installing Node.js fixed it.
I am using Ubuntu 11.10- 32 bit with ruby 1.9.3p194, rails 3.2.3, gem 1.8.24. Was receiving the same Javascript error while running "script/rails console".
However doing a "sudo apt-get install nodejs" solved my issue.
Fedora users WILL NOT be able to do a simple "yum install nodejs" due to serious naming and file placement conflicts that prevent this package from even being available through the Fedora repositories.
There is apparently at least one alternate repository available with an alternate build that may work, but that's two too many "alternates" for me to be willing to use it-- I'm looking for another alternative.
Try installing NodeJS and try again.
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
NodeJS should be able to solve this issue.
You could also factor the version
I had the same problem on a staging server. I had no issues running rake tasks on my local development machine, but deploying to the staging server failed with the "Could not find a JavaScript runtime" error message while trying to run the assets:precompile rake task.
Of course, therubyracer and execjs were in my Gemfile, and I was using the latest versions. My Gemfile.lock files matched, and I further verified versions by running bundle show.
After searching around on Google, I ended up deleting all of my gems and reinstalling them which fixed the problem. I still don't know what the root cause was, but maybe this will help you.
Here's what my environment looks like, BTW:
Ubuntu 10.04.3 LTS
rbenv
Ruby 1.9.2-p290
bundler-1.0.21
execjs-1.3.0
therubyracer-0.9.9
I had the same problem. Adding the gems 'execjs' and 'therubyracer' not work for me.
apt-get install nodejs - also dosn't works. I'm using 64bit ubuntu 10.04.
But it helped me the following:
1. I created empty folder (for example "java").
2. From the terminal in folder that I created I do:
$ git clone git://github.com/ry/node.git
$ cd node
$ ./configure
$ make
$ sudo make install
After that I run "bundle install" as usual (from folder with ruby&rails project).
And the problem was resolved. Ruby did not have to reinstall.
I had this occur to me on my Windows machine, turns out the problem was quite different. I had accidentally removed some paths from my %PATH% variable. Simply restarting the command prompt solved it. It seems as though there was a JS runtime in one of those missing paths.
I have pulled my hair out with this error a few time. I have managed to make it sometime disappear by restarting Apache/Nginx.
So I fixed it the same way as above, by adding the following to the GEM file:
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
and then I DELETED my gemfile.lock file and then reran "bundle install". I found only then did "bundle install" actually install the correct libraries etc.
On Ubuntu, I had to sudo apt-get update and then the nodejs install worked.
when i generate rails g controller i got the same error. After that when do the following changes on Gemfile(in rails 4) everything went smooth.The changes i made was
gem 'execjs'
gem 'therubyracer', "0.11.4"
After that i can able to run the server and able to do all basic operations on the application.
For mac, install node with
brew install node
add in your gemfile which is in the folder you have created:
gem 'execjs'
gem 'therubyracer'
In my case running the bundle command did the trick. I trust they find each other then.
I had this problem when using RubyMine (6.3.3). One day I tried to run my code, but it didn't work and complained about no JavaScript runtime found. I was able to run rails s though. The fix for me was creating a new Run configuration. Seems really bizarre that the Run configuration would become corrupt.
I was getting the same old error when trying to run a rails app via a Dockerfile.
As suggested by user #PaulWilliams, I used apt to grab the missing package by adding these lines:
RUN apt-get update
RUN apt-get install nodejs -y
Notes
I didn't need to change/edit Gemfile or Gemfile.lock at all.
This solution didn't work for me when the lines were added early in the build process. It only worked when the lines were placed immediately before the line in the Dockerfile that was erroring.
If you happen to get the error on fly.io, here's some more information/documentation on the fix.
Lastly, I didn't have (nor need 'therubyracer') in my rails app, but was still getting the first part of the error message execJs: 'Could not find a JavaScript runtime'
Hope it helps someone.

Installing a forked github gem of Toto

Ok, this is probably simple, but I'm having a bit of a pain trying to get it to work.
So I was using the gem "Toto", which I installed using "sudo gem install toto", but I recently found a fork of the gem I would rather use here https://github.com/evaryont/toto.
I tried specifying the gem url with --source, but I guess github doesn't support gems anymore aside from "the list". I then tried downloading the forked source and running "rake build" and "rake install" which seemed to create a gem just fine, but when I plug it back into the same application which comes with the gem, it fails to load.
It dies like this.
computer:myblog User$ thin start -R config.ru
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- toto (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from config.ru:2
from /Library/Ruby/Gems/1.8/gems/rack-1.3.0/lib/rack/builder.rb:51:in `instance_eval'
from /Library/Ruby/Gems/1.8/gems/rack-1.3.0/lib/rack/builder.rb:51:in `initialize'
from config.ru:1:in `new'
from config.ru:1
Sample Toto Application
git clone git://github.com/cloudhead/dorothy.git myblog
I'm also a little discouraged about building the gem like this because I'm hosting on Heroku, and I would like to make sure that I can use this gem on there as well. I suppose I may have to unpack this gem and commit it to my source?
Update
I also tried using bundler with the following in my Gemfile, and I get the same error, would this mean its just an incompatibility in the sample code and the forked gem?
gem "toto", :git => "git://github.com/evaryont/toto.git"
Are you running in a context where the gem exists? Bundler handles :git-installed gems by cloning the source and storing it in a special directory for bundled gems. It's not actually installed to your system, and won't run unless bundler is running first.
Try this:
bundle exec thin start -R config.ru

How to get mongrel working with bundler?

Transitioning to bundler with an existing production setup. Naively with a gemfile and setup like:
gem "rails", "2.3.8"
gem "mongrel", git: "http://github.com/dynamix/mongrel.git"
bundle install --path /mnt/app/shared/bundle
Starting with
bundle exec mongrel_rails start --environment=production ...
results in
/mnt/app/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:166:in `require':
no such file to load -- /mnt/services/shared/bundle/ruby/1.9.1/gems/mongrel-1.2.0.beta.1/lib/mongrel/init.rb (MissingSourceFile)
What to do?
To answer my own, since I couldn't find a correct solution elsewhere on the web for this scenario:
The problem seems to be an interaction of bundler and mongrel's use of the gem_plugin. Yes, these may be on life support but unfortunately lots of people's production configs still depend on them.
Seems that with mongrel --pre installed from the git source, it's looking in bundle/ruby/1.9.1/gems/mongrel_ instead of bundle/ruby/1.9.1/bundler/gems/mongrel_ which is where bundler is stashing the gem cloned from git.
So the solution that worked for our config is to just symlink them:
ln -s /mnt/app/shared/bundle/ruby/1.9.1/bundle/gems/mongrel* \
/mnt/app/shared/bundle/ruby/1.9.1/gems/mongrel-1.2.0.beta.1
This is clearly something simple that bundler could do automatically. Full trace of the exception was:
/mnt/app/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:166:in `require':
no such file to load -- /mnt/app/shared/bundle/ruby/1.9.1/gems/mongrel-1.2.0.beta.1/lib/mongrel/init.rb (MissingSourceFile)
from /mnt/app/shared/bundle/ruby/1.9.1/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:166:in `require'
from /mnt/app/shared/bundle/ruby/1.9.1/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:134:in `block in load'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:241:in `each'
from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:241:in `each'
from /mnt/services/shared/bundle/ruby/1.9.1/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:112:in `load'
from /mnt/app/shared/bundle/ruby/1.9.1/bundler/gems/mongrel-f3e69eb8e6fb/lib/mongrel/configurator.rb:231:in `load_plugins'

Resources