# Bizarre issue with pkg upgrade



## rekabis (Feb 7, 2014)

I have a bizarre issue with pkg upgrade - it wants to install packages that are older than ones already installed.

For example, I am trying to set up a LAMP server, but I have the following installed:
PHP 5.5
Ruby 2.0
MariaDB 5.5
Apache 2.4

Problem is, when I run a pkg upgrade, it wants to *downgrade* me to ruby 1.9 and mysql55-client even though I have ruby 2.0 and mariadb55-client installed.

How do I permanently prevent the installation of older ports? Keep in mind, these are the only things requesting installation:

```
$ sudo pkg upgrade
Updating repository catalogue
Upgrades have been requested for the following 40 packages:

        Reinstalling mariadb55-client-5.5.33a_1 (options changed)
        Reinstalling php55-5.5.8 (options changed)
        Reinstalling php55-extensions-1.8 (options changed)
        Installing ruby: 1.9.3.484_1,1
        Installing mysql55-client: 5.5.35
        Installing ruby19-iconv: 1.9.3.484,1
        Reinstalling rubygem-ansi-1.4.3 (direct dependency changed)
        Reinstalling rubygem-builder-3.0.4 (direct dependency changed)
        Reinstalling rubygem-bundler-1.3.5 (direct dependency changed)
        Reinstalling rubygem-erubis-2.7.0_1 (direct dependency changed)
        Reinstalling rubygem-hike-1.2.3 (direct dependency changed)
        Reinstalling rubygem-i18n-0.6.9,2 (direct dependency changed)
        Reinstalling rubygem-journey-1.0.4 (direct dependency changed)
        Reinstalling rubygem-json-1.8.1 (direct dependency changed)
        Reinstalling rubygem-json_pure-1.8.1 (direct dependency changed)
        Reinstalling rubygem-mime-types-1.25.1 (direct dependency changed)
        Reinstalling rubygem-minitest-5.0.6 (direct dependency changed)
        Reinstalling rubygem-multi_json-1.8.4 (direct dependency changed)
        Reinstalling rubygem-polyglot-0.3.3 (direct dependency changed)
        Reinstalling rubygem-rack-1.4.5,3 (direct dependency changed)
        Reinstalling rubygem-rack-cache-1.2 (direct dependency changed)
        Reinstalling rubygem-rack-ssl-1.3.3 (direct dependency changed)
        Reinstalling rubygem-rack-test-0.6.2 (direct dependency changed)
        Reinstalling rubygem-rake-10.1.1 (direct dependency changed)
        Reinstalling rubygem-sqlite3-1.3.8 (direct dependency changed)
        Reinstalling rubygem-thor-0.18.1 (direct dependency changed)
        Reinstalling rubygem-tilt-2.0.0 (direct dependency changed)
        Reinstalling rubygem-treetop-1.4.15 (direct dependency changed)
        Reinstalling rubygem-turn-0.9.6 (direct dependency changed)
        Reinstalling rubygem-tzinfo-0.3.38 (direct dependency changed)
        Reinstalling ruby19-mysql-2.8.2_1 (direct dependency changed)
        Reinstalling rubygem-activesupport-3.2.16 (direct dependency changed)
        Reinstalling rubygem-execjs-2.0.2 (direct dependency changed)
        Reinstalling rubygem-mail-2.5.4_1,1 (direct dependency changed)
        Reinstalling rubygem-railties-3.2.16 (direct dependency changed)
        Reinstalling rubygem-uglifier-2.4.0 (direct dependency changed)
        Reinstalling rubygem-actionmailer-3.2.16 (direct dependency changed)
        Reinstalling rubygem-activemodel-3.2.16 (direct dependency changed)
        Reinstalling rubygem-activeresource-3.2.16 (direct dependency changed)
        Reinstalling rubygem-coffee-rails-3.2.2_1 (direct dependency changed)
```

As you can see, nothing else is “getting in the way” with some sort of a dependency. For some reason, the system wants to downgrade Ruby and additionally install the mysql55-client package even though mariadb55-client is already installed.


----------



## trh411 (Feb 7, 2014)

Here is what I get looking at the dependencies for one of the items in your list devel/rubgem-ansi:

```
# cd /usr/ports/devel/rubygem-ansi
# make build-depends-list
/usr/ports/devel/ruby-gems
/usr/ports/lang/ruby19
/usr/ports/ports-mgmt/pkg
# make run-depends-list
/usr/ports/devel/ruby-gems
/usr/ports/lang/ruby19
```
So lang/ruby19 is required to both build and run devel/rubgem-ansi. That is why it wants to install it. I did not check any of the others. Perhaps someone else can suggest a way to alter this behavior with /etc/make.conf?


----------



## rekabis (Feb 7, 2014)

That is very strange, because installing devel/rubygem-ansi (via devel/ruby-gems) did not require devel/ruby19 at all. I already had devel/ruby20 installed, and it accepted that just fine.


----------



## SirDice (Feb 7, 2014)

If you build rubygem-ansi from ports it will happilly use Ruby 2.0. The official packages however are built against the default version, which is 1.9. Same goes for MariaBD vs. MySQL, MySQL is the default.

If you want or need to change the defaults you have to build from ports and/or build your own package repository with all the defaults set the way you want it.


----------



## gesperon (Feb 7, 2014)

The solution I found to this issue was to use `pkg lock ...` on the packages I don't want to be changed. Then I manually unlock and upgrade them with `portupgrade`.

For example if I have apache with a bunch of non-default options and dependencies, I just do `pkg lock apache22`. And once a new version shows up after `portsnap fetch && portsnap update && portversion -vl "<"` unlock it and portupgrade it.

EDIT: granted, it is a bit of administration overhead. I wish `pkg` was able to handle those situations


----------

