Today I got to the office, and the first thing that popped into my eyes when I opened Twitterrific was this:
Rick Olson announcing that Warehouse is now open-source. Damn, it HAS to be Christmas! I have always loved the products that Active Reload builds, mostly because they follow the “do more with less” and “keep it simple stupid” principles, but also because their web-applications look awesome, thanks to Justin Palmer, the self-taught and self-proclaimed Design Ninja (I’ll have to agree with him on this one).
I have always wanted to give Warehouse a spin on my projects (professional and personal), but never got around to buy it because I was afraid it could be of no use for me (you guys have to find a way to distribute trials or something). Now that it’s open-source, I am going to try and provide a guide on how to install it.
Step 1. Requirements
Since I don’t have a spare computer lying around, I’m going to create a virtual machine to accomplish the task. I’ll try to build a dedicated SVN server, using Ubuntu Server (you can use anything else that’s Debian based) so all the dependencies will be installed using apt-get
Please take note that this is not a solution to be used in a production environment. It is most suited for “evaluation” purposes.
As for what virtualization software is concerned, there are several options:
- Windows:
- VirtualBox (free, as in beer or open-source)
- VMWare Server (free, as in beer)
- VMWare Workstation (commercial, starts at $189.00)
- Microsoft Virtual PC (free, as in beer, has a few quirks with Linux as guest)
- Linux:
- VirtualBox (free, as in beer or open-source)
- VMWare Server (free, as in beer)
- Mac OS X:
- VirtualBox (free, as in beer or open-source)
- VMWare Fusion (commercial, starts at $79.99, well worth the money, ahem…)
- Parallels Desktop (commercial, starts at $79.99)
So, go ahead and pick one, create a new virtual machine and install Ubuntu Server on that (any of these virtualization solutions can mount an ISO image, which you will have to download from Ubuntu’s website). I chose svnserver for the server hostname, and developer for the default username.
Step 2. Creating the user
Next we need to create a user for our Warehouse installation. The following commands create the warehouse user and add it to the www-data group (the same group Apache runs with by default).
-
sudo adduser warehouse
-
sudo adduser warehouse www-data
Step 3. Getting all the dependencies in place
After creating the user, you’ll have to add a repository so that you can apt-get the Phusion Passenger Apache module. Edit /etc/apt/sources.list and add the following lines in the end:
-
# Phusion Passenger for Apache
-
deb http://apt.brightbox.net hardy main
Afterwards, run the following command in order to update your apt repositories and install all the requirements to run Warehouse:
-
sudo apt-get update
-
sudo apt-get install git-core subversion subversion-tools ruby libsvn-ruby libmysql-ruby libopenssl-ruby ruby1.8-dev rdoc ri mysql-server mysql-client apache2 libapache2-mod-passenger
NB: The Passenger module package might have a bug where the mod_passenger.so is extracted to the root. If that happens, issue the following command:
-
sudo mv /mod_passenger.so /usr/lib/apache2/modules/
Install Rails 2.0.2, Rake and Erubis
-
sudo gem install rails -v=2.0.2
-
sudo gem install rake
-
sudo gem install erubis
Create a mysql user and databases for Warehouse:
-
mysqladmin create warehouse -h localhost -u root -p
-
mysqladmin create warehouse_development -h localhost -u root -p
-
mysqladmin create warehouse_test -h localhost -u root -p
To add a new user and give it permission to those databases, run these commands inside a mysql shell:
-
GRANT ALL PRIVILEGES ON warehouse.* TO 'warehouse'@'localhost' IDENTIFIED BY 'warehouse_user_password' WITH GRANT OPTION;
-
GRANT ALL PRIVILEGES ON warehouse_development.* TO 'warehouse'@'localhost' IDENTIFIED BY 'warehouse_user_password' WITH GRANT OPTION;
-
GRANT ALL PRIVILEGES ON warehouse_test.* TO 'warehouse'@'localhost' IDENTIFIED BY 'warehouse_user_password' WITH GRANT OPTION;
Step 4. Creating first SVN repository and gitting Warehouse
Login as warehouse. First off, we’ll create our first repository that will hold your project. Here’s how to do it:
-
mkdir svn
-
svnadmin create svn/topsecretproject
-
chown -R :www-data svn
We’ll assume topsecretproject is your project name. Next, inside your home directory, issue the following commands:
-
git clone git://github.com/entp/warehouse.git www
-
chown -R :www-data www
-
chmod -R 775 www
This will checkout the Warehouse code into /home/warehouse/www/. You can also get a tarball, but using this method is easier if you want to stay on the edge (I hear Rick is adding git support into Warehouse). It will also make the directory readable by the www-data group.
Next, we need to configure the database and run the first migration:
-
cd www
-
cp config/database.sample.yml config/database.yml
Edit database.yml and put in the correct values. After that, head back to /home/warehouse/www/ and run:
-
mkdir log
-
rake tmp:create
-
RAILS_ENV=production rake db:schema:load
Step 5. Creating the Apache virtualhost
Log in again as the developer user, and cd to /etc/apache2/sites-available/. In that directory, create a file named warehouse-site with the following content:
-
<VirtualHost *:80>
-
DocumentRoot /home/warehouse/www/public
-
ErrorLog /var/log/apache2/warehouse_error.log
-
LogLevel warn
-
CustomLog /var/log/apache2/warehouse_access.log combined
-
RailsEnv production
-
</VirtualHost>
Finally, issue the following commands to enable the site you just configured, remove the default one, activate the rewrite module and restart apache:
-
sudo ln -s /etc/apache2/sites-available/warehouse-site /etc/apache2/sites-enabled/warehouse-site
-
sudo rm /etc/apache2/sites-enabled/000-default
-
sudo a2enmod rewrite
-
sudo apache2ctl restart
Now all you have to do is to open a browser window and type http://<your_virtual_machine_ip>/install in the URL and you’ll be up and running. I recommend, however, that you define the site with a ServerName, so that the sub-domains work properly.
Step 6. Giving your svn server a domain name and accessing it
Edit /etc/apache2/sites-available/warehouse-site and, right after the <VirtualHost> tag, add the following line:
-
ServerName svnserver.dev
You can change svnserver.dev to whatever you like. Afterwards, add that host to your hosts file. Here’s how to do it in Windows, Linux or Mac OS X. If all goes well, enter the new URL (including /install in the end) in your browser, and you should be seeing something like this:
In doubt, fill the “Absolute path to repository” with the following value:
/home/warehouse/svn/topsecretproject/, where topsecretproject is the repository name you’ve created in step 4. Also, after completing the installation, you might get an URL like http://topsecretproject.svnserver.dev/. In that case, you’ll have to go back to your hosts file and add another entry with that hostname.
Wrapping up

