Monday, 8 September 2008

sudo and pkg_add working together

Installing software into FreeBSD could be done 2 ways. The nice way using ports and the fast way using packages. The mechanism to install packages is using pkg_add. As installing software requires root privileges sudo should be the way to go for it.

But while using sudo to call pkg_add gives you an error:

[rick@davis /usr/home/rick]$ sudo pkg_add -r mysql51-serverError: FTP Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.0-release/Latest/mysql51-server.tbz: Syntax error, command unrecognized
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.0-release/Latest/mysql51-server.tbz' by URL


This problem is caused by the lack of a few environment variables which get lost while calling it trough sudo, as mentioned in this mailing list post to freebsd-ports

They way to solve it is to call sudo with argument -E which gives you they required result :-)

[rick@davis /usr/home/rick]$ sudo -E pkg_add -r ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.0-release/Latest/mysql51-server.tbz
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.0-release/Latest/mysql51-server.tbz... Done.
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.0-release/All/mysql-client-5.1.22.tbz... Done.
Added group "mysql".
Added user "mysql".

No comments:

Post a Comment