TypeError: no implicit conversion of nil into String Ruby / Rails Origin: Application & API OSI layer 7 · Application Last updated 5 Nov 2026

Ruby: TypeError: no implicit conversion of nil into String

A String method (+, File.join, Array#join usage) received nil instead of a string.

Exact message you may see TypeError: no implicit conversion of nil into StringTypeError (no implicit conversion of nil into String)no implicit conversion of Integer into Stringno implicit conversion of Symbol into StringTypeError: no implicit conversion from nil to integer
Seen on: Ruby

Meaning

Typically an env var or attribute is nil (ENV["X"] + "/path", "a" + user.name). Use string interpolation ("#{x}"), to_s, or ENV.fetch("X") to fail clearly. The backtrace line shows the operation.

Common causes

  • ENV["VAR"] unset
  • nil attribute concatenated with +
  • File.join with nil segment
  • Missing default in config
  • Optional value from params

⚡ Quick fix

  1. ENV.fetch("VAR") to fail early or ENV.fetch("VAR", "default")
  2. Use interpolation "#{name}" or name.to_s
  3. Guard against nil with ||

Detailed fix by platform

Ruby

  1. path = File.join(ENV.fetch("APP_ROOT"), "tmp")

How to diagnose

  1. Value — Nil where?
  2. ENV — Set?
  3. Operation — Concatenation?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

ArgumentError: missing keyword / unknown keyword — Ruby: ArgumentError: missing keyword: :name / unknown keyword: :nmae (Ruby / Rails)ArgumentError: missin…ArgumentError: wrong number of arguments (given 1, expected 2) — Ruby: ArgumentError: wrong number of arguments (given 1, expected 2..3) (Ruby / Rails)ArgumentError: wrong …Bundler could not find compatible versions for gem — Bundler: Bundler could not find compatible versions for gem "activesupport": In Gemfile: rails (= 7.1.0) depends on activesupport (= 7.1.0) (Ruby / Rails)Bundler could not fin…Bundler: Could not find gem in locally installed gems — Bundler: Could not find gem 'rails (~> 7.1)' in locally installed gems / Could not find rails-7.1.0 in any of the gem sources listed in your Gemfile (Ruby / Rails)Bundler: Could not fi…FrozenError: can't modify frozen String — Ruby: FrozenError: can't modify frozen String: "abc" (Ruby / Rails)FrozenError: can't mo…TypeError: nil can't be coerced into Integer — Ruby: TypeError: nil can't be coerced into Integer / String can't be coerced into Integer (Ruby / Rails)TypeError: nil can't …undefined method for nil — Ruby: NoMethodError: undefined method `x' for nil (nil:NilClass) (Ruby / Rails)undefined method for …TypeError…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.