Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

cmount: Add optional `brew` tag to throw an error when using mount in the binaries installed via Homebrew - Fixes #4775

Anagh Kumar Baranwal07dee18d6bca
diff --git a/cmd/cmount/mount_brew.go b/cmd/cmount/mount_brew.go
new file mode 100644
index 000000000..df553487a
--- /dev/null
+++ b/cmd/cmount/mount_brew.go
@@ -0,0 +1,32 @@
+// Build for macos with the brew tag to handle the absence
+// of fuse and print an appropriate error message
+
+// +build brew
+// +build darwin
+
+package cmount
+
+import (
+ "github.com/pkg/errors"
+ "github.com/rclone/rclone/cmd/mountlib"
+ "github.com/rclone/rclone/vfs"
+)
+
+func init() {
+ name := "mount"
+ cmd := mountlib.NewMountCommand(name, false, mount)
+ cmd.Aliases = append(cmd.Aliases, "cmount")
+ mountlib.AddRc("cmount", mount)
+}
+
+// mount the file system
+//
+// The mount point will be ready when this returns.
+//
+// returns an error, and an error channel for the serve process to
+// report an error when fusermount is called.
+func mount(_ *vfs.VFS, _ string, _ *mountlib.Options) (<-chan error, func() error, error) {
+ return nil, nil, errors.New("mount is not supported on MacOS when installed via Homebrew. " +
+ "Please install the binaries available at https://rclone." +
+ "org/downloads/ instead if you want to use the mount command")
+}
diff --git a/cmd/cmount/mount_unsupported.go b/cmd/cmount/mount_unsupported.go
index 57d820e22..dbd73618f 100644
--- a/cmd/cmount/mount_unsupported.go
+++ b/cmd/cmount/mount_unsupported.go
@@ -1,6 +1,6 @@
// Build for cmount for unsupported platforms to stop go complaining
// about "no buildable Go source files "
-// +build !linux,!darwin,!freebsd,!windows !cgo !cmount
+// +build !linux,!darwin,!freebsd,!windows !brew !cgo !cmount
package cmount
diff --git a/cmd/mount/mount_unsupported.go b/cmd/mount/mount_unsupported.go
index bff6cd670..e4284148d 100644
--- a/cmd/mount/mount_unsupported.go
+++ b/cmd/mount/mount_unsupported.go
@@ -1,7 +1,7 @@
// Build for mount for unsupported platforms to stop go complaining
// about "no buildable Go source files "
-// Invert the build constraint: linux,go1.13 darwin,go1.13 freebsd,go1.13
+// Invert the build constraint: linux,go1.13 freebsd,go1.13
//
// !((linux&&go1.13) || (freebsd&&go1.13))
// == !(linux&&go1.13) && !(freebsd&&go1.13))