Bug 651023

Summary: Cannot compile a C++ hello word in Eclipse CDT : ccache: failed to create /var/cache/ccache/tmp
Product: [Fedora] Fedora Reporter: Pierre Blavy <pierreblavy>
Component: ccacheAssignee: Ville Skyttä <ville.skytta>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: akurtako, christopherheiny, don-redhat-z6y, ferfong, jjohnstn, seandarcy, ville.skytta
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ccache-3.1.4-3.fc14 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-16 20:51:50 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Fix candidate /etc/profile.d/ccache.sh none

Description Pierre Blavy 2010-11-08 17:01:52 UTC
Description of problem:
Dear reader, I cannot compile a simple hello word C++ program





Version-Release number of selected component (if applicable):

Eclipse 3.6.1

Eclipse CDT P2 Customizations for SDK installation
Version: 1.0.0.201009241320
Build id: 201010072134

Complete FEDORA  14 update 08-nov-2010



How reproducible:
Always




Steps to Reproduce:
1. create a C++ hello word project
2.compile it
  



Actual results:

**** Build of configuration Debug for project yuna ****
make all 
Building file: ../src/yuna.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/yuna.d" -MT"src/yuna.d" -o"src/yuna.o" "../src/yuna.cpp"
ccache: failed to create /var/cache/ccache/tmp (Permission denied)
make: *** [src/yuna.o] Erreur 1


Expected results:
Compile.


Additional info:
mkdir /var/cache/ccache/tmp; 
chmod a+rwx  /var/cache/ccache/tmp  
didn't fix the bug


setenforce 0; 
didn't fix the bug

Comment 1 Pierre Blavy 2010-11-08 17:15:13 UTC
yum remove ccache is a workaround.

Comment 2 Jeff Johnston 2010-11-08 18:57:25 UTC
The failure is not occurring in Eclipse or the CDT.  I would expect this to fail just the same from the command line without Eclipse up and running.  I am forwarding the bug to ccache as I am not familiar enough to suggest what you should be checking for your local set-up.  If it turns out that that the CDT is mucking with your set-up, then it can be redirected back here again when more details are available.

Comment 3 Ville Skyttä 2010-11-08 22:03:33 UTC
Could you let me know what the following console commands output for your user:

env | grep CCACHE

ls -lad /var/cache/ccache /var/cache/ccache/tmp

groups

rpm -qV ccache

Comment 4 Ville Skyttä 2010-11-08 22:09:47 UTC
(These commands should be run while ccache is installed and a new console opened after installing it.)

Comment 5 Pierre Blavy 2010-11-09 11:02:14 UTC
[pierre@pcpblavy workspace]$ su -c'yum -y install ccache'
[...]
Installé:
  ccache.x86_64 0:3.1-1.fc14   

[pierre@pcpblavy workspace]$konsole



[pierre@pcpblavy workspace]$ env | grep CCACHE
CCACHE_DIR=/var/cache/ccache
CCACHE_UMASK=002



[pierre@pcpblavy workspace]$ ls -lad /var/cache/ccache /var/cache/ccache/tmp
ls: impossible d'accéder à /var/cache/ccache/tmp: Permission non accordée
drwxrws---. 19 root ccache 4096 18 sept. 12:33 /var/cache/ccache



[pierre@pcpblavy workspace]$ groups
pierre

[pierre@pcpblavy workspace]$ rpm -qV ccache
[pierre@pcpblavy workspace]$

Comment 6 Ville Skyttä 2010-11-09 16:02:55 UTC
(In reply to comment #5)
> [pierre@pcpblavy workspace]$ env | grep CCACHE
> CCACHE_DIR=/var/cache/ccache
> CCACHE_UMASK=002
> 
> [pierre@pcpblavy workspace]$ ls -lad /var/cache/ccache /var/cache/ccache/tmp
> ls: impossible d'accéder à /var/cache/ccache/tmp: Permission non accordée
> drwxrws---. 19 root ccache 4096 18 sept. 12:33 /var/cache/ccache
> 
> [pierre@pcpblavy workspace]$ groups
> pierre

As I suspected, this is the problem.  Your ccache dir is set to /var/cache/ccache, but you don't have permissions to that dir (you're not a member of the ccache group).  What I don't know yet why is your CCACHE_DIR set there; /etc/profile.d/ccache.sh should set it only if you have write access to it.

Could you try finding out what sets your CCACHE_DIR to that value?  Do you have any CCACHE_* settings in your shell profile files (apart from /etc/profile.d/ccache.*sh)?  For example if you use bash,

