dutchcoders/transfer.sh · error

basedir not set.

Error message

basedir not set.

What it means

Thrown by the transfer.sh CLI in the gdrive branch of provider selection when --provider gdrive is used and both gdrive flags are present but --basedir is empty. The basedir is the root directory under which uploaded files are organized/stored locally; gdrive storage requires it, so the CLI fails validation before constructing the storage.

Source

Thrown at cmd/cmd.go:506

				return errors.New("access-key not set.")
			} else if secretKey := c.String("aws-secret-key"); secretKey == "" {
				return errors.New("secret-key not set.")
			} else if bucket := c.String("bucket"); bucket == "" {
				return errors.New("bucket not set.")
			} else if store, err := storage.NewS3Storage(c.Context, accessKey, secretKey, bucket, purgeDays, c.String("s3-region"), c.String("s3-endpoint"), c.Bool("s3-no-multipart"), c.Bool("s3-path-style"), logger); err != nil {
				return err
			} else {
				options = append(options, server.UseStorage(store))
			}
		case "gdrive":
			chunkSize := c.Int("gdrive-chunk-size") * 1024 * 1024

			if clientJSONFilepath := c.String("gdrive-client-json-filepath"); clientJSONFilepath == "" {
				return errors.New("gdrive-client-json-filepath not set.")
			} else if localConfigPath := c.String("gdrive-local-config-path"); localConfigPath == "" {
				return errors.New("gdrive-local-config-path not set.")
			} else if basedir := c.String("basedir"); basedir == "" {
				return errors.New("basedir not set.")
			} else if store, err := storage.NewGDriveStorage(c.Context, clientJSONFilepath, localConfigPath, basedir, chunkSize, logger); err != nil {
				return err
			} else {
				options = append(options, server.UseStorage(store))
			}
		case "storj":
			if access := c.String("storj-access"); access == "" {
				return errors.New("storj-access not set.")
			} else if bucket := c.String("storj-bucket"); bucket == "" {
				return errors.New("storj-bucket not set.")
			} else if store, err := storage.NewStorjStorage(c.Context, access, bucket, purgeDays, logger); err != nil {
				return err
			} else {
				options = append(options, server.UseStorage(store))
			}
		case "local":
			if v := c.String("basedir"); v == "" {
				return errors.New("basedir not set.")

View on GitHub (pinned to c37bfd9579)

Solutions

  1. Add --basedir /path/to/storage to the command line when using --provider gdrive
  2. Ensure the path exists and is writable by the process
  3. If the same flags file serves multiple providers, verify the provider value actually matches the branch you configured flags for
  4. After this check NewGDriveStorage runs — make sure the client JSON and token paths are valid to avoid the next error

Example fix

// before
transfer.sh --provider gdrive --gdrive-client-json-filepath /secrets/c.json --gdrive-local-config-path /data/token.json
// after
transfer.sh --provider gdrive --gdrive-client-json-filepath /secrets/c.json --gdrive-local-config-path /data/token.json --basedir /data/uploads
Defensive patterns

Strategy: validation

Validate before calling

: "${BASEDIR:?basedir required for gdrive provider}"
mkdir -p "$BASEDIR"
args+=(--basedir "$BASEDIR")

Try / catch

if err := cmd.Root.Execute(); err != nil {
  if strings.Contains(err.Error(), "basedir not set") {
    log.Fatalf("provider requires --basedir")
  }
  os.Exit(1)
}

Prevention

When it happens

Trigger: Running with --provider gdrive, --gdrive-client-json-filepath and --gdrive-local-config-path set, but no --basedir (or an empty interpolation). Note the same message also appears for --provider local at a different code path (cmd.go:524).

Common situations: Configurations ported from an S3 deployment (which has no basedir requirement) to gdrive; a basedir env var like TRANSFER_BASEDIR unset in the container; multiple provider branches sharing a config template where basedir was only defined for the local provider.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dutchcoders/transfer.sh@c37bfd9579 (2026-09-05). Data as JSON: /api/errors/0c1647b1a9deff39. Report an issue: GitHub.