rake errors while loading some kind of mutex - ruby-on-rails

I just installed facebook connect for my site, but without having edited something on the files that cast the error I get this:
rake aborted!
uninitialized constant ActiveSupport::Dependencies::Mutex
/var/www/###/Rakefile:10:in `require'
(See full trace by running task with --trace)
In line 10 of my Rakefile you find:
require 'tasks/rails'
I haven't edited 'tasks/rails'... what is this Mutex and why does it now cast this error?

the error is probably thrown because some code that is in the module ActiveSupport::Dependencies wants to use the Mutex class, but the class for some reason can not be autoloaded.
Sometimes the problem lies not in the code, but in the environment - like conflicting gems, i guess the issue is that your freshly installed facebook connect messes up some parts in your system
It can help to look at the rake some:task --trace output, to determine which file causes the problem - maybe look for calls to facebook connect library, and then try to play with that file - comment out lines that might be causing your problem, to determine what has to be done.
To help you further one would need the stack trace, the list of your gems and their version used in the project and maybe steps what have you done while installing the facebook connect

If you can't upgrade from rails 2.3.4, require 'thread' in Rakefile, before boot.rb is initialized.
You may also need to require it in config/environment.rb, and script/server.
Looks like this:
require 'thread'
require File.join(File.dirname(__FILE__), 'boot')

You have Rails 3.0.5 installed, but are trying to use 2.3.4. While, if you have 2.3.4 installed additionally, they shouldn't conflict to much, I'd recommend you take a look at using RVM for development to create isolated development environments (called gemsets).
Further, you're using Rails 2.3.4, which is incompatible with Rubygems 1.6. I highly recommend you upgrade rails to the latest 2.3 version (currently 2.3.11), as it includes numerous bug and security fixes, as well as compatibility with the latest Rubygems. Alternatively you can downgrade Rubygems to 1.3.7, but I'd advise upgrading Rails instead as it's a better long-term solution and includes numerous critical security fixes.

Related

Cannot running 'rake db:migrate' on a cloned github repo

Since I am new to rails and have learned the very basics from books I now figured that I can learn quite a bit more from reading other peoples code and trying to make sense of it so I have signed up at github and set up everything there. Now I read that one good open source project to learn from is radiant so I went to https://github.com/radiant/radiant and cloned it to a local directory. THen I proceeded as follows:
cd radiant
bundle install, which went fine
rake db:migrate, which first returned:
rake aborted! You have already activated rake 0.9.2, but your Gemfile requires rake 0.8.7. Using bundle exec may sol
So I typed in bundle exec rake db:migrate and recieved the following:
NOTE: Gem.source_index is deprecated, use specification. It will be removed on or after 2011-11-01. Gem.source_index called from c:/Ruby192/lib/ruby/gems/1.9.1/gems/rails-2.3.14/lib/rails/gem_dependency Rake aborted! No such file to load -- radius
So here I am wondering how to fix this problem? I also noticed that a Gemfile and a Gemfile.lock already existed in the radiant folder when it was cloned, which perhaps could be part of the problem?
Also I wonder if it is crutial that I run the same version of rails as the project is written in?
Now it should be said that I currently have rails 3.0.5 installed and run on windows
I hope someone can help me here, it has been quite frustrating since I have not been able to run any cloned github repos (radiant here just being one example).
You should edit your Gemfile and make it require newer rake.
Also you can run rake db:migrate --trace to get additional error information.
The deprecation warning is still just a warning, and it shouldn't be causing you any issues. The part of that error that is relevant is the No such file to load -- radius. You probably need to follow the instructions for installing Radiant, which include running a gem install radiant before dropping this project code somewhere.
Bundler manages installing and using the gems in your Gemfile, and if a Gemfile.lock is present it'll use those exact versions. This means you can't run Radiant with Rails 3.0.5 since the Gemfile specifies 2.3.14. Bundler will install Rails 2.3.14 and its dependencies automatically, though, so you don't need to worry about it.
By the way, this project looks like it has been very mismanaged. It's not common for a Rails project/gem to force you to actually clone it to use it. If you want to check out a Rails 3 project to learn from, I have a slim Rails 3 app that was intended to be an API up publicly on Github with some really clean code: http://github.com/coreyward/instavibe

Undefined Method Error when creating delayed_job workers with script/delay_job