grep -F CCACHE /etc/bashrc /etc/profile ~/.bash_profile ~/.bashrc \
    /etc/profile.d/*sh

Comment 7 sean 2010-11-15 02:07:29 UTC
This same issue is happening with me on F14. It's not limited to eclipse. Any time ccache is used this occurs.

grep -F CCACHE /etc/bashrc /etc/profile ~/.bash_profile ~/.bashrc

shows nothing. This is a brand new bare metal install of F14.

I messed with permissions of /var/cache[/ccache], but no luck. Have now removed ccache.

Comment 8 Pierre Blavy 2010-11-15 13:23:52 UTC
Hi, thank for your information


I do not have a ccache.sh file
root@pcpblavy ~]# locate ccache.sh
[root@pcpblavy ~]#

I don't think I've got a CCACHE redirection
[pierre@pcpblavy ~]$ grep -F CCACHE /etc/bashrc /etc/profile ~/.bash_profile ~/.bashrc \
     /etc/profile.d/*sh
[pierre@pcpblavy ~]$ 

(idem for root)



My Fedora install is a yum upgrade from Fedora 13 to Fedora 14
I've tryed to reinstall ccache with: yum -y remove ccache; yum -y install ccache;

Comment 9 Ville Skyttä 2010-11-15 17:03:05 UTC
(In reply to comment #7)
> grep -F CCACHE /etc/bashrc /etc/profile ~/.bash_profile ~/.bashrc
> 
> shows nothing.

sean, you missed one argument to grep: /etc/profile.d/*sh (see comment 6).


(In reply to comment #8)
> I do not have a ccache.sh file
> root@pcpblavy ~]# locate ccache.sh
> [root@pcpblavy ~]#

Maybe your locate databases aren't up to date.  Try ls -la /etc/profile.d/ccache.*sh

> [pierre@pcpblavy ~]$ grep -F CCACHE /etc/bashrc /etc/profile ~/.bash_profile
> ~/.bashrc \
>      /etc/profile.d/*sh

I don't know how this would be possible, the ccache package includes /etc/profile.d/ccache.sh and /etc/profile.d/ccache.sh, and both of them most certainly contain the string CCACHE.  And they had been removed while ccache was installed, rpm -V ccache should have told us about it.  Did you run this grep command while you had ccache installed?

Comment 10 Ville Skyttä 2010-11-21 09:53:15 UTC
(Requested info still needed.)

Comment 11 Pierre Blavy 2010-11-22 09:26:33 UTC
Hi, here is your required information


[root@pcpblavy ~]# yum -y install ccache;updatedb;
[bla bla bla ...]
---> Paquet ccache.x86_64 0:3.1-1.fc14 marqué pour être installé 
[bla bla bla ...]
Install       1 Package(s)
[bla bla bla ...]
3.1-1.fc14.x86_64.rpm                                                           [bla bla bla ...]               

Installé:
  ccache.x86_64 0:3.1-1.fc14                                                                    Terminé !


#-------------------------------------

[root@pcpblavy ~]# ls -la /etc/profile.d/ccache.*sh
-rw-r--r--. 1 root root 634 18 sept. 12:33 /etc/profile.d/ccache.csh
-rw-r--r--. 1 root root 659 18 sept. 12:33 /etc/profile.d/ccache.sh


#-------------------------------------

[root@pcpblavy ~]# grep -F CCACHE /etc/bashrc /etc/profile ~/.bash_profile ~/.bashrc
[root@pcpblavy ~]#

[root@pcpblavy ~]# su pierre
[pierre@pcpblavy root]$  grep -F CCACHE /etc/bashrc /etc/profile ~/.bash_profile ~/.bashrc
[pierre@pcpblavy root]$ 


I've run (again) this command after a fresh ccache install, both in root and user mode, and I only get an empty answer.

#-------------------------------------


[root@pcpblavy ~]# rpm -V ccache 
[root@pcpblavy ~]# 

#-------------------------------------


[root@pcpblavy ~]# ls -la /etc/profile.d/ccache.*sh
-rw-r--r--. 1 root root 634 18 sept. 12:33 /etc/profile.d/ccache.csh
-rw-r--r--. 1 root root 659 18 sept. 12:33 /etc/profile.d/ccache.sh


#-------------------------------------

[root@pcpblavy ~]# cat /etc/profile.d/ccache.csh
# Use ccache by default.  Users who don't want that can set the CCACHE_DISABLE
# environment variable in their personal profile.

if ( "$path" !~ */usr/lib64/ccache* ) then
    set path = ( /usr/lib64/ccache $path )
