Bug 34936 - java.io.IOException: cvs: not found when calling ant from crontab
Summary: java.io.IOException: cvs: not found when calling ant from crontab
Status: RESOLVED WORKSFORME
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.6.2
Hardware: Other Solaris
: P2 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-16 13:51 UTC by Stefan Goor
Modified: 2008-02-22 12:18 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Goor 2005-05-16 13:51:22 UTC
I am trying to use ant in a crontab task but it fails constantly on the <cvs> 
commands.

The error reported from crontab is:  'cvs: not found'
and the error logged by ant is: 'java.io.IOException: cvs: not found'

CVS is available on the path as I set the PATH=/usr/local/bin:$PATH prior to 
calling the ant command in the script that is used by crontab.

I checked to see if cvs can be found in crontab when it is not is an ant 
script and it was called without any problems.

From my understanding of the cvs task, all it requires is for cvs to be on the 
PATH, but this does not seem to be the case.  Is there anyway of specifying 
the location of cvs?
Comment 1 Alexey Solofnenko 2005-05-16 17:40:21 UTC
In my experience, when commands are executed from cron, their environment is not set.
You need to execute ". ~/.profile" before running any other commands.
Comment 2 Dominique Devienne 2005-05-17 04:13:18 UTC
> Is there anyway of specifying the location of cvs?

You can always use <exec executable="/path/to/cvs"> and see if it makes a 
difference. You could also echo the PATH before executing <cvs>. Try also 
<available> to confirm it's really in the path.

Then some script other than Ant's own shell script could change the 
environment. --DD

Comment 3 Stefan Goor 2005-05-17 09:58:15 UTC
(In reply to comment #1)
> In my experience, when commands are executed from cron, their environment is 
not set.
> You need to execute ". ~/.profile" before running any other commands.

Thanks for the response.  I tried calling the .profile that I normally use but 
crontab complained because of the 'export' command on each of the variables so 
I found some information on the Internet 
(http://www.aplawrence.com/Unixart/cron.html) that said you don't need to use 
export so I created a script that set all the variables required and then 
called the ant script but still no joy.
To check if the cvs bin directory was added I echoed the PATH to a file and 
found it was there and also tried calling cvs directly in the script and the 
command was found.  It only seemed to have problems in the ant script.

Thanks,
Stefan
Comment 4 Alexey Solofnenko 2005-05-17 18:05:42 UTC
> I found some information on the Internet 
> (http://www.aplawrence.com/Unixart/cron.html) that said you don't need to use 
> export so I created a script that set all the variables required and then 
> called the ant script but still no joy.

I think this is something else. Your script is executed with some interpreter 
and that interpreter does require "export". In any case, add plain "set" command
into your cron job script to see what environment is set and what is missing
(look for PATH, HOME, TMP, etc. environment variables). You may also need to
change the current directory before executing any commands.
Comment 5 Matt Benson 2005-05-27 15:36:45 UTC
ping, is this still an issue?
Comment 6 Steve Loughran 2006-08-23 12:50:08 UTC
Stefan, is this still a problem? I'm going to close it as worksforme, because
its a cron setup problem, not ant.