Having a bit of a problem running multiple workers.
When creating workers with rake jobs:work jobs run without and problem, even when invoking it multiple times, but when creating workers with ruby script/delayed_job -n 5 start all jobs fail with undefined method on Syck::DomainType.
I've searched quite a bit, but can't seem to find the solution for this. I am running DelayedJob on the Mongoid backend. Gem versions:
rake 0.9.2
rails 3.0.6
delayedjob 2.1.4
delayedjob_mongoid 1.0.2
Has anyone experienced a similar error/have a solution? Or short of that some information on why/how workers are being created differently depending on which way they are invoked?
I had the exact same problem. I could reproduce it by loading the job in the console and trying to unserialize it:
$ rails console production
> j = Delayed::Job.last
> YAML.load(j.handler)
On my production environment, I got a Syck::DomainType object whereas in development it just unserialized my object (the data stored in db is the same in both case).
Long story short, I realized that I had ruby 1.9.1 instead of 1.9.2 on my server. Switching to an rvm managed environment with ruby-1.9.2p290 solved the problem for me.
Perhaps ruby script/delayed_job -n 5 start all doesn't invoke Bundler.setup and that's why it's different from other ways of launching workers? (Just a guess)
You may be able to fix the Syck::DomainType error by putting this at the top of config/application.rb
require 'yaml'
YAML::ENGINE.yamler = 'syck'
# [...]
require File.expand_path('../boot', __FILE__)
Thanks to this answer: rails error, couldn't parse YAML
It looks like the problem was derived from bundler >= 1.0.10 loading up psych and overwriting some of sycks functionality if libyaml is present. I was able to remove the libyaml install from my system, something that I know won't be possible for everyone. Tough to track down, hopefully this post will help someone else
Run it with:
bundle exec ./script/delayed_job -n 5 start

How to solve "uninitialized constant Dependencies" error in rake?

