Hello!

Yes, only changes in the environment.scm files are required for fixing the 
issue.

Why did you make the patch so complex?

> --- a/guix/scripts/environment.scm
> +++ b/guix/scripts/environment.scm
> @@ -464,8 +464,15 @@ (define (setup-fhs profile)
>    ;; /bin since that already has the sh symlink and the other (optional) FHS
>    ;; bin directories will link to /bin.
>    (let ((gcc-path (string-append profile "/bin/gcc")))
> -    (if (file-exists? gcc-path)
> -        (symlink gcc-path "/bin/cc")))
> +    (when (file-exists? gcc-path)
> +      (catch 'system-error
> +        (lambda ()
> +          (symlink gcc-path "/bin/cc"))
> +        (lambda args
> +          ;; If /bin/cc already exists because it was provided by another
> +          ;; package in PROFILE, such as 'clang-toolchain', leave it.
> +          (unless (= EEXIST (system-error-errno args))
> +            (apply throw args))))))
>
>    ;; Guix's ldconfig doesn't search in FHS default locations, so provide a
>    ;; minimal ld.so.conf.


was not enough ?

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index a219b2ac89..37f11395f9 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -464,7 +464,8 @@ (define (setup-fhs profile)
   ;; /bin since that already has the sh symlink and the other (optional) FHS
   ;; bin directories will link to /bin.
   (let ((gcc-path (string-append profile "/bin/gcc")))
-    (if (file-exists? gcc-path)
+    (if (and (file-exists? gcc-path)
+             (not (file-exists? "/bin/cc")))
         (symlink gcc-path "/bin/cc")))

   ;; Guix's ldconfig doesn't search in FHS default locations, so provide a


________________________________
Da: Ludovic Courtès <l...@gnu.org>
Inviato: mercoledì 23 ottobre 2024 22:26
A: Marco Fortina <marco_fort...@hotmail.it>
Cc: guix-devel@gnu.org <guix-devel@gnu.org>
Oggetto: Re: guix shell: error: symlink: File exists: "/bin/cc"

Hi,

Marco Fortina <marco_fort...@hotmail.it> skribis:

> I have this issue when with guix time-machine shell when using --emulate-fhs 
> option and having gcc-toolset and clang-toolset in my manifest.scm.

I tried, and for those reading along, the problem is:

--8<---------------cut here---------------start------------->8---
$ guix shell -CF gcc-toolchain clang-toolchain
guix shell: error: symlink: File exists: "/bin/cc"
--8<---------------cut here---------------end--------------->8---

> --- a/gnu/packages/llvm.scm
> +++ b/gnu/packages/llvm.scm
> @@ -512,8 +512,10 @@ (define-public (make-clang-toolchain clang libomp)
>                       ;; Create 'cc' and 'c++' so that one can use it as a
>                       ;; drop-in replacement for the default tool chain and
>                       ;; have configure scripts find the compiler.
> -                     (symlink "clang" (string-append out "/bin/cc"))
> -                     (symlink "clang++" (string-append out "/bin/c++"))
> +                     (unless (file-exists? "/bin/cc")
> +                         (symlink "clang" (string-append out "/bin/cc")))
> +                     (unless (file-exists? "/bin/c++")
> +                         (symlink "clang++" (string-append out "/bin/c++")))

This part has no effect (there’s no /bin/cc in the build environment.)

> +++ b/guix/scripts/environment.scm
> @@ -465,7 +465,8 @@ (define* (link-contents dir #:key (exclude '()))
>    ;; bin directories will link to /bin.
>    (let ((gcc-path (string-append profile "/bin/gcc")))
>      (if (file-exists? gcc-path)
> -        (symlink gcc-path "/bin/cc")))
> +        (unless (file-exists? "/bin/cc")
> +            (symlink gcc-path "/bin/cc"))))

Good catch!  I’m proposing a slightly modified variant of this change:

Reply via email to