Topic: can't run musicbrainz server-- carton install --deployment failed

When I run the command:'carton install --deployment', the output have some type error text,as follows:
I use Ubuntu 12.04 wubi. The former is all right.
---------------------------------------
.......
! Couldn't find module or a distribution Carp (1.22)
! Bailing out the installation for Test-Warn-0.24. Retry with --prompt or --force.
Found conflicting versions for package 'inc::Module::Install'
  inc/Module/Install.pm (1.06)
  Module/Install.pm (0)
Found conflicting versions for package 'inc::Module::Install::DSL'
  inc/Module/Install/DSL.pm (1.06)
  Module/Install/DSL.pm (0)
.......
Successfully installed HTML-Selector-XPath-0.14
341 distributions installed
Installing modules failed
------------------------------------------
Would you help me? Something wrong?

Re: can't run musicbrainz server-- carton install --deployment failed

Hi zaiai2003,

I could be wrong here as virtual machines, no GUI, compiling source code and using postgresql are all new for me but a bit of googling goes a loong way.  For starters see this thread and post #4 by ianmcorvidae:

http://forums.musicbrainz.org/viewtopic.php?id=3774

Here's what I've found:
Given a fresh Ubuntu server 12.04.1 LTS install, and following the instructions in the install.md file (https://github.com/metabrainz/musicbrai … INSTALL.md) with rembo10's extra notess (https://github.com/rembo10/headphones/w … inz-Mirror), when it comes to run carton install --deployment it will fail due to missing perl dependencies.

The steps which follow assume you've already followed the install.md instructions and reached the carton install --deployment step which has then returned an error like ! Couldn't find module or a distribution xxxxxx.

#STEP 1 To save some time trawling through the musicbrainz/.cpanm/build.log for missing dependencies, run the following from the musicbrainz-server directory to install (hopefully) all the additional perl dependencies:
NB - you may not need to use sudo - I might have messed up somewhere as the installer wouldn't work without it.

sudo cpanm Cache::Cache         
sudo cpanm Cache::Memcached                      
sudo cpanm Cache::Memcached::Fast                
sudo cpanm Cache::Memory                         
sudo cpanm Captcha::reCAPTCHA                    
sudo cpanm Catalyst
sudo cpanm Catalyst::Action::RenderView
sudo cpanm Catalyst::Authentication::Credential::HTTP
sudo cpanm Catalyst::Devel
sudo cpanm Catalyst::Plugin::Authentication
sudo cpanm Catalyst::Plugin::AutoRestart
sudo cpanm Catalyst::Plugin::Cache
sudo cpanm Catalyst::Plugin::Cache::HTTP
sudo cpanm Catalyst::Plugin::ConfigLoader
sudo cpanm Catalyst::Plugin::ErrorCatcher
sudo cpanm Catalyst::Plugin::I18N
sudo cpanm Catalyst::Plugin::Session
sudo cpanm Catalyst::Plugin::Session::State::Cookie
sudo cpanm Catalyst::Plugin::Session::Store::FastMmap
sudo cpanm Catalyst::Plugin::StackTrace
sudo cpanm Catalyst::Plugin::Static::Simple
sudo cpanm Catalyst::Plugin::Unicode::Encoding
sudo cpanm Catalyst::Runtime
sudo cpanm Catalyst::View::TT
sudo cpanm CGI::Expand
sudo cpanm CGI::Simple::Cookie
sudo cpanm Class::C3::Adopt::NEXT
sudo cpanm Class::Inspector
sudo cpanm Class::Load
sudo cpanm Class::Method::Modifiers
sudo cpanm Class::MOP
sudo cpanm Clone
sudo cpanm Config::General
sudo cpanm CSS::Minifier
sudo cpanm Data::Compare
sudo cpanm Data::Dump
sudo cpanm Data::Dumper::Concise
sudo cpanm Data::OptList
sudo cpanm Data::Page
sudo cpanm Data::UUID
sudo cpanm Data::UUID::MT
sudo cpanm Date::Calc
sudo cpanm DateTime::Format::Duration
sudo cpanm DateTime::Format::Natural
sudo cpanm DateTime::Format::Pg
sudo cpanm DateTime::TimeZone
sudo cpanm DBD::Pg
sudo cpanm DBI
sudo cpanm DBIx::Connector
sudo cpanm Digest::MD5::File
sudo cpanm Digest::SHA1
sudo cpanm Email::Address
sudo cpanm Email::MIME
sudo cpanm Email::MIME::Creator
sudo cpanm Email::Sender
sudo cpanm Email::Valid
sudo cpanm Encode::Detect
sudo cpanm Env::Path
sudo cpanm FCGI
sudo cpanm FCGI::ProcManager
sudo cpanm File::ChangeNotify
sudo cpanm File::ShareDir
sudo cpanm Function::Parameters
sudo cpanm HTML::Entities
sudo cpanm HTML::FormHandler
sudo cpanm HTML::HeadParser
sudo cpanm HTML::HTML5::Entities
sudo cpanm HTML::HTML5::Parser
sudo cpanm HTML::HTML5::Sanity
sudo cpanm HTML::Selector::XPath
sudo cpanm HTML::Tiny
sudo cpanm HTML::TreeBuilder::XPath
sudo cpanm HTTP::Body
sudo cpanm HTTP::Headers
sudo cpanm HTTP::Request
sudo cpanm HTTP::Request::AsCGI
sudo cpanm HTTP::Request::Common
sudo cpanm HTTP::Response
sudo cpanm IO::All
sudo cpanm IO::HTML
sudo cpanm Javascript::Closure
sudo cpanm JSON::DWIW
sudo cpanm JSON::Syck
sudo cpanm List::MoreUtils
sudo cpanm List::UtilsBy
sudo cpanm Locale::Maketext::Lexicon
sudo cpanm Locale::Messages
sudo cpanm Locale::PO
sudo cpanm Log::Dispatch
sudo cpanm LWP::UserAgent
sudo cpanm LWP::UserAgent::Mockable
sudo cpanm Method::Signatures::Simple
sudo cpanm MIME::Types
sudo cpanm Module::Versions
sudo cpanm Moose
sudo cpanm MooseX::ABC
sudo cpanm MooseX::Clone
sudo cpanm MooseX::Daemonize
sudo cpanm MooseX::Emulate::Class::Accessor::Fast
sudo cpanm MooseX::Getopt
sudo cpanm MooseX::MethodAttributes
sudo cpanm MooseX::MethodAttributes::Inheritable
sudo cpanm MooseX::Role::Parameterized
sudo cpanm MooseX::Role::WithOverloading
sudo cpanm MooseX::Runnable
sudo cpanm MooseX::Singleton
sudo cpanm MooseX::Types
sudo cpanm MooseX::Types::Common::Numeric
sudo cpanm MooseX::Types::LoadableClass
sudo cpanm MooseX::Types::Structured
sudo cpanm MooseX::Types::URI
sudo cpanm MRO::Compat
sudo cpanm namespace::autoclean
sudo cpanm namespace::clean
sudo cpanm Net::Amazon::AWSSign
sudo cpanm Net::Amazon::S3::Policy
sudo cpanm Net::CoverArtArchive
sudo cpanm Object::AUTHORITY
sudo cpanm Object::Role
sudo cpanm Package::Stash
sudo cpanm Plack
sudo cpanm Plack::Middleware::Debug
sudo cpanm Plack::Middleware::ReverseProxy
sudo cpanm Plack::Test::ExternalServer
sudo cpanm Proc::ProcessTable
sudo cpanm RDF::Query
sudo cpanm RDF::RDFa::Parser
sudo cpanm RDF::Trine
sudo cpanm Readonly
sudo cpanm REST::Utils
sudo cpanm Safe::Isa
sudo cpanm Starman
sudo cpanm Statistics::Basic
sudo cpanm String::CamelCase
sudo cpanm String::Escape
sudo cpanm String::RewritePrefix
sudo cpanm String::ShellQuote
sudo cpanm String::TT
sudo cpanm Sub::Exporter
sudo cpanm Task::Weaken
sudo cpanm Template
sudo cpanm Template::Plugin::Class
sudo cpanm Template::Plugin::JavaScript
sudo cpanm Template::Plugin::Map
sudo cpanm Template::Plugin::Math
sudo cpanm Template::Timer
sudo cpanm Test::Aggregate
sudo cpanm Test::Differences
sudo cpanm Test::JSON
sudo cpanm Test::LongString
sudo cpanm Test::Magpie
sudo cpanm Test::Memory::Cycle
sudo cpanm Test::Mock::Class
sudo cpanm Test::Pod
sudo cpanm Test::Pod::Coverage
sudo cpanm Test::Routine
sudo cpanm Test::WWW::Selenium
sudo cpanm Test::WWW::Selenium::Catalyst
sudo cpanm Test::XPath
sudo cpanm Text::MicroTemplate
sudo cpanm Text::SimpleTable
sudo cpanm Text::Trim
sudo cpanm Text::Unaccent
sudo cpanm Text::WikiFormat
sudo cpanm Throwable
sudo cpanm Time::Duration
sudo cpanm Tree::Simple
sudo cpanm Tree::Simple::Visitor::FindByPath
sudo cpanm TryCatch
sudo cpanm URI
sudo cpanm URI::Escape
sudo cpanm URI::file
sudo cpanm XML::Generator
sudo cpanm XML::LibXML
sudo cpanm XML::LibXML::Debugging
sudo cpanm XML::LibXML::Devel
sudo cpanm XML::Parser
sudo cpanm XML::Parser::Lite
sudo cpanm XML::RegExp
sudo cpanm XML::RSS::Parser::Lite
sudo cpanm XML::SemanticDiff
sudo cpanm XML::Simple
sudo cpanm XML::XPath

I then followed step #3a and checked build.log but found this error in the build.log:
skipped: phantomjs not found, please set MUSICBRAINZ_PHANTOMJS or install phantomjs to the default location
so...
#STEP 2 Install phantomjs via apt-get:

sudo add-apt-repository ppa:jerome-etienne/neoip
sudo apt-get update
sudo apt-get install phantomjs

#STEP 2a Or compile it from source:

sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.7
./build.sh

According to this IRC log
http://chatlogs.musicbrainz.org/musicbr … 01-12.html

phantomjs should be installed in /home/musicbrainz/opt/

#STEP 2a I had compiled phantomjs in the home directory so created a symlink to point to opt:

cd ~/
mkdir opt
cd opt
ln -s /home/musicbrainz/phantomjs

#STEP 3 You now should have all the missing perl modules / MB dependencies so if you know what you're doing (btw - I can't claim to :)), skip step #3a below and just run:

cpanm --installdeps . 

If you did get an error running cpanm --installdeps . , you might well find the solution in this post.  If not, try a google search on the error string (it might take a bit of effort but it's better than asking the developers #musicbrainz-devel on freenode for help setting up a replication server - they've got better things to do!).  For starters you might have another  missing dependency...

#STEP 3a To find out if you have all the required modules for MB, run the following from the musicbrainz-server directory:

cpanm .

Then check musicbrainz/.cpanm/build.log.  It'll say something like error Foo::Bar module missing.  Ianmcorvidaes' post from the thread http://forums.musicbrainz.org/viewtopic.php?id=3774 outlines what you need to do to locate and install missing modules in more detail.

By using the cpanm . command you will probably find other errors in the build.log  - I was just running it to check if all the required dependencies were present.  Once there are no missing module errors, go on to run:

cpanm --installdeps .

Assuming you have got all the perl dependencies and cpanm --installdeps . should return no errors.  Then continue following the install.md instructions to install the postgresql extensions, configure DBDefs.pl and setup the postgresql authentication files postgresql.conf, pg_hba.conf, and/or pg_ident.conf.  NB you must restart the postgresql server if you make any changes to the authentication files.  To do so, run the following:

/usr/lib/postgresql/8.4/bin/pg_ctl reload -D /var/lib/postgresql/8.4/main

If you get stuck, these troubleshooting notes might help:

ON POSTGRESQL AUTHENTICATION ERRORS:
eg. FATAL:  role "musicbrainz" does not exist
- check musicbrainz belongs to the postgres group

id musicbrainz

- add user to group if required:

sudo usermod -a -G postgres musicbrainz

- create the postgres 'role' musicbrainz:

su postgres
createuser -d -a -P musicbrainz
# Enter password for new role: musicbrainz
# Enter it again: musicbrainz

- if you can't su postgres, you will need to set the postgres UNIX password to be able to su postgres (sudo passwd postgres)

- now login to postgres from the musicbrainz user:

su musicbrainz
psql might result in database musicbrainz does not exist

- check psql musicbrain role now exists:

psql
\du

should result in something like the following:

                              List of roles
  Role name  |                   Attributes                   | Member of
-------------+------------------------------------------------+-----------
 musicbrainz | Superuser, Create role, Create DB, Replication | {}
 postgres    | Superuser, Create role, Create DB, Replication | {}

- from postgres, enter \q to quit and return back to the shell:
\q

ON FATAL:  role "root" does not exist:
- carefully re-check the authentication files, postgresql.conf, pg_hba.conf, and/or pg_ident.conf in /etc/postgresql/8.4/main/ or /etc/postgresql/[your version]/main/ as outlined in the install.md instructions.  If you make any changes the authentication files, you must restart the postgresql server:

/usr/lib/postgresql/8.4/bin/pg_ctl reload -D /var/lib/postgresql/8.4/main

#STEP 4 TEST ANB PREPARE DB (these are just my notes and are incomplete, you MUST refer to the install.md instructions which outline these steps below in more detail and are properly maintained):
to create a clean db to test for errors, run the following from the \musicbrainz-server\ dir

carton exec ./admin/InitDb.pl -- --createdb --clean

it should return InitDb.pl successful at the end

#STEP 5 REMOVE TEST DB:

psql -U postgres template1
DROP DATABASE musicbrainz_db;
\d
\q

#STEP 6 import the MBdb dump (ftp://ftp.musicbrainz.org/pub/musicbrai … ullexport/) and run carton exec from the /home/musicbrainz/musicbrainz_server/ directory (this'll take 1-2+hrs depending on your system):
REFER to the install.md instructions on what to do here - these were just my own install notes.

carton exec ./admin/InitDb.pl -- --createdb --import /home/musicbrainz/dump/mbdump*.tar.bz2 --echo

DATABASE TROUBLESHOOTING:
ON CREATE DB ERROR:
Warning: this is a slave replication server, but there is no READONLY connection defined
- Review your server configuration in lib/DBDefs.pm.  Refer to install.md and rembo10's instructions https://github.com/rembo10/headphones/w … inz-Mirror for more info.

ON IMPORT ERRORS:
Error during CreateIndexes.sql at ./admin/InitDb.pl line 108
or
ERROR:  could not create unique index "artist_idx_null_comment" (OR) "label_idx_null_comment"
DETAIL:  Key (name)=(012345) is duplicated.

- Don't import the file mbdump-edit.tar.bz2
AND ALSO
- comment out or remove two lines in the file admin/sql/CreateIndexes.sql: lines 8 and 9, and /or 159 & 160:

CREATE UNIQUE INDEX artist_idx_null_comment ON artist (name) WHERE comment IS NULL;
CREATE UNIQUE INDEX artist_idx_uniq_name_comment ON artist (name, comment) WHERE comment IS NOT NULL;
CREATE UNIQUE INDEX label_idx_null_comment ON label (name) WHERE comment IS NULL;
CREATE UNIQUE INDEX label_idx_uniq_name_comment ON label (name, comment) WHERE comment IS NOT NULL;

This second requirement to comment out lines of code is a known bug. You can read more about it here: http://forums.musicbrainz.org/viewtopic.php?id=3839 and here: http://codereview.musicbrainz.org/r/2226/

ON DATABASE ALREADY EXISTS:
DBD::Pg::st execute failed: ERROR:  database "musicbrainz_db" already exists at /home/musicbrainz/musicbrainz-server/admin/../lib/Sql.pm line 107.
- follow #STEP 5 above to remove the existing musicbrainz_db.

#STEP 7 To start the server:

carton exec -- plackup -Ilib -r

ON RUNTIME ERROR:
Error while loading app.psgi: Can't locate Catalyst/Plugin/Session/Store/Memcached.pm in @INC (@INC contains: lib /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at lib/Catalyst/Plugin/Session/Store/MusicBrainz.pm line 3.
BEGIN failed--compilation aborted at lib/Catalyst/Plugin/Session/Store/MusicBrainz.pm line 3.
Compilation failed in require at lib/MusicBrainz/Server.pm line 0.
Compilation failed in require at app.psgi line 21.
BEGIN failed--compilation aborted at app.psgi line 21.

- not all modules were installed, try to build without --deployment from the musicbrainz-server dir

carton install

If you get an access denied error, use sudo carton install instead.

Failing that, remove the local folder in musicbrainz-server

rm -rf local
carton install

#STEP 8 To bring the db up to date
carton exec -- ./admin/replication/LoadReplicationChanges

#STEP 9 AUTOMATION:
These instructions were from rembo10's wiki page:
https://github.com/rembo10/headphones/w … inz-Mirror

To load the replication changes manually, you'll need to run:

carton exec -- ./admin/replication/LoadReplicationChanges

Alternatively, you can use the following script which can start/stop the server, and load the replication changes.

http://paste2.org/p/2042937

Save it as "/usr/bin/mbcontrol", and run:

chmod a+x /usr/bin/mbcontrol

which will make it executable.

Run it as the musicbrainz user, making sure you have write access to /var/run/musicbrainz and var/log/musicbrainz.

Usage:

mbcontrol start/stop (start and stop the server)

mbcontrol hourly (load the replication changes)

To have the script run automatically, you can stick a line into the musicbrainz user's crontab:

crontab -e

and add this line, which will run "mbcontrol hourly" at 10 minutes past the hour every hour:

10 * * * * /usr/bin/mbcontrol hourly


----------------
It's a longwinded post but the intention here was to put a lot of the (apparently) common problems I found setting up a MB server on ubuntu from scratch in one place, save a lot of googling, and the devs on IRC from responding to the same questions over and over again.  If there's something in the instructions which could do with editing, pls let me know.  Lastly, a humble bow and thanks to everyone on the musicbrainz team :) Without music to decorate it, time is just a bunch of boring production deadlines or dates by which bills must be paid. (Zappa)
m****pain