# How to avoid the ".. is already installed" errors



## HL1234 (Mar 1, 2017)

Hi,
I started to install some ports in a fresh system and try to do it step by step to get more out how it works.
I face a problem - I know how to fix it. But I like to avoid it before it occurs.

I.e. there are two just simple installations:
First I installed perl5.24 from ports:
/usr/ports/lang/perl5.24

Then I go to /usr/ports/devel/p5-Locale-gettext. And I check out:
`make build-depends-list` tell me it need:
/usr/ports/devel/gettext-runtime
/usr/ports/devel/gettext-tools
/usr/ports/lang/perl5.24
/usr/ports/ports-mgmt/pkg

Fine! all what is needed I have already installed on the system.

But then, when doing `make build` it comes to that "*.. is already installed*" error and it "_stopped in /usr/ports/lang/perl5.24_" because it has build perl5.24 again.

So, I've got two questions:
Why does the port "p5-Locale-gettext" build "perl5.24" again although "perl5.24" has already been installed some minutes before and is on the system?

How can I avoid that "p5-Locale-gettext" will build "perl5.24" again, is there i.e. any special switch to tell `make` not to do that?

Thanks


----------



## ShelLuser (Mar 2, 2017)

I am fairly sure that running `# make build` inside a ports directory will not trigger that error. _Fairly_ sure, I cannot rule out errors. But making / building the port doesn't install it thus this should not happen. Nor does it on 10.3:


```
My idea of roughing it turning the air conditioner too low.

macron:/home/peter $ su
Password:
You have mail.
root@macron:/home/peter # cd /usr/ports/devel/p5-Loc
p5-Locale-Maketext-Fuzzy/   p5-Locale-PGetText/
p5-Locale-Maketext-Gettext/ p5-Locale-PO/
p5-Locale-Maketext-Lexicon/ p5-Locale-gettext/
p5-Locale-Maketext-Simple/  p5-Locale-libintl/
p5-Locale-Maketext/         p5-LockFile-Simple/
p5-Locale-Msgfmt/
root@macron:/home/peter # cd /usr/ports/devel/p5-Locale-gettext/
root@macron:/usr/ports/devel/p5-Locale-gettext # pkg info -x gettext
gettext-runtime-0.19.8.1_1
gettext-tools-0.19.8.1
p5-Locale-gettext-1.06
php56-gettext-5.6.30
py27-python-gettext-3.0
root@macron:/usr/ports/devel/p5-Locale-gettext # make build
root@macron:/usr/ports/devel/p5-Locale-gettext #
```
I think something else is happening at your end....


----------



## MarcoB (Mar 2, 2017)

Maybe you can add "FORCE_PKG_REGISTER=YES" in your make.conf. This would avoid the error message, but this isn't a remedy for the actual cause. But as ShelLuser said this only happens when doing a "make install".


----------



## talsamon (Mar 2, 2017)

I don't know if it helps in this case. But sometimes
the dependencies are not properly cleand and causes
"strange" errors. `make clean-depends`
helps.


----------



## SirDice (Mar 2, 2017)

MarcoB said:


> Maybe you can add FORCE_PKG_REGISTER=YES in your make.conf.


Do not set this until you fully understand the consequences of it.


----------



## HL1234 (Mar 2, 2017)

Thanks for Your support,
but
(1) I know with "FORCE_PKG_REGISTER=YES" I can build and install that port. (2) Also I could do a `make reinstall`, that will the dependent "perl5.24" of "p5-Locale-gettext", in that example, reinstall and then it would go on with the build of it.
(3) ShelLuser are right that a `make build` does not install that port. But if a port has dependencies  that must be installed first to build the port the instructions in the port Makefile will do that. 
The problem I figure out here, and I do not understand whats going on, is: what is when a dependencies of a port have to install, because of the instructions in Makefile, but it is already present in the system. I do expect that it should be recognized and not that all of the dependencies is build again, if they are uptodate (also because of the time it costs). And sure, if that dependency will be installed by the Makefile, before continue with building the port, it come's to a stop,  because the installation fail, because the dependency is already there. This behavior is on one hand good, because it should not quit overwrite an already completed installation, with  exception you force this with: "FORCE_PKG_REGISTER=YES". 

My question is, how to avoid this all? I do not want (in that example and elsewhere) to reinstall a installation, when I know the actual version is already installed on the system.

talsamon: I have not test `make clean-depends` but will do it. Im searching for HELP of all make _commands _but could not find it. In `man make` I have not seen there anything about `make config`, `make build`, `make build-depends-list`, etc. Where is the description of all of this make _commands_? 