I am trying to build Noosfero (http://noosfero.org/), a project done in Ruby, but I am pretty new in Ruby and Linux (my current environment).
I am following the instructions in their tutorial (http://gitorious.org/noosfero/noosfero/blobs/master/INSTALL and http://gitorious.org/noosfero/noosfero/blobs/master/HACKING).
I was supposed to run an apt-get install with many packages, everything worked except for libgettext-ruby-data, to which I get a message that "E: Package libgettext-ruby-data has no installation candidate".
I then download the source and try to run "rake db:schema:load", which I get the following error:
"rake aborted!
uninitialized constant Dependencies
/home/user/noosfero/Rakefile:10"
My rake file is the following:
require(File.join(File.dirname(FILE), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails' #this is the line that the dependency can't be found
I searched around and found this question here: Uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) , but changing the config files didn't help and I could wasn't able to downgrade my RubyGems because I do not know how to do that (gem -update returns a message that I have to do that using apt-get, but I can't find out in which package the gem program is).
The first time I run Rake, I get a message saying:
"I: Installing Debian-installed Rails from /usr/share/rails into vendor/rails.
I: Please note that the recommended Rails version is 2.1.0, and that other versions might not work"
But I don't know how to downgrade my Rails version.
I've got many paths to follow, so I've got many questions, I hope you can help me:
1- Does anyone knows how to fix it directly?
2- How can I downgrade Gems?
3- How can I downgrade Rails?
4- Where can I download gems and how can I install it? (The documentation provides a link, but this link is VERY strange: http://www.yotabanana.com/hiki/ruby-gettext.html?ruby-gettext ).
Any help is very appreciated.
Thanks,
Oscar
Edit: can this error be a problem in the project I downloaded and not in my environment? After some research I am starting to think it is, can it be?
It would help if you share your rake version, by the way.
In the meantime, take a look at this:
https://github.com/jimweirich/rake/issues/33
(Only valid for rake 0.9.0, though).
This was a version conflict I had with the project I was trying to build, not it is solved :)
First of all, I'm a Noosfero developer and I need to admit that the process of preparing the environment to run Noosfero right now is pretty nasty (unless you only want to run it in the production mode since we've got a debian package). But this problem is close to an end since we're a building a vagrant box (for more info see http://vagrantup.com/) to noosfero. Things are going to be much better. But regardless all this nastiness and not having the box yet, Noosfero was supposed to run if you followed all the steps in the INSTALL instructions. Let me try to help you.
Are you using Rails 2.1.0? The best way to do so is to uninstall rails from your system (if you installed through apt-get) and install through rubygems:
gem install rails -v=2.1.0
To avoid problems ensure that there isn't any other version of rails installed through rubygems (gem list).
If you still having problems to run the schema load, run it with --trace and post it here.
If you have other problems you can try contacting us through noosfero-dev#listas.softwarelivre.org or the irc #noosfero at FreeNode.

MissingSourceFile when I run "cucumber features"

I had cucumber 0.6.1 working quite fine... but I ran the gem update cucumber command, and things went smoothly. Then when I decided to run the cucumber features command, I received this error:
Using the default profile...
no such file to load -- cucumber/webrat/element_locator (MissingSourceFile)
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inpolyglot_original_require'
So I tried a few things... I did a gem update on webrat, that didn't work. I removed all previous versions of cucumber by doing gem uninstall cucumber then selecting past versions. Same with webrat. No luck. What am I doing wrong?
Have you tried to regenerate cucumber files with script/generate cucumber --webrat? Maybe it solves it. Just take care not to overwrite features/support/paths.rb.
I resolved this issue. There was an old version of the 'freelancing-god-thinking-sphinx' gem on the server i was deploying to. Removing this gem enabled everything to work properly.
I had a similar issue using Bundler where my Gemfile had >= 0.4.3 version of cucumber, so it would always look to install newer versions of cucumber when updating/installing the bundler gems. Cucumber's env file (/features/support/env), however, referenced files that were not part of the future releases. In particular, '/cucumber/rails/world'. Therefore, I got the same MissingSourceFile error you are getting.
I think either want to roll back your version of cucumber, or update your cucumber env file so it's compatible with your version of cucumber.
For me, I commented out the following line in my env.rb file
# require 'cucumber/webrat/element_locator'
# Deprecated in favor of #tableish - remove this line if you don't
# use #element_at or #table_at
As you can see by the comment following it, it has been depreciated anyway.

De-capistrano a rails app?

I've inherited a rails site that I need to deploy (quickly!) to our webhost, which is a standard *nix shared server that uses FastCGI for rails apps. I've worked with rails sites on multiple occasions in the past but wouldn't consider myself an expert by any stretch.
This particular app was developed using capistrano, with which I've got no experience, and everything I've read leads me to believe that to deploy the app "properly" would require my setting up an external svn account, among other things, which aren't feasible given our time frame and hosting situation.
My question is: what is the best way to quickly get this application up and running without using capistrano? I received, along with the site files, a .sql dump that I've already imported, and I've configured config/database.yml to reflect the correct production db settings. Right now, running ruby script/console production yields the following error message:
/home/user1/ruby/gems/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:443:in `load_missing_constant':NameError: uninitialized constant ApplicationController
Thanks for your consideration!
As the others already stated, you are probably using the incorrect version.
Rails switched from app_controller to application_controller (or something like that) in version 2.1 or 2.2.
There is a rake task that you should be able to run in that case:
rake rails:update:application_controller
It might help you.
As for the capistrano. In your deploy.rb you can add the parameter :deploy_via :
set :deploy_via, :copy
set :scm, :none
And it should use the copy you are having in your working directory to deploy with (no need for subversion or any other version control)
Copy usually fetches the code from a repository locally and then uploads it to the server, but also setting the :scm to none it should ignore that and just (hopefully) use your working copy instead.
All capistrano requires is a deploy.rb and a Capfile, this is not what is causing your error. From the looks of it it seems that the problem is that you're using a gem rails version which is incompatible with your app, do you know which version it was developed with? If so you should try vendoring your rails directory to the right version.
For deployment, if you're using FastCGI you can just upload the files to the host and set the appropriate permissions and you should be good to go. Going forward you might want to look at upgrading to a newer version of rails, using capistrano and changing your environment to use apache passenger.
I hope this helps.
The problem you're running into appears to be a mismatch of your installed version and the version that the app is expecting. Look in config/environment.rb, Toward the top you'll see something that looks like:
RAILS_GEM_VERSION = '2.3.4'
You need to make sure that the version of rails installed on your machine matches whatever version is declared in that file. You can do that by running:
sudo gem install -v=X.X.X rails
where X.X.X matches what was in your environment.rb.
Jonnii is suggesting you "freeze" your rails by including all the rails code into your project directly, (which can be done by running rake rails:freeze:gems AFTER you have followed the above steps and gotten the correct gems installed in the first place.) Once you've frozen rails, then you no longer need to have the rails gems installed on your webserver machine.
Good luck!

Resources