Answers.Body: <p>The error you're seeing is probably caused by this:</p>
  <p><code>./.env.sh: line 128: $'\r': command not found</code></p>
  <p>This error indicates that your OS doesn't recognise the line endings in this file. This means the file isn't parsed correctly, which in turn means your environment variables are wrong (for example, the GLOBAL_DB_DRIVER might include a control character at the end, which would explain your current problem). The most common cause is that you're developing on Windows or WSL which uses different line endings from Unix/Mac systems. Here are some resources to fix this:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/11616835/r-command-not-found-bashrc-bash-profile">For bash / Linux</a></li>
  <li><a href="https://askubuntu.com/questions/966488/how-do-i-fix-r-command-not-found-errors-running-bash-scripts-in-wsl">For Windows / WSL</a></li>
  </ul>
  <p>Also, you might want to look into how this error occured in the first place. If you cloned the repository using git, it can automatically handle line ending conversions. Make sure to <a href="https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings" rel="nofollow noreferrer">check the settings according to this guide</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-21T10:17:48.877Z
Answers.Text: Thanks. Let me have a try.
Answers.UserDisplayName: Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-21T09:14:50.623Z
Answers.LastActivityDate: 2021-07-21T09:14:50.623Z
Answers.UserDisplayName: MoritzLost
Body: <p>I keep getting the error <strong>Environment variable GLOBAL_DB_DRIVER was neither 'mysql' nor 'pgsql'. Aborting.</strong> when trying to pull the database from the production server to staging using <a href="https://github.com/nystudio107/craft-scripts" rel="nofollow noreferrer">Craft Script</a>.</p>
  <p><a href="https://i.sstatic.net/s6frw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/s6frw.png" alt="enter image description here" /></a></p>
  <p>I have set the <strong>GLOBAL_DB_DRIVER=&quot;mysql&quot;</strong>, but the error is still there.</p>
  <p>Below is my .env.sh settings,</p>
  <pre><code># The path of the `craft` folder, relative to the root path; paths should always have a trailing /
  GLOBAL_CRAFT_PATH=&quot;./&quot;
  
  # The maximum age of db backups in days; backups older than this will be automatically removed
  GLOBAL_DB_BACKUPS_MAX_AGE=90
  
  # The database driver for this Craft install ('mysql' or 'pgsql')
  GLOBAL_DB_DRIVER=&quot;mysql&quot;
  
  # -- LOCAL settings --
  
  # Local path constants; paths should always have a trailing /
  LOCAL_ROOT_PATH=&quot;/var/www/html/test/&quot;
  LOCAL_ASSETS_PATH=${LOCAL_ROOT_PATH}&quot;web/assets/images/&quot;
  
  # Local user &amp; group that should own the Craft CMS install
  LOCAL_CHOWN_USER=&quot;nobody&quot;
  LOCAL_CHOWN_GROUP=&quot;nogroup&quot;
  
  # Local directories relative to LOCAL_ROOT_PATH that should be writeable by the $CHOWN_GROUP
  LOCAL_WRITEABLE_DIRS=(
                  &quot;${GLOBAL_CRAFT_PATH}storage&quot;
                  &quot;web/cpresources&quot;
                  &quot;web/assets&quot;
                  )
  
  # Absolute paths to directories to back up, in addition to `LOCAL_ASSETS_DIRS` and `LOCAL_CRAFT_FILE_DIRS`
  LOCAL_DIRS_TO_BACKUP=(
                    &quot;/var/www/html/test/backups&quot;
                  )
  
  # Local database constants; default port for mysql is 3306, default port for postgres is 5432
  LOCAL_DB_NAME=&quot;test&quot;
  LOCAL_DB_PASSWORD=&quot;*****&quot;
  LOCAL_DB_USER=&quot;user&quot;
  LOCAL_DB_HOST=&quot;host&quot;
  LOCAL_DB_PORT=&quot;3306&quot;
  LOCAL_DB_SCHEMA=&quot;public&quot;
  
  # If you are using mysql 5.6.10 or later and you have `login-path` setup as per:
  # https://opensourcedbms.com/dbms/passwordless-authentication-using-mysql_config_editor-with-mysql-5-6/
  # you can use it instead of the above LOCAL_DB_* constants; otherwise leave this blank
  LOCAL_DB_LOGIN_PATH=&quot;&quot;
  
  # The `mysql` and `mysqldump` commands to run locally
  LOCAL_MYSQL_CMD=&quot;mysql&quot;
  LOCAL_MYSQLDUMP_CMD=&quot;mysqldump&quot;
  
  # Local backups path; paths should always have a trailing /
  LOCAL_BACKUPS_PATH=&quot;/var/www/html/test/backups/&quot;
  
  # -- REMOTE settings --
  
  # Remote ssh credentials, user@domain.com and Remote SSH Port
  REMOTE_SSH_LOGIN=&quot;user@ip.com&quot;
  REMOTE_SSH_PORT=&quot;7722&quot;
  
  # Should we connect to the remote database server via ssh?
  REMOTE_DB_USING_SSH=&quot;yes&quot;
  
  # Remote path constants; paths should always have a trailing /
  REMOTE_ROOT_PATH=&quot;/var/www/html/test/&quot;
  REMOTE_ASSETS_PATH=${REMOTE_ROOT_PATH}&quot;web/assets/images&quot;
  
  # Remote database constants; default port for mysql is 3306, default port for postgres is 5432
  REMOTE_DB_NAME=&quot;test&quot;
  REMOTE_DB_PASSWORD=&quot;*****&quot;
  REMOTE_DB_USER=&quot;user&quot;
  REMOTE_DB_HOST=&quot;prod-host&quot;
  REMOTE_DB_PORT=&quot;3306&quot;
  REMOTE_DB_SCHEMA=&quot;public&quot;
  
  # If you are using mysql 5.6.10 or later and you have `login-path` setup as per:
  # https://opensourcedbms.com/dbms/passwordless-authentication-using-mysql_config_editor-with-mysql-5-6/
  # you can use it instead of the above REMOTE_DB_* constants; otherwise leave this blank
  REMOTE_DB_LOGIN_PATH=&quot;&quot;
  
  # The `mysql` and `mysqldump` commands to run remotely
  REMOTE_MYSQL_CMD=&quot;mysql&quot;
  REMOTE_MYSQLDUMP_CMD=&quot;mysqldump&quot;
  
  # Remote backups path; paths should always have a trailing /
  REMOTE_BACKUPS_PATH=&quot;/var/www/html/test/backups/&quot;
  
  # Remote Amazon S3 bucket name
  REMOTE_S3_BUCKET=&quot;test-storage&quot;
  </code></pre>
  <p>Here is my system, both staging, and production using the same</p>
  <pre><code>PHP version 7.4.18
  OS version  Linux 5.4.0-1047-aws
  Database driver &amp; version   MySQL 5.5.5
  Craft edition &amp; version Craft Pro 3.6.13
  </code></pre>
  
