Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Process.spawn doesn't remove nil env variables #3428

@smellsblue

Description

@smellsblue

Process.spawn is supposed to unset environment variables that are explicitly specified as nil. Instead, the environment variable is being set as "". This happens even if the environment variable didn't exist before calling Process.spawn.

Below is a sample script demonstrating the problem:

#!/usr/bin/env ruby
if ARGV.first != "spawned"
  Process.wait Process.spawn({ "SHOULD_BE_NIL" => nil }, __FILE__, "spawned")
  exit
end

if ENV["SHOULD_BE_NIL"].nil?
  puts "success!"
else
  puts "failure: #{ENV["SHOULD_BE_NIL"].inspect}"
end

When run on Ruby 2.2.3 and JRuby 1.7.22, it works as expected... I get success!, but on JRuby 9.0.3.0, I get failure: "".

I'd be happy to work on a fix for this if it hasn't already been solved (I found some similar looking issues open, but couldn't find one that quite matched it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions