git and dreamhost : refusing to update checked out branch: refs/heads/master

After dreamhost decided to move my account that hosted the git repository to a new server, first time I’ve tried to push some changes to the git repository I was faced with the followng error:

Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 699 bytes, done.
Total 7 (delta 6), reused 0 (delta 0)
error: refusing to update checked out branch: refs/heads/master
error: By default, updating the current branch in a non-bare repository
error: is denied, because it will make the index and work tree inconsistent
error: with what you pushed, and will require 'git reset --hard' to match
error: the work tree to HEAD.
error: You can set 'receive.denyCurrentBranch' configuration variable to
error: 'ignore' or 'warn' in the remote repository to allow pushing into
error: its current branch; however, this is not recommended unless you
error: arranged to update its work tree to match what you pushed in some
error: other way.
error: To squelch this message and still keep the default behaviour, set
error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://dh_user@dh_domain/home/repository_path/projects/project.git

After searching and finding out various solutions to solve the problem, none of which was specific to a server move, I’ve tried the following:

  • Followed the steps here to set up a new repository project_asm.git
  • went to local project changed the config file to add the new remote repository
  • issued git push new_remote master
  • make a code change and then git push

And everything should work as normal again.

Rails – Mysql::Error: Got error 28 from storage engine

Trying to access your rails application in your development pc, you get the error:

Mysql::Error: Got error 28 from storage engine

in your console.

It turns out that this specific error is a MySQL error, indicating that you have run out of space in the partition that the MySQL server stores its files (/var/lib/mysql).
Looking at the folder there, you can see a very large file called ibdata1.
This file holds all the information about your InnoDB tables and transactions in your MySQL. According to other posts after a Google search, it seems that this file cannot be reduced in size either by removing/truncating your tables or deleting databases that you don’t need. There are quite a few solutions out there if you really need to keep a backup of your databases, but if you only using your database for development and you DON’T NEED (!!) your data or tables, you can move this big ibdata1 to another partition for backup and restart your mysql, that will create a new file.

Testing Active_Mailer with GMail in development

You want to test your email configuration and be able to send emails in your development environment, using a GMail account in a Rails application using 2.3.2.

Start your console in your development environment:


Add the following replacing your GMail details:

ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => "",
:port => 587,
:domain => "your_gmail_domain",
:authentication => :plain,
:user_name => "your_gmail_user_name",
:password => "your_gmail_password"}

Add a simple email class:

class MyMailer < ActionMailer::Base def test_email @recipients = "" @from = "" @subject = "test from dev console" @body = "this is the body" end end

and to finally test the email:


if it doesn't return with an error but with something like:

TMail::Mail port=#TMail::StringPort:id=0x..fdab4cee0 bodyport=#TMail::StringPort:id=0x..fdab4a9ec

then it should be working so add the configuration to your environments/development.rb

config.action_mailer.smtp_settings { ... }

Deploying a Rails project in a server that hosts the git repository

You want to deploy your project in a server (dreamhost), that also hosts your git repository. When you try to do that by only setting the set_repository, you get errors like ‘permission denied, please try again’, even though if you try to checkout the git repository on your server works.

Set your :repository as a file in your host as in:
set :repository, "file:///home/username/git_on_server/projects/repo_name.git"

Then also set up your local_repository, as in:
set :local_repository, "user_name@server_domain_name:/home/username/git_on_server/projects/repo_name.git"

Rails Passenger Staging environment problem in Dreamhost

You want to deploy your rails application using Passenger in Dreamhost, but on a staging environment. It doesn’t work just changing your Capistrano recipe or your environment files, as the default environment for passenger is ‘production’.

Looking at the Passenger documentation here, there are four different ways of achieving that by changing the RailsEnv option. If you don’t want to change the Apache configuration files, and as long as the option AllowOverride is on (which should be on Dreamhost), then you would need to create an .htaccess file in your application’s public folder with the following:

RailsEnv staging