* guix shell: error: symlink: File exists: "/bin/cc"
@ 2024-10-13 16:45 Marco Fortina
2024-10-13 23:11 ` bug#73799: " Marco Fortina
2024-10-23 20:26 ` Ludovic Courtès
0 siblings, 2 replies; 8+ messages in thread
From: Marco Fortina @ 2024-10-13 16:45 UTC (permalink / raw)
To: guix-devel@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]
Hello there.
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 this this could be solved with this patch:
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 9f851a478e..7a276569e9 100644
--- 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++")))
(union-build (assoc-ref %outputs "debug")
(list (assoc-ref %build-inputs
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index a219b2ac89..72e56367a8 100644
--- a/guix/scripts/environment.scm
+++ 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"))))
;; Guix's ldconfig doesn't search in FHS default locations, so provide a
;; minimal ld.so.conf.
This patch will create the symlinks only if destination files is not already present.
Thanks
[-- Attachment #2: Type: text/html, Size: 7271 bytes --]
^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#73799: guix shell: error: symlink: File exists: "/bin/cc"
2024-10-13 16:45 guix shell: error: symlink: File exists: "/bin/cc" Marco Fortina
@ 2024-10-13 23:11 ` Marco Fortina
2024-10-14 19:13 ` Rutherther via Bug reports for GNU Guix
2024-10-23 20:26 ` Ludovic Courtès
1 sibling, 1 reply; 8+ messages in thread
From: Marco Fortina @ 2024-10-13 23:11 UTC (permalink / raw)
To: 73799
[-- Attachment #1: Type: text/plain, Size: 1931 bytes --]
Hello there.
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 this this could be solved with this patch:
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 9f851a478e..7a276569e9 100644
--- 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++")))
(union-build (assoc-ref %outputs "debug")
(list (assoc-ref %build-inputs
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index a219b2ac89..72e56367a8 100644
--- a/guix/scripts/environment.scm
+++ 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"))))
;; Guix's ldconfig doesn't search in FHS default locations, so provide a
;; minimal ld.so.conf.
This patch will create the symlinks only if destination files is not already present.
Thanks
[-- Attachment #2: Type: text/html, Size: 7679 bytes --]
^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#73799: guix shell: error: symlink: File exists: "/bin/cc"
2024-10-13 23:11 ` bug#73799: " Marco Fortina
@ 2024-10-14 19:13 ` Rutherther via Bug reports for GNU Guix
0 siblings, 0 replies; 8+ messages in thread
From: Rutherther via Bug reports for GNU Guix @ 2024-10-14 19:13 UTC (permalink / raw)
To: 73799; +Cc: Marco Fortina
Hey Marco,
that llvm.scm change is actually irrelevant to the problem. There
will never be cc in the llvm package itself before the condition.
It occurs prior to the profile merging.
There is no fhs in that case
so checking for /bin/cc does not make sense, moreover
it could pose a problem if one built without a sandbox
on a foreign distro. Then the package output could differ
because /bin/gcc or /bin/c++ exist.
As for the change in environment.scm, that is indeed
what causes the issue.
Since there is an if already, maybe it would make sense to
not introduce another condition statement, but to extend
the existing if?
Regards,
Rutherther
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: guix shell: error: symlink: File exists: "/bin/cc"
2024-10-13 16:45 guix shell: error: symlink: File exists: "/bin/cc" Marco Fortina
2024-10-13 23:11 ` bug#73799: " Marco Fortina
@ 2024-10-23 20:26 ` Ludovic Courtès
2024-10-23 20:26 ` Rutherther
2024-10-24 8:02 ` R: " Marco Fortina
1 sibling, 2 replies; 8+ messages in thread
From: Ludovic Courtès @ 2024-10-23 20:26 UTC (permalink / raw)
To: Marco Fortina; +Cc: guix-devel@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1833 bytes --]
Hi,
Marco Fortina <marco_fortina@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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 965 bytes --]
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index a219b2ac89..fc7fa84be7 100644
--- 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.
[-- Attachment #3: Type: text/plain, Size: 100 bytes --]
I’ll push it soon if there are no objections.
Thanks for reporting the problem!
Ludo’.
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: guix shell: error: symlink: File exists: "/bin/cc"
2024-10-23 20:26 ` Ludovic Courtès
@ 2024-10-23 20:26 ` Rutherther
2024-10-24 8:02 ` R: " Marco Fortina
1 sibling, 0 replies; 8+ messages in thread
From: Rutherther @ 2024-10-23 20:26 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel@gnu.org, Marco Fortina
Hello, note that this is linked to issue #73799,
since the original patch was submitted both to
guix-devel and guix-patches.
Regards,
Rutherther
^ permalink raw reply [flat|nested] 8+ messages in thread
* R: guix shell: error: symlink: File exists: "/bin/cc"
2024-10-23 20:26 ` Ludovic Courtès
2024-10-23 20:26 ` Rutherther
@ 2024-10-24 8:02 ` Marco Fortina
2024-10-24 13:28 ` Greg Hogan
2024-10-26 14:20 ` R: " Ludovic Courtès
1 sibling, 2 replies; 8+ messages in thread
From: Marco Fortina @ 2024-10-24 8:02 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel@gnu.org
[-- Attachment #1: Type: text/plain, Size: 3827 bytes --]
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 <ludo@gnu.org>
Inviato: mercoledì 23 ottobre 2024 22:26
A: Marco Fortina <marco_fortina@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_fortina@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:
[-- Attachment #2: Type: text/html, Size: 10022 bytes --]
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: guix shell: error: symlink: File exists: "/bin/cc"
2024-10-24 8:02 ` R: " Marco Fortina
@ 2024-10-24 13:28 ` Greg Hogan
2024-10-26 14:20 ` R: " Ludovic Courtès
1 sibling, 0 replies; 8+ messages in thread
From: Greg Hogan @ 2024-10-24 13:28 UTC (permalink / raw)
To: Marco Fortina; +Cc: guix-devel@gnu.org
On Thu, Oct 24, 2024 at 4:03 AM Marco Fortina <marco_fortina@hotmail.it> wrote:
>
> Hello!
>
> Yes, only changes in the environment.scm files are required for fixing the issue.
>
> Why did you make the patch so complex?
There are many potential errors in addition to EEXIST:
https://man7.org/linux/man-pages/man2/symlink.2.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: R: guix shell: error: symlink: File exists: "/bin/cc"
2024-10-24 8:02 ` R: " Marco Fortina
2024-10-24 13:28 ` Greg Hogan
@ 2024-10-26 14:20 ` Ludovic Courtès
1 sibling, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2024-10-26 14:20 UTC (permalink / raw)
To: Marco Fortina; +Cc: guix-devel@gnu.org
Hi Marco,
Marco Fortina <marco_fortina@hotmail.it> skribis:
> Yes, only changes in the environment.scm files are required for fixing the issue.
>
> Why did you make the patch so complex?
[...]
>> + (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))))))
It’s more verbose, but it’s more accurate: we want to try to symlink and
let go if we get EEXIST, but not if we get another problem. (That also
avoids a time-of-check-to-time-of-use race condition, though it does not
really matter in this context.)
HTH,
Ludo’.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-10-26 14:21 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-13 16:45 guix shell: error: symlink: File exists: "/bin/cc" Marco Fortina
2024-10-13 23:11 ` bug#73799: " Marco Fortina
2024-10-14 19:13 ` Rutherther via Bug reports for GNU Guix
2024-10-23 20:26 ` Ludovic Courtès
2024-10-23 20:26 ` Rutherther
2024-10-24 8:02 ` R: " Marco Fortina
2024-10-24 13:28 ` Greg Hogan
2024-10-26 14:20 ` R: " Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.