-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Ignore error of symlink #83605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore error of symlink #83605
Conversation
a2ad370
to
c0b4fd9
Compare
This code was last changed by @infinisil in 8d4509e. @infinisil Is it possible that there was a bug introduced in 8d4509e for when there are multiple Is the fix that @junjihashimoto is proposing here correct? |
If Is it correct that there should be such conflicts in the first place? |
@nh2 For example,
|
I think, from reading that commit, that the code should try to create the same set of links before and after the commit. (Outside of cases of the bug that the commit was fixing.) If so, then this has probably behaved the same way since this
If that's what's going on, then perhaps we can have the script check that: if the link already exists, it should point to the same path we were going to create it with. Then if it doesn't, we create it just like we do now. |
listDynamicLinks () { | ||
for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do | ||
for lib in "$d/"*.{dylib,so} ; do | ||
if [ -f "$lib" ] ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we use linux, lib includes not only actual filenames but also *.dylib
.
This [ -f "$lib" ]
is used to delete *.dylib
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, I see -- because there are no files matching somedir/*.dylib
?
Hmm, but this bit of code has always been this way -- in fact it's only since February in 019e86f that it mentions .so
at all, and before that it was only .dylib
:
for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do
- for lib in "$d/"*.dylib; do
+ for lib in "$d/"*.{dylib,so}; do
ln -s "$lib" "$dynamicLinksDir"
This change should be a separate commit, in any event. Probably deserves some separate debugging and discussion, too. It sounds like an independent issue from the collision issue.
@gnprice |
for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do | ||
for lib in "$d/"*.{dylib,so}; do | ||
ln -s "$lib" "$dynamicLinksDir" | ||
listDynamicLinks () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment on this function explaining what it is doing (and why it is needed)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one comment above.
Also, please rebase this on the haskell-updates
branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @junjihashimoto for the revisions! Comments below.
listDynamicLinks () { | ||
for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do | ||
for lib in "$d/"*.{dylib,so} ; do | ||
if [ -f "$lib" ] ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, I see -- because there are no files matching somedir/*.dylib
?
Hmm, but this bit of code has always been this way -- in fact it's only since February in 019e86f that it mentions .so
at all, and before that it was only .dylib
:
for d in $(grep '^dynamic-library-dirs:' "$packageConfDir"/* | cut -d' ' -f2- | tr ' ' '\n' | sort -u); do
- for lib in "$d/"*.dylib; do
+ for lib in "$d/"*.{dylib,so}; do
ln -s "$lib" "$dynamicLinksDir"
This change should be a separate commit, in any event. Probably deserves some separate debugging and discussion, too. It sounds like an independent issue from the collision issue.
for lib in "$d/"*.{dylib,so} ; do | ||
if [ -f "$lib" ] ; then | ||
echo "$lib" | ||
fi | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of something like:
for lib in "$d/"*.{dylib,so} ; do
local linkPath="$dynamicLinksDir/$(basename "$lib")"
if [ -e "$linkPath" ]; then
# link already exists! but maybe that's OK
if [ ! -l "$linkPath" ] || [ "$(readlink "$linkPath")" != "$lib" ]; then
echo >&2 "error: failed to create symbolic link $linkPath: file exists"
exit 1
fi
else
ln -s "$lib" "$linkPath"
fi
done
I.e., if the place where we want to create the link already exists, then check that it is already a link and already points exactly where we'd like to point it.
for lib in $(listDynamicLinks | sort | uniq) ; do | ||
ln -s "$lib" "$dynamicLinksDir" | ||
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit: I think the ln -s
step can best be pushed inside the function. Then this is just a call, like:
makeDynamicLinks
That just keeps the ln -s
a little closer to the logic that drives it.
(Also, as is I think the sort | uniq
shouldn't be needed, because of the sort -u
that's inside the function.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your reviewing.
I will update it and check the test.
The hackage-packages.nix change was generated by hackage2nix v2.15.1 from Hackage revision commercialhaskell/all-cabal-hashes@ad4a70d.
haskellPackages.idris: Fix build (new GHC 8.8 & old megaparsec 7)
Test suite requires database. Disabling tests as is done for mysql backend.
haskellPackages.persistent-postgresql: don't check
This update was generated by hackage2nix v2.15.1 from Hackage revision commercialhaskell/all-cabal-hashes@0123dd8.
This update was generated by hackage2nix v2.15.1 from Hackage revision commercialhaskell/all-cabal-hashes@8c7fc4a.
This update was generated by hackage2nix v2.15.1 from Hackage revision commercialhaskell/all-cabal-hashes@e07c49f.
This is the first step towards unbreaking the tensorflow packages.
ld.gold doesn't play well with musl as is documented in NixOS#49071 and https://sourceware.org/bugzilla/show_bug.cgi?id=23856
This update was generated by hackage2nix v2.15.1 from Hackage revision commercialhaskell/all-cabal-hashes@b4a552b.
…skell-1 Unbreak tensorflow haskell 1
ghc: do not use ld.gold with musl libc NixOS#84670
haskellPackages.hsexif: unbroken (fix
This update was generated by hackage2nix v2.15.1 from Hackage revision commercialhaskell/all-cabal-hashes@9501e1f.
ghc: mention why ld.gold is disabled for musl libc
0e3de22
to
e3fb3b0
Compare
I rebase this on the |
You'll need to change the base branch on this PR to be |
@junjihashimoto By the way, you do not need to make a new PR to change branches, you can click the |
For ticket subscribers, new PR is in #84985 |
Thank you for letting me know. |
Motivation for this change
When setupCompilerEnvironmentPhase, symlink fails for existing link.
I want to ignore the error.
This pr changes
ln -s
toln -sf
.OS : macos
https://github.com/hasktorch/hasktorch/runs/541719980
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)