There you have it. Warehouse up and running syncing your first (and empty) repository. To serve it through apache (ie. enable you to make commits outside of the virtual machine), check this tutorial out. I hope this helps you in any way. I would appreciate some feedback, so don’t hesitate to fill that little form bellow.
Thanks and see you next time.
Tags: active reload, git, justin palmer, open-source, rails, rick olson, server, svn, tutorial, ubuntu, warehouse


When I execute: RAILS_ENV=production rake db:schema:load I get this:
(in /var/www/svn)
rake aborted!
no such file to load — rubygems
Any idea?
I might have forgotten to indicate to install rubygems on the article. Did you do that?
Hey, thanks for the tutorial. Using Mongrel everything seems fine, I get the installer screen. But when I’m trying to use Apache, I get the following error message:
We’re sorry, but something went wrong.
We’ve been notified about this issue and we’ll take a look at it shortly.
Unfortunately I can’t find anything in the logs. The error log is empty, the access log looks fine.
Any suggestions?
OS: Ubuntu 9.04 Server
Meanwhile I found the reason: only the development database has contents, the production DB is completely empty. How comes? I did a
rake db:migrate
and a
rake db:schema:load
Thanks in advance
I seem to be blind
The only thing I forgot was to add
RAILS_ENV=production
to my rake commands. Now everything’s fine. Thanks again.
I am stuck at:
There appears to be a database problem.
*
Your config/database.yml may not be written correctly. Please check it and fix any errors.
*
Your database schema may be out of date or nonexistant. Please run rake db:migrate to ensure that the database schema is up-to-date.
*
The database server may not be running. Please check whether it’s running, and start it if it isn’t.
Error message:
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysld.sock’ (2) (Mysql::Error)
Exception class:
Mysql::Error
Application root:
/home/warehouse/www
and my datbaase.yml is set to the correct directory based on mysql status command.
I have a problem with my virtual host file:
sudo apache2ctl restart
Syntax error on line 7 of /etc/apache2/sites-enabled/warehouse-site:
Invalid command ‘RailsEnv’, perhaps mis-spelled or defined by a module not included in the server configuration
what is wrong? i hope you can help me…
Do you have the passenger apache module enabled?
If so, try removing the offending line and setting the environment in the environment.rb file on the application’s config directory. That should get you running.
Can’t browse the repository.
Everytime I wan’t to browse I get an Error 500.
The log tells me the following error message:
ActionView::TemplateError (undefined method `length’ for #) on line #88 of browser/dir.html.erb
Any ideas?
Maybe there’s something wrong with the repository. Can you check-in / check-out from it? Do you have all the libraries in place? That line is where warehouse traverses through the changesets, so the problem could be lying on the SVN repo.
The repository browser works fine before I start indexing the changes. After indexing the changes I’ll get the error, I tested with my own repo and with brand new repo I’ve created.
I was having the same issue with the browser, and it is apparently due to an issue with the rails truncate helper. If you’re using Ruby 1.8.7 and Rails 2.0.2, try the solution in the following post:
http://blog.sviluppoweb.eu/2008/11/26/undefined-method-length-for-enumerableenumerator-on-text_helperrb50in-truncate/
Great tutorial… I was able to get the install page to display but its not serving any of the pictures and none of the links work. I’m guessing this is an apache configuration problem but have no idea where to look first. Any help is appreciated.
OK… So I just forgot to enable the rewrite module… thanks again though…
What do your rails logs say? What about your apache logs? Or does it not find the hostname?
Forgot to enable the rewrite module… solved everything. Thanks again for the tutorial.
I’m not sure what was going on, but I seem to have fixed that. But now when I run:
RAILS_ENV=production rake db:schema:load
I get:
Access denied for user ‘warehouse’@'localhost’ (using password: NO)
why would it not be using the password? I reset the password in mysql to make sure it was set correctly.
Check your database.yml file. Make sure the password is specified for the production environment. My guess is that it isn’t.
Why does installing Phusion Passenger require removing a lot of the php5 modules, such as phpmyadmin?
@James It does? I had no idea. What errors do you get when installing / activating it?
Thanks again, i suppose thats the case also for svn users, i mean, i have to create them manually also? I though that by creating them on the Warehouse panel the system would take care of creating those users in the config files for each repository.
Go to Warehouse’s FAQ to see the list of commands available. They have several commands to import users into warehouse and get them into the SVN daemon.
Join to Warehouse…
Does this seems to be a bug? Trying to import the users from apache htpasswd file I’m getting from “warehouse:import_users” rake the error: “uninitialized constant Warehouse::Command::User”
Command line used: “rake warehouse:import_users CONFIG=config/htpasswd.conf”
Maybe someone else tried it?
Cheers!
Fixed. I had more non-alphanumeric character in my password that made Sequel to crash.
Hi, back on this. I configured apache and it’s running on production. But I can’t use any command line available with warehouse cause I’m getting this annoying error.
”
rake aborted!
bad URI(is not URI?): mysql://root:password@localhost/xorn_production
”
Seems to be a problem with mysql server?! All tables are fine in “xorn_production” database besides “changesets” table with empty records in.
Thanks !
Silly me! I have started the server and now I’m running Warehouse installation on my http://localhost:3000. Thanks a lot guys!
@Adriana: Although that’s not the “production” server (it’s only to check if everything is OK), it should work fine. You should still check if apache is running and if the settings are OK. Let me know.
Hi, for me it’s weird, I took Warehouse tar.gz archive from http://github.com/entp/warehouse/tree/master. All packages installation steps went fine but I didn’t finished the warehouse configuration because I don’t have /install directory. I don’t have any other config errors. I’m running it on debian and ubuntu OS.
Thanks.
@Luis: You have to create them yourself, then add them to Warehouse.
@Adriana: Did you start the server? You could try starting it with script/server, mongrel or the like. Besides, there is no install directory, only a controller. E-mail me at < me AT andremedeiros DOT info > if you need further help.
Hi, newbie here. I’ve managed to install Warehouse, after configuring Subversion. Im not sure if everything went ok because after working for a while, i now cannot connect to the repositories with versionsapp. The system always returns an error related to not being able to find any repository.
Anyone had this kind of issues?
When adding a new repository to Warehouse, is it supposed to be created in the file system automatically or do i have to create by hand?
Thanks.
Thanks! That did the trick. Much appreciated.
Glad it worked out for you.
@Trey What OS are you deploying Warehouse on? I’ve had cases where, in linux, it would assume /tmp/mysql.sock when it’s really lying on /var/run/mysqld/mysqld.sock. So, here are a couple of things you need to make sure of: 1) Have the mysql gem installed (native one, not the ruby based one). 2) If that doesn’t solve it, try adding this line to your database.yml configurations:
socket: /var/run/mysqld/mysqld.sock
Good luck.
Thanks for the guide! I’m a complete n00b and am trying to get warehouse going for a small group of developers. I keep running into an error following this: RAILS_ENV=production rake db:schema:load. The process stops and I get “Can’t connect to mysql server through socket /tmp/mysql.sock (2)” I’m a little lost but am guessing it’s some sort of permissions problem with mysql and the install. Any help would be greatly appreciated. Again, thanks a ton for writing this guide!
@Devan I’m not sure, although I doubt it. I recommend you to join #activereload on irc.freenode.net and ask technoweenie about that issue. Sounds like a great improvement.
This is an excellent, well written and thorough tutorial on installing warehouse – it is much appreciated. Wish I had found it hours and hours ago – would have saved me a whole day!
I am wondering if you know whether Warehouse can access a repo on another svn server at another location, e.g. svn://overthere.com/thatrepo instead of having the repositories on the local machine? I have tried, and get errors when trying to browse the repo.
Thanks again,
Devan
@tav Thanks for the feedback. Well, 755 would depend on how you’d setup the users and all. I chose an approach where the “warehouse” user would run under the same group as apache, but not as the user per-se, so I’m not sure 755 would be enough. Anyway, I’ll give it a try and let you know.
Thanks!!
Near perfect installation guide! Just needs some modifications with regards the permissions. I think chmod -R 755 is what’s needed?
Thanks again, tav
@Kevin Did you catch the file and line that caused the error?
Thanks for the quick reply!
You were right – I chmodded the directory again and it worked.
I got to the next screen but when I click sync it says: “A 500 error occurred, please check your logs” and in the log it says “FloatDomainError (NaN)…”
Know what would have caused this?
Thanks,
Kevin
@Kevin Thanks! I’d suspect that it’s trying to write the config file and not being able to. Try chmodding the directory again, and let me know how it goes. Good luck.
Cool tutorial!
I get to the point where I bring up the install page but when I enter all the info and click install it says: Permission denied – /home/warehouse/www/config/initializers/warehouse.rb
any clue as to what the issue is?
Thanks,
Kevin
pew.
In that case, I’d take that to the Warehouse community forum. You might find a solution there. Good luck and I’m sorry I couldn’t be of any more help.
Where can I find the community forum? I only found a forum about lighthouse but not about warehouse.
You can find it at http://help.warehouseapp.com/
Thanks for your reply.
i can’t install it cause ibapr1 is not available:
root@www:~# sudo apt-get install libapache2-mod-passenger
Reading package lists… Done
Building dependency tree… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
Since you only requested a single operation it is extremely likely that
the package is simply not installable and a bug report against
that package should be filed.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libapache2-mod-passenger: Depends: libapr1 but it is not installable
Depends: libaprutil1 but it is not installable
Depends: libc6 (>= 2.4) but 2.3.6-0ubuntu20.5 is to be installed
Depends: libgcc1 (>= 1:4.1.1-21) but 1:4.0.3-1ubuntu5 is to be installed
Depends: libruby1.8 (>= 1.8.6.111) but 1.8.4-1ubuntu1.6 is to be installed
Depends: libstdc++6 (>= 4.1.1-21) but 4.0.3-1ubuntu5 is to be installed
E: Broken packages
root@www:~# sudo apt-get install libapr1
Reading package lists… Done
Building dependency tree… Done
Package libapr1 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package libapr1 has no installation candidate
can you tell me, were i get it from?
thanks
What distribution and version of Linux are you using? You could try building passenger from source like so:
sudo gem install passenger
Install the development tools (ruby-dev, build-essentials, etc) first.
I got it! thanks!
That’s awesome!