# minio-ruby [MinIO](https://min.io) is an open-source S3-compatible object store. This gem provides a Ruby interface to MinIO.
## Installation Install the gem and add to the application's Gemfile by executing: ```sh bundle add minio ``` If bundler is not being used to manage dependencies, install the gem by executing: ```sh gem install minio ``` ### Using a local installation of `minio` If you are not able to use the vendored standalone executables (for example, if you're on an unsupported platform), you can use a local installation of the `minio` executable by setting an environment variable named `MINIO_INSTALL_DIR` to the directory containing the executable. For example, if you've installed `minio` so that the executable is found at `/usr/local/bin/minio`, then you should set your environment variable like so: ``` sh MINIO_INSTALL_DIR=/usr/local/bin ``` This also works with relative paths. If you've installed into your app's directory at `./.bin/minio`: ``` sh MINIO_INSTALL_DIR=.bin ``` ## Usage ### Configuration You can configure (if needed, this is optional) the `username` and `password` to secure the MinIO web dashboard. This Ruby interface permits you to use any method of storing secrets that you prefer. For example, you could store these secrets in Rails' encrypted credentials: ```ruby # config/initializers/minio.rb minio_credentials = Rails.application.credentials.minio Litestream.configure do |config| config.username = minio_credentials.username config.password = minio_credentials.password end ``` The default credentials that MinIO uses are `minioadmin` for both the username and password. If you are using the default credentials, you do not need to configure the `username` and `password` in the initializer, but you should absolutely change the default credentials in a production environment. If you want, you can also configure the username and password via environment variables: ```sh export MINIO_ROOT_USER=frodo export MINIO_ROOT_PASSWORD=ikeptmysecrets ``` ### Running the server You can start the MinIO server via the gem's rake task: ```sh bin/rails minio:server # or bundle exec rake minio:server ``` If you need to pass arguments through the rake task to the underlying `minio` command, that can be done with argument forwarding: ```sh bin/rails minio:server -- --directory /mnt/data ``` This example shows the special `--directory` option available on [the `server` command](https://min.io/docs/minio/linux/reference/minio-server/minio-server.html), which allows you to specify the directory where MinIO will store its data. By default, the gem will use the `storage/minio` directory in your Rails app. The MinIO `server` command supports various additional options, which can be passed through the rake task: ```sh --config value specify server configuration via YAML configuration [$MINIO_CONFIG] --address value bind to a specific ADDRESS:PORT, ADDRESS can be an IP or hostname (default: ":9000") [$MINIO_ADDRESS] --console-address value bind to a specific ADDRESS:PORT for embedded Console UI, ADDRESS can be an IP or hostname [$MINIO_CONSOLE_ADDRESS] --ftp value enable and configure an FTP(Secure) server --sftp value enable and configure an SFTP server --certs-dir value, -S value path to certs directory (default: "~/.minio/certs") --quiet disable startup and info messages --anonymous hide sensitive information from logging --json output logs in JSON format --help, -h show help ``` ## Troubleshooting Some common problems experienced by users ... ### `ERROR: Cannot find the minio executable` for supported platform Some users are reporting this error even when running on one of the supported native platforms: * arm64-darwin (darwin-arm64) * arm64-linux (linux-arm64) * x86_64-darwin (darwin-amd64) * x86_64-linux (linux-amd64) * x86_64-windows (windows-amd64) #### Check Bundler PLATFORMS A possible cause of this is that Bundler has not been told to include native gems for your current platform. Please check your `Gemfile.lock` file to see whether your native platform is included in the `PLATFORMS` section. If necessary, run: ``` sh bundle lock --add-platform