ERROR: In file ./.env: environment variable name'THOR_SILENCE_DEPRECATION' may not contain whitespace.

As the title says, but this time

.env


ERROR: In file ./.env: environment variable name 'THOR_SILENCE_DEPRECATION ' may not contain whitespace.

I would like to share the solution in my environment as to what to do when the error occurs.

I'm a beginner about a month after I started learning programming with Ruby on Rails, so I think there are some points that I can't reach or lack of explanation. We would appreciate it if you could point out any points you noticed.

environment

・ Ruby 2.6.5 ・ Rails 5.2.3 · MySQL 5.7 ・ Docker ・ Docker-compose version: '3'

First of all, from the solved method

I would like to start with the solution.

Under my environment, the root directory (Same hierarchy as files such as Dockerfile and Gemfile) The cause was that the description of the .env file that exists in was incorrect.

.env


#This is the description that gives an error
THOR_SILENCE_DEPRECATION = true


#The error can be resolved by modifying the description below.
THOR_SILENCE_DEPRECATION=true

In the description that gives an error, there are extra spaces. By removing the white space, the above error will be resolved.

Deep digging for errors

Let's look at the content of the error again.

.env


ERROR: In file ./.env: environment variable name 'THOR_SILENCE_DEPRECATION ' may not contain whitespace.

If you try to correct this sentence to Japanese with Google Translate,

  • Error: File ./.env: Environment variable name'THOR_SILENCE_DEPRECATION' may not contain spaces. *

Will be converted to.

It's a little difficult to understand in Japanese, but somehow

"I'm getting an error because of the blank space."

You can add Atari.

When I googled the error text, no one came up with the exact same error text, but I referred to the following blog for the solution.

** Composer gives an error that spaces in .env need to be quoted ** https://awesome-linus.com/2019/04/07/composer-install-error-need-quotes/

When I googled the error statement, there was little information, so I can predict that it is not an error that occurs so often, but I hope that it will be helpful for beginners as a solution when encountering an error.

Details the background of the error

Let's take a closer look at the background of the error.

This error is caused by a mistake in the description of the ".env file", but some people may have never touched the .env file in the first place.

I have been studying Rails for about a month, and I have never had a chance to touch the .env file, but in the process of introducing the Gem "sorcery" that implements the login function, I got the following error. I had to touch the .env file to resolve it.

Deprecation warning: Expected string default value for '--test-framework'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.

This error is

-Added sorcery to Gemfile ・ Bundle install -Execute the command "rails g sorcery: install" to use sorcery

It occurred in the process.

I'm not sure about the details of the error, but it seems that the error is coming from the Gem for generating the shell script.

As a way to resolve this error, put it in your .env file

.env


#Correct description
THOR_SILENCE_DEPRECATION=true

Need to add a description of Wrongly wrote the following code.

.env


#A description that causes an error because there are unnecessary spaces
THOR_SILENCE_DEPRECATION = true

And rails g controller ~~ When I tried to execute, I got a title error.

By the way, regarding the error of "Deprecation warning ~ ~ ~", the following article

** [Ruby on Rails] How to set environment variables (.bash_profile, Dotenv-rails) ** https://qiita.com/yuichir43705457/items/7cfcae6546876086b849

** Introduce RSpec ** https://qiita.com/d0ne1s/items/1ecd114b33e80058215f

I was able to solve it with reference to. Thank you very much.

The end

The above is the solution to this error and the surrounding information. It was an error with not much information, so if you are in trouble, I would appreciate it if you could refer to it. Also, if there are any points that are difficult to understand, please point them out.

Well then, thank you for staying with us until the end.

Recommended Posts

ERROR: In file ./.env: environment variable name'THOR_SILENCE_DEPRECATION' may not contain whitespace.
"Where-blocks may only contain parameterizations" error in Spock
[Error] The app is not displayed in the production environment
Symbol not found error when new class in another Java file
Error in ./gradlew: Symbol not found