Thanks


----------



## SirDice (Mar 2, 2017)

HL1234 said:


> I know with "FORCE_PKG_REGISTER=YES" I can build and install that port.


Yes, that's the nature of FORCE_PKG_REGISTER. But instead of fixing things you've inadvertently screwed up the system even further. Do not use this! Seriously. Yes, you will get this port to install. But it doesn't fix the reason why it failed it in the first place. Those checks are done for good reason and you've just told it to ignore those checks. Which really only makes things worse, not better. You need to fix the issue not the symptoms. 



> I'm searching for HELP of all make _commands _but could not find it.


Targets relevant to ports: ports(7).



> In man make I have not seen there anything about make config, make build, make build-depends-list, etc. Where is the description of all of this make commands?


You won't find it there because they're not arguments for make(1) itself, they're so-called build targets. These are defined in a Makefile and could be anything.


----------



## HL1234 (Mar 2, 2017)

I've tried
`make clean-depends`
but it doesn't help.
I figured out by creating a build.log file that this port is looking for the wrong thing:

/usr/ports/devel/p5-Locale-gettext]  `script build.log make build`


```
Script started on Thu Mar  2 16:14:23 2017
Command: make build
===>   p5-Locale-gettext-1.06 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by p5-Locale-gettext-1.06 for building
===>  Extracting for p5-Locale-gettext-1.06
=> SHA256 Checksum OK for gettext-1.06.tar.gz.
===>  Patching for p5-Locale-gettext-1.06
===>  Applying FreeBSD patches for p5-Locale-gettext-1.06
===>   p5-Locale-gettext-1.06 depends on executable: msgfmt - found
===>   p5-Locale-gettext-1.06 depends on file: /usr/local/bin/perl5.24 - not found
===>...........
===>  Building for perl5-5.24.1
---
.............
===>  Installing for perl5-5.24.1
===>  Checking if perl5 already installed
===>   perl5-5.24.1 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of perl5
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/lang/perl5.24
*** Error code 1
...
Stop.
make: stopped in /usr/ports/devel/p5-Locale-gettext
```
As I told perl5.24 is already installed. I find in 
`ls /usr/local/bin/p*`
[FONT=Courier New]-rwxr-xr-x  3 root  wheel   7680  1 März 22:40 /usr/local/bin/perl
-rwxr-xr-x  3 root  wheel   7680  1 März 22:40 /usr/local/bin/perl5
-rwxr-xr-x  3 root  wheel   7680  1 März 22:40 /usr/local/bin/perl5.24.1[/FONT]


There is "perl" "perl5" "perl5.24.1" but not a "perl5.24". I think I can create a link or make a copy form perl5.24.1 to perl5.24. That will fix it.
`# perl5.24.1 -v`

```
This is perl 5, version 24, subversion 1 (v5.24.1) built for amd64-freebsd-thread-multi
Copyright 1987-2017, Larry Wall...
```
But this do not solve the principal problem:
If a port/Makefile does not recognize the right thing - how can I tell "make" on the command line not to build a required dependency (with exception it need the external sources anyway) ?


----------



## SirDice (Mar 2, 2017)

It does recognize the right thing, the problem is that your system is in an inconsistent state.


----------



## HL1234 (Mar 2, 2017)

SirDice said:


> It does recognize the right thing, the problem is that your system is in an inconsistent state.


sorry - but I do not understand. The system has a fresh FreeBSD 11.0 installation. I have just installed a few ports:

```
dialog4ports-0.1.6
gettext-runtime-0.19.8.1_1
gettext-tools-0.19.8.1
gmake-4.2.1_1
indexinfo-0.2.6
perl5-5.24.1
pkg-1.10.0_2
portmaster-3.17.10
tcl87-8.7.a0.20170202_1
```
`uname -a`

```
FreeBSD RS1000G7SE 11.0-RELEASE-p2 FreeBSD 11.0-RELEASE-p2 
#0: Mon Oct 24 06:55:27 UTC 2016     
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
```
Why should the system be in an inconsistent state? Or how should this has been happened?
Thanks


----------



## MarcoB (Mar 2, 2017)

Did you update your portstree before installing these ports?
Try to clean things up too like "pkg autoremove" and "portsclean -C -D -DD" because like SirDice said your ports/pkgs aren't in a clean state now.


----------



## SirDice (Mar 2, 2017)

HL1234 said:


