0

I just upgraded to El Capitan and found out that the C compiler (Clang) is not working under the command line. I wrote a "hello word" test, tried to compile and I get the following error:

$ cc test.c -o test

$ error: unable to open output file

  '/var/folders/Ge/GeRStfi8Ek8jojLcqf1vsE+++TI/-Tmp-/test-ad7039.o': 'No

  such file or directory'

1 error generated.

... do I have a permission problems somewhere? Thanks!

Caco
  • 1
  • 1
  • 1
  • Did you check the file? – stark May 23 '16 at 11:26
  • 2
    Try re-installing Xcode and the commandline tools ... http://stackoverflow.com/a/32338889/2836621 – Mark Setchell May 23 '16 at 11:26
  • it doesn't compile anything... and also I reinstalled Xcode with no use :( – Caco May 23 '16 at 11:32
  • What does `which cc` and `cc --version` say? – molbdnilo May 23 '16 at 11:46
  • $ which cc gives /usr/bin/cc (which is simbolically linked with clang) and cc--version produces Apple LLVM version 7.3.0 (clang-703.0.31) Target: x86_64-apple-darwin15.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin – Caco May 23 '16 at 11:48
  • Check your permissions (try running with sudo). It's probably a permissions issue if the compiler can't open the output file. – Matthew Daiter May 23 '16 at 11:48
  • will try with a workaround as El Capitan doesn't allow you manually to fix your permissions :( – Caco May 23 '16 at 11:52
  • Wait, it totally does. Have you tried using chmod or chown? – Matthew Daiter May 23 '16 at 11:52
  • It is indeed a permission problem as I can actually compile the file using sudo. I tried repairing manually the permissions using the command line with: sudo /usr/libexec/repair_packages --verify --standard-pkgs / and sudo /usr/libexec/repair_packages --repair --standard-pkgs --volume / but still I cannot compile without the sudo command – Caco May 23 '16 at 13:37

1 Answers1

0

Either you're running into permissions problems (the compiler is unable to create a folder inside var, and so there's no such file or directory) or the ability to open the file in the current directory of compilation isn't allowed. Check your permissions on

  • The file
  • The directory

Run the command under sudo. If that fixes your problem, then use ls -la to check your permissions in the current folder. Then, use chown or chmod to change the permissions on the file/folder.

Example:

chown owner-user test.c

Now, you may actually not actually have access to the /var/ folder. If so, then the temp folder cc is creating is the problem. So then, you'd sudo call cc. For a more permanent fix, you can chown the binary or directory clang is in.

  • the sudo works, so I can live with it now :0 thanks for that... regarding permissions I am stuck here as the System doesn't allow me to change them! see this: https://support.apple.com/en-gb/HT201560 – Caco May 23 '16 at 13:17
  • 1
    ok... I found out how to do it under the command line here http://lifehacker.com/verify-and-repair-permissions-from-the-command-line-in-1741718667 will see how does it go – Caco May 23 '16 at 13:29
  • 1
    It is indeed a permission problem as I can actually compile the file using sudo; I tried repairing manually the permissions using the command line with: sudo /usr/libexec/repair_packages --verify --standard-pkgs / and sudo /usr/libexec/repair_packages --repair --standard-pkgs --volume / but still I cannot compile without the sudo command – Caco May 23 '16 at 13:37