endif

# If /var/cache/ccache is writable, use a shared cache there.  Users who don't
# want that even if they have that write permission can set the CCACHE_DIR
# and unset the CCACHE_UMASK environment variables in their personal profile.

if ( ! $?CCACHE_DIR && -w /var/cache/ccache && -d /var/cache/ccache ) then
    setenv CCACHE_DIR /var/cache/ccache
    setenv CCACHE_UMASK 002
    unsetenv CCACHE_HARDLINK
endif












#-------------------------------------


[root@pcpblavy ~]# cat /etc/profile.d/ccache.csh
# Use ccache by default.  Users who don't want that can set the CCACHE_DISABLE
# environment variable in their personal profile.

if ( "$path" !~ */usr/lib64/ccache* ) then
    set path = ( /usr/lib64/ccache $path )
endif

# If /var/cache/ccache is writable, use a shared cache there.  Users who don't
# want that even if they have that write permission can set the CCACHE_DIR
# and unset the CCACHE_UMASK environment variables in their personal profile.

if ( ! $?CCACHE_DIR && -w /var/cache/ccache && -d /var/cache/ccache ) then
    setenv CCACHE_DIR /var/cache/ccache
    setenv CCACHE_UMASK 002
    unsetenv CCACHE_HARDLINK
endif
[root@pcpblavy ~]# cat /etc/profile.d/ccache.sh
# Use ccache by default.  Users who don't want that can set the CCACHE_DISABLE
# environment variable in their personal profile.

case ":${PATH:-}:" in
    *:/usr/lib64/ccache:*) ;;
    *) PATH="/usr/lib64/ccache${PATH:+:$PATH}" ;;
esac

# If /var/cache/ccache is writable, use a shared cache there.  Users who don't
# want that even if they have that write permission can set the CCACHE_DIR
# and unset the CCACHE_UMASK environment variables in their personal profile.

if [ -z "${CCACHE_DIR:-}" ] && [ -w /var/cache/ccache ] && [ -d /var/cache/ccache ] ; then
    export CCACHE_DIR=/var/cache/ccache
    export CCACHE_UMASK=002
    unset CCACHE_HARDLINK
fi



updatedb
locate ccache*






#-------------------------------------
[root@pcpblavy ~]# cat ~/.bash_profile ~/.bashrc
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias yum-update='yum clean all; yum -y --changelog update yum rpm python;    yum --changelog update;'
alias yum-update-testing='yum clean all; yum --changelog --enablerepo=updates-testing update ;'


# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi



#--------------------------------------------------
[root@pcpblavy ~]# su pierre
[pierre@pcpblavy root]$ cat ~/.bash_profile ~/.bashrc 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi


#umask
umask 0077

# User specific aliases and functions
alias temperature='cat /proc/acpi/thermal_zone/THM/temperature'