> Why should the system be in an inconsistent state? Or how should this has been happened?


Now those are the right questions to ask and what we need to figure out 

The point is that this check is done in /usr/ports/Mk/Uses/perl5.mk which all those Perl ports use. So if one port fails this check, all other Perl ports should fail on the same thing.

Do you have a /etc/make.conf file? If you have, what does it contain?


----------



## HL1234 (Mar 2, 2017)

MarcoB yes, I have done a complete update of the portstree
SirDice right; in between I have found some out by looking into the Makefile of "p5-Locale-gettext" and searching in /usr/ports/Mk/bsd.port.mk a "USES=perl5". In the subdirectory Uses I found then the file perl5.mk.
In it I find something like this:

```
.......
# PERL_LEVEL   - Perl version as an integer of the form MNNNPP, where
#         M is major version, N is minor version, and P is
#         the patch level. E.g., PERL_VERSION=5.14.4 would give
#         a PERL_LEVEL of 501404. This can be used in comparisons
#         to determine if the version of perl is high enough,
#         whether a particular dependency is needed, etc.
.....
# Mk/bsd.default-versions.mk in sync.
.  if   ${PERL_LEVEL} >= 502400
PERL_PORT?=   perl5.24
.  elif   ${PERL_LEVEL} >= 502200
PERL_PORT?=   perl5.22
.  else # ${PERL_LEVEL} < 502200
PERL_PORT?=   perl5.20
.  endif
------
```
I have a /etc/make.conf
The contend for perl is

```
#270228 added for Perl
# -----------------------------------------------------------------------------
DEFAULT_VERSIONS= perl=5.24
# because I do not want a installation take perl5.22 or so...
#.....
# added by use.perl
PERL_VERSION=5.24
```
Should I set this to
DEFAULT_VERSIONS= perl=5.24.1
and
PERL_VERSION=5.24.1 ?
I thought these settings only targeting major versions description.


----------



## SirDice (Mar 2, 2017)

No, the version refers to the port's name, which is perl5.24. So DEFAULT_VERSIONS+= perl=5.24 is correct. It's not needed though, the default is already set to 5.24 (see /usr/ports/Mk/bsd.default-versions.mk), but doesn't do any harm.

The PERL_VERSION line shouldn't be there and may actually be the cause of the problems.


----------



## HL1234 (Mar 2, 2017)

Dear SirDice your are great 
That was it. I've changed PERL_VERSION=5.24 to PERL_VERSION=5.24.1 in /etc/make.conf and the Makefile of /usr/ports/devel/p5-Locale-gettext don't complain any more about the missing perl5 version.

But at end - when I would not find such a solution: How can I avoid the ".. is already installed" error with a switch, or make command on command line, that any dependency should not be build and installed for a specific port?


----------



## SirDice (Mar 3, 2017)

Remove the PERL_VERSION from make.conf. It shouldn't be there at all.



HL1234 said:


> But at end - when I would not find such a solution: How can I avoid the ".. is already installed" error with a switch, or make command on command line, that any dependency should not be build and installed for a specific port?


You shouldn't need to do anything, this situation should never occur.


----------



## wblock@ (Mar 3, 2017)

MarcoB said:


> Maybe you can add "FORCE_PKG_REGISTER=YES" in your make.conf. This would avoid the error message, but this isn't a remedy for the actual cause. But as ShelLuser said this only happens when doing a "make install".


Please don't do that.  At best, it will only hide the real problem until it becomes too severe to fix.


----------



## HL1234 (Mar 3, 2017)

Hello,
SirDice I will do so. I think I have these entry from earlier days. I found such a advice, that has also belongs to mine for /etc/make.conf. I can remember that this entry was anytime, long years ago, also set in my make.conf and I has just update the version number to 5.24. But this was wrong it has to be 5.24.1.




Edit: above comes from: https://books.google.de/books?id=2g...AG#v=onepage&q=PERL_VERSION make.conf&f=false
or see https://groups.google.com/forum/#!topic/mailing.freebsd.questions/z-EVoI5FfI0[1-25]

The question is, has this really changed not to set and only use the new option 
	
	



```
DEFAULT_VERSIONS+= perl5=5.24
```
 ?


----------



## SirDice (Mar 3, 2017)

HL1234 said:


> The question is, has this really changed not to set and only use the new option


Yes, it has. Setting PERL_VERSION caused the issues you were having.


----------



## wblock@ (Mar 3, 2017)

That advice came from 2006.  And even then it said "...there is no reason to mess with this file."


----------