Tags: <craft3><database><mysql><multi-environment><environmentvariables>
Title: Craft Script: Environment variable GLOBAL_DB_DRIVER was neither 'mysql' nor 'pgsql'
ThreadText: # Craft Script: Environment variable GLOBAL_DB_DRIVER was neither 'mysql' nor 'pgsql'
  
  (Asked by: username_0 on 2021-07-21)
  
  I keep getting the error **Environment variable GLOBAL\_DB\_DRIVER was neither 'mysql' nor 'pgsql'. Aborting.** when trying to pull the database from the production server to staging using [Craft Script](https://github.com/nystudio107/craft-scripts).
  
  [![enter image description here](https://i.sstatic.net/s6frw.png)](https://i.sstatic.net/s6frw.png)
  
  I have set the **GLOBAL\_DB\_DRIVER="mysql"**, but the error is still there.
  
  Below is my .env.sh settings,
  
  ```
  # The path of the `craft` folder, relative to the root path; paths should always have a trailing /
  GLOBAL_CRAFT_PATH="./"
  
  # The maximum age of db backups in days; backups older than this will be automatically removed
  GLOBAL_DB_BACKUPS_MAX_AGE=90
  
  # The database driver for this Craft install ('mysql' or 'pgsql')
  GLOBAL_DB_DRIVER="mysql"
  
  # -- LOCAL settings --
  
  # Local path constants; paths should always have a trailing /
  LOCAL_ROOT_PATH="/var/www/html/test/"
  LOCAL_ASSETS_PATH=${LOCAL_ROOT_PATH}"web/assets/images/"
  
  # Local user & group that should own the Craft CMS install
  LOCAL_CHOWN_USER="nobody"
  LOCAL_CHOWN_GROUP="nogroup"
  
  # Local directories relative to LOCAL_ROOT_PATH that should be writeable by the $CHOWN_GROUP
  LOCAL_WRITEABLE_DIRS=(
                  "${GLOBAL_CRAFT_PATH}storage"
                  "web/cpresources"
                  "web/assets"
                  )
  
  # Absolute paths to directories to back up, in addition to `LOCAL_ASSETS_DIRS` and `LOCAL_CRAFT_FILE_DIRS`
  LOCAL_DIRS_TO_BACKUP=(
                    "/var/www/html/test/backups"
                  )
  
  # Local database constants; default port for mysql is 3306, default port for postgres is 5432
  LOCAL_DB_NAME="test"
  LOCAL_DB_PASSWORD="*****"
  LOCAL_DB_USER="user"
  LOCAL_DB_HOST="host"
  LOCAL_DB_PORT="3306"
  LOCAL_DB_SCHEMA="public"
  
  # If you are using mysql 5.6.10 or later and you have `login-path` setup as per:
  # https://opensourcedbms.com/dbms/passwordless-authentication-using-mysql_config_editor-with-mysql-5-6/
  # you can use it instead of the above LOCAL_DB_* constants; otherwise leave this blank
  LOCAL_DB_LOGIN_PATH=""
  
  # The `mysql` and `mysqldump` commands to run locally
  LOCAL_MYSQL_CMD="mysql"
  LOCAL_MYSQLDUMP_CMD="mysqldump"
  
  # Local backups path; paths should always have a trailing /
  LOCAL_BACKUPS_PATH="/var/www/html/test/backups/"
  
  # -- REMOTE settings --
  
  # Remote ssh credentials, user@domain.com and Remote SSH Port
  REMOTE_SSH_LOGIN="user@ip.com"
  REMOTE_SSH_PORT="7722"
  
  # Should we connect to the remote database server via ssh?
  REMOTE_DB_USING_SSH="yes"
  
  # Remote path constants; paths should always have a trailing /
  REMOTE_ROOT_PATH="/var/www/html/test/"
  REMOTE_ASSETS_PATH=${REMOTE_ROOT_PATH}"web/assets/images"
  
  # Remote database constants; default port for mysql is 3306, default port for postgres is 5432
  REMOTE_DB_NAME="test"
  REMOTE_DB_PASSWORD="*****"
  REMOTE_DB_USER="user"
  REMOTE_DB_HOST="prod-host"
  REMOTE_DB_PORT="3306"
  REMOTE_DB_SCHEMA="public"
  
  # If you are using mysql 5.6.10 or later and you have `login-path` setup as per:
  # https://opensourcedbms.com/dbms/passwordless-authentication-using-mysql_config_editor-with-mysql-5-6/
  # you can use it instead of the above REMOTE_DB_* constants; otherwise leave this blank
  REMOTE_DB_LOGIN_PATH=""
  
  # The `mysql` and `mysqldump` commands to run remotely
  REMOTE_MYSQL_CMD="mysql"
  REMOTE_MYSQLDUMP_CMD="mysqldump"
  
  # Remote backups path; paths should always have a trailing /
  REMOTE_BACKUPS_PATH="/var/www/html/test/backups/"
  
  # Remote Amazon S3 bucket name
  REMOTE_S3_BUCKET="test-storage"
  
  ```
  
  Here is my system, both staging, and production using the same
  
  ```
  PHP version 7.4.18
  OS version  Linux 5.4.0-1047-aws
  Database driver & version   MySQL 5.5.5
  Craft edition & version Craft Pro 3.6.13
  
  ```
  
  **Tags:** craft3, database, mysql, multi-environment, environmentvariables
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-21. Score: 1
  
  The error you're seeing is probably caused by this:
  
  `./.env.sh: line 128: $'\r': command not found`
  
  This error indicates that your OS doesn't recognise the line endings in this file. This means the file isn't parsed correctly, which in turn means your environment variables are wrong (for example, the GLOBAL\_DB\_DRIVER might include a control character at the end, which would explain your current problem). The most common cause is that you're developing on Windows or WSL which uses different line endings from Unix/Mac systems. Here are some resources to fix this:
  
  * [For bash / Linux](https://stackoverflow.com/questions/11616835/r-command-not-found-bashrc-bash-profile)
  * [For Windows / WSL](https://askubuntu.com/questions/966488/how-do-i-fix-r-command-not-found-errors-running-bash-scripts-in-wsl)
  
  Also, you might want to look into how this error occured in the first place. If you cloned the repository using git, it can automatically handle line ending conversions. Make sure to [check the settings according to this guide](https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings).
  
  > **Comments:**
  > **username_0**: Thanks. Let me have a try.  
  
  ---
  
  