Comment 12 Ville Skyttä 2010-11-22 15:46:30 UTC
(In reply to comment #11)
> [pierre@pcpblavy root]$  grep -F CCACHE /etc/bashrc /etc/profile
> ~/.bash_profile ~/.bashrc
> [pierre@pcpblavy root]$ 
> 
> I've run (again) this command after a fresh ccache install, both in root and
> user mode, and I only get an empty answer.

That's because you're missing the /etc/profile.d/*sh argument to grep, please pay close attention to end of comment 6.  But nevermind, you posted the whole contents of the profile.d ccache scripts so I've now seen them.

Unfortunately I still have no clue why this would happen, /etc/profile.d/ccache.sh clearly does its CCACHE_DIR, CCACHE_UMASK and CCACHE_HARDLINK modifications if: 1) CCACHE_DIR is non-empty, and 2) /var/cache/ccache is writable, and 3) /var/cache/ccache is a directory:

> if [ -z "${CCACHE_DIR:-}" ] && [ -w /var/cache/ccache ] && [ -d
> /var/cache/ccache ] ; then
>     export CCACHE_DIR=/var/cache/ccache
>     export CCACHE_UMASK=002
>     unset CCACHE_HARDLINK
> fi

I'm out of ideas.  Just one more try: please post the complete output of running the following three commands in a shell as non-root:

bash --norc
[ -w /var/cache/ccache ] && echo "writable" || echo "NON-writable"
[ -d /var/cache/ccache ] && echo "dir" || "NON-dir"


Oh, one more thing, I wonder what's the "su pierre" is for: do you log in as root and then su to a normal user, or do you log in directly as a non-root user?

Comment 13 Ville Skyttä 2010-11-22 15:47:50 UTC
(In reply to comment #12)
> CCACHE_HARDLINK modifications if: 1) CCACHE_DIR is non-empty

Oops, replace "non-empty" with "empty" in the above.

Comment 14 Donald Cohen 2011-02-28 21:13:36 UTC
I got this problem when trying to run configure to build clisp.
  configure:3954: gcc -m64 --version >&5 
  ccache: failed to create /var/cache/ccache/tmp (Permission denied) 

I also am running fc14.
ccache.x86_64 3.1.3-1.fc14
I believe that I was running configure successfully before, then I ran it as root, and then could no longer run it as non-root.

The clisp people sent me to the ccache people who reply:

ccache doesn't write to /var/ccache/ccache without specific configuration, 
which implies you are not running ccache with default values. And this means 
that if you haven't configured ccache, then the distribution or operating 
system you use probably have installed and enabled ccache for you. 
 
So, my guess is that you should send the bug report to your operating system 
vendor.

Comment 15 Ville Skyttä 2011-02-28 22:12:12 UTC
Ok, running stuff as root will most certainly at least pass the /var/cache/ccache writability check in /etc/profile.d/ccache.sh.  But without specific (non-default) configuration, I still don't know how /var/cache/ccache would afterwards end up writable by the *non-root* user.  And if it's not writable, the configuration in the ccache package really shouldn't end up configuring ccache to do anything with /var/cache/ccache and ccache shouldn't be doing that by itself.  Perhaps the previous ./configure run leaves something behind (config.status?) that points there.  But then again if the error comes from a plain "gcc -m64 --version" command even that doesn't make sense to me (unless something sets $TMPDIR to /var/cache/ccache/tmp).

I'm afraid I will still need exact and complete instructions how to reproduce this (commands, environment, group membership of affected users) on my system before I can do something about it.

Comment 16 Christopher Heiny 2011-03-30 19:18:15 UTC
We're also experiencing this on F14.  Since it's happening while during an automated compiled of a fairly large program, I'll see if a small test case can be written.  In the meantime, here's some of the environment info along with grep output.  Let me know if you need anything else.

[cheiny@venom ~]$ groups cheiny
cheiny : games wheel cvs-uk gitembeddedsw documentation cvshostsw pm toolbox cvssoftware tools cvscpt firmwareIP cvsrandd hostsw firmware cvsdocs
[cheiny@venom ~]$ ls -ld /var/cache/ccache
drwxrws---. 19 root ccache 4096 Mar  8 18:08 /var/cache/ccache
[cheiny@venom ~]$ grep -F CCACHE /etc/bashrc /etc/profile ~/.bash_profile ~/.bashrc /etc/profile.d/*.sh
/etc/profile.d/ccache.sh:# Use ccache by default.  Users who don't want that can set the CCACHE_DISABLE
/etc/profile.d/ccache.sh:# want that even if they have that write permission can set the CCACHE_DIR
/etc/profile.d/ccache.sh:# and unset the CCACHE_UMASK environment variables in their personal profile.
/etc/profile.d/ccache.sh:if [ -z "${CCACHE_DIR:-}" ] && [ -w /var/cache/ccache ] && [ -d /var/cache/ccache ] ; then
/etc/profile.d/ccache.sh:    export CCACHE_DIR=/var/cache/ccache
/etc/profile.d/ccache.sh:    export CCACHE_UMASK=002
/etc/profile.d/ccache.sh:    unset CCACHE_HARDLINK
[cheiny@venom ~]$

Comment 17 Ville Skyttä 2011-03-30 20:07:48 UTC
What's the output of "ls -la /var/cache/ccache" (as root, and non-root for a user that is not in the ccache group)?  Is SELINUX enabled and enforcing?  If yes, does it make a difference if you put it in permissive mode?

Comment 18 Christopher Heiny 2011-03-30 20:23:43 UTC
Here ya go.  User cheiny is not in ccache group.


[cheiny@venom ~]$ ls -la /var/cache/ccache
ls: cannot open directory /var/cache/ccache: Permission denied
[cheiny@venom ~]$ sudo ls -la /var/cache/ccache
total 80
drwxrws---. 19 root ccache 4096 Mar  8 18:08 .
drwxr-xr-x. 27 root root   4096 Jan  3 18:11 ..
drwxrwsr-x   5 root ccache 4096 Mar  8 18:11 0
drwxrwsr-x   6 root ccache 4096 Mar  8 18:11 1
drwxrwsr-x   5 root ccache 4096 Mar  8 18:11 2
drwxrwsr-x   7 root ccache 4096 Mar  8 18:11 3
drwxrwsr-x   3 root ccache 4096 Mar  8 18:11 4
drwxrwsr-x   7 root ccache 4096 Mar  8 18:11 5
drwxrwsr-x   4 root ccache 4096 Mar  8 18:11 6
drwxrwsr-x   4 root ccache 4096 Mar  8 18:11 7
drwxrwsr-x   5 root ccache 4096 Mar  8 18:11 8
drwxrwsr-x   3 root ccache 4096 Mar  8 18:11 9
drwxrwsr-x   3 root ccache 4096 Mar  8 18:11 a
drwxrwsr-x   4 root ccache 4096 Mar  8 18:11 b
drwxrwsr-x   5 root ccache 4096 Mar  8 18:11 c
-rw-rw-r--   1 root ccache  190 Mar  8 18:08 CACHEDIR.TAG
drwxrwsr-x   5 root ccache 4096 Mar  8 18:11 d
drwxrwsr-x   3 root ccache 4096 Mar  8 18:11 e
drwxrwsr-x   3 root ccache 4096 Mar  8 18:11 f
drwxrwsr-x   2 root ccache 4096 Mar  8 18:11 tmp
[cheiny@venom ~]$

Comment 19 Ville Skyttä 2011-03-30 21:50:55 UTC
Created attachment 488911 [details]
Fix candidate /etc/profile.d/ccache.sh

Okay, I've found one reliable reproducer.

1) Log in as root or some other user who has write access to /var/cache/ccache
2) su $nonrootuser # user that does not have write access to /var/cache/ccache
3) Try to build something as $nonrootuser

The problem is that at step 1), /var/cache/ccache is writable so the profile.d script sets up CCACHE_DIR and CCACHE_UMASK, and nothing touches them in step 2), so the settings persist but the user still doesn't have permissions to /var/cache/ccache and thus things fail at step 3).

Please test the attached ccache.sh script (drop it to /etc/profile.d overwriting the existing one) and let me know if it fixes this for you.

Comment 20 Christopher Heiny 2011-03-30 22:10:39 UTC
I'm trying that now.

By the way, I forgot to answer the SELinux question in my last comment: it's disabled.

Comment 21 Christopher Heiny 2011-03-30 22:37:23 UTC
That seems to have fixed it for us.  Both the simple command line compile example from Comment #19 and compiles through CruiseControl work now.  We had to kill and restart the CruiseControl service, but that makes sense given your explanation.

Thanks!

Comment 22 Fedora Update System 2011-04-02 10:12:20 UTC
ccache-3.1.4-3.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/ccache-3.1.4-3.fc14

Comment 23 Fedora Update System 2011-04-02 10:32:54 UTC
ccache-3.1.4-4.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/ccache-3.1.4-4.fc15

Comment 24 Fedora Update System 2011-04-02 10:41:34 UTC
ccache-3.1.4-4.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/ccache-3.1.4-4.el6

Comment 25 Fedora Update System 2011-04-02 11:45:43 UTC
ccache-2.4-19.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/ccache-2.4-19.el5

Comment 26 Fedora Update System 2011-04-02 22:49:01 UTC
Package ccache-3.1.4-3.fc14:
* should fix your issue,
* was pushed to the Fedora 14 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing ccache-3.1.4-3.fc14'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/ccache-3.1.4-3.fc14
then log in and leave karma (feedback).

Comment 27 Fedora Update System 2011-04-15 21:09:30 UTC
ccache-3.1.4-4.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 28 Christopher Heiny 2011-04-16 06:06:20 UTC
Did this get pushed to F14 stable as well?

Comment 29 Ville Skyttä 2011-04-16 08:27:38 UTC
Not yet, the F-14 update is waiting for some positive karma, see comment 26.

Comment 30 Christopher Heiny 2011-04-16 14:43:05 UTC
Update applied, build works, anonymous feedback left.  [I tried signing up for a tester account, but the captcha system was impenetrable]

Comment 31 Fedora Update System 2011-04-16 20:51:45 UTC
ccache-3.1.4-3.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 32 Fedora Update System 2011-04-25 18:53:44 UTC
ccache-3.1.4-4.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 33 Fedora Update System 2011-04-25 18:54:19 UTC
ccache-2.4-19.el5 has been pushed to the Fedora EPEL 5 stable repository.  If problems still persist, please make note of it in this bug report.