dotnet / install-scripts

MIT License
128 stars 68 forks source link

`stat` call fails on macOS when the GNU stat is used instead of BSD stat #396

Closed daleeidd closed 9 months ago

daleeidd commented 9 months ago

Describe the bug

Get the following:

Error! .NET Acquisition Failed: Installation failed: stat: cannot read file system information for '%z': No such file or directory

Please attach log file(s) here if you have any:

DotNetAcquisition-ms-dotnettools.vscode-dotnet-runtime-1694845816479.txt

Output error:

visualstudiotoolsforunity.vstuc requested to download the .NET Runtime. Downloading .NET version(s) 7.0.11 ......... Error! Failed to download .NET 7.0.11: stat: cannot read file system information for '%z': No such file or directory

Error! .NET Acquisition Failed: Installation failed: stat: cannot read file system information for '%z': No such file or directory

Other Info:

Reproduction Steps

Open any C# project.

Further technical details

I have the GNU Tools first in my path so using their version of stat.

Stat:

stat (GNU coreutils) 9.3 Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Written by Michael Meskes.

VSCode

Version: 1.81.1 (Universal) Commit: 6c3e3dba23e8fadc360aed75ce363ba185c49794 Date: 2023-08-09T22:20:33.924Z (1 mo ago) Electron: 22.3.18 ElectronBuildId: 22689846 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Darwin arm64 22.6.0

Extension:

1.7.3

craigds commented 9 months ago

also getting this as of today. I also have the GNU tools first in my path.

More debugging:

# homebrew-installed gnu stat
$ /opt/homebrew/opt/coreutils/libexec/gnubin/stat -f %z
stat: cannot read file system information for '%z': No such file or directory

# macos default bsd stat
$ /usr/bin/stat -f %z
0
baronfel commented 9 months ago

@craigds is the homebrew-delivered stat ahead of the system stat on your PATH?

craigds commented 9 months ago

yes it is. Despite homebrew mentioning that this may cause problems, many people do that and I've never had trouble with it before - normally the GNU tools are just like the BSD tools but with more useful options :)

baronfel commented 9 months ago

This is coming from the install scripts themselves: https://github.com/dotnet/install-scripts/blob/e9163da52c5cf33f9d68627d0bf49cc557d005e3/src/dotnet-install.sh#L570-L572

They may need to become more defensive here if folks are going to install gnu utilities on darwin.

baronfel commented 9 months ago

Folks, we need to see if there's a way to detect if stat is GNU or BSD version - the arguments will change depending on which one we have.

craigds commented 9 months ago

could just hardcode the path to /usr/bin/stat if you always want the BSD one

baronfel commented 9 months ago

Closing as fixed in #397. The scripts served from the website will be updated soon.