From: zn@mbf.nifty.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:100343] [Ruby master Bug#17254] ENV.replace may set nil instead of the proper value
Date: Thu, 08 Oct 2020 10:20:53 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-17254.20201008102052.14@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17254.20201008102052.14@ruby-lang.org
Issue #17254 has been reported by znz (Kazuhiro NISHIYAMA).
----------------------------------------
Bug #17254: ENV.replace may set nil instead of the proper value
https://bugs.ruby-lang.org/issues/17254
* Author: znz (Kazuhiro NISHIYAMA)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
On docs.ruby-lang.org, it uses [snap ruby](https://snapcraft.io/ruby), and it failed to run `rdoc`.
```
Oct 07 13:20:08 docs-2020.ruby-lang.org env[6183]: rdoc --title Documentation for Ruby master --main README.md --output /var/www/docs.ruby-lang.org/releases/20200916140300/master -U --all --encoding=UTF-8 .
Oct 07 13:20:08 docs-2020.ruby-lang.org env[6183]: <internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
Oct 07 13:20:08 docs-2020.ruby-lang.org env[6183]: from <internal:gem_prelude>:1:in `<internal:gem_prelude>'
Oct 07 13:20:08 docs-2020.ruby-lang.org env[6183]: rake aborted!
```
I investigate it, it caused by setting nil instead of the proper value in `ENV.replace`.
```
vagrant@buster:/tmp/t$ cat Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
vagrant@buster:/tmp/t$ env PATH=/var/www/docs.ruby-lang.org/shared/bundle/ruby/2.7.0/bin:/snap/bin:$PATH DEBIAN_DISABLE_RUBYGEMS_INTEGRATION=1 bundle exec env -u RUBYOPT ruby -r/snap/ruby/189/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/setup -e 'p ENV["RUBYLIB"]'
"/snap/ruby/189/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib"
```
Calling `ENV.clear` before `ENV.replace` resolves this issue.
```
vagrant@buster:/tmp/t$ cat /tmp/clear-before-replace.rb
class << ENV
alias orig_replace replace
def replace(h)
clear
orig_replace(h)
end
end
vagrant@buster:/tmp/t$ env PATH=/var/www/docs.ruby-lang.org/shared/bundle/ruby/2.7.0/bin:/snap/bin:$PATH DEBIAN_DISABLE_RUBYGEMS_INTEGRATION=1 bundle exec env -u RUBYOPT ruby -r/tmp/clear-before-replace -r/snap/ruby/189/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/setup -e 'p ENV["RUBYLIB"]'
"/snap/ruby/189/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib:/snap/ruby/189/lib/ruby/2.7.0:/snap/ruby/189/lib/ruby/2.7.0/amd64"
```
Where should call `ENV.clear`?
In `ENV.replace` or caller of `ENV.replace`?
---Files--------------------------------
full-env-log.txt (8.96 KB)
rdoc-failed-log.txt (2.57 KB)
--
https://bugs.ruby-lang.org/
next parent reply other threads:[~2020-10-08 10:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 10:20 zn [this message]
2020-10-16 2:45 ` [ruby-core:100413] [Ruby master Bug#17254] ENV.replace may set nil instead of the proper value merch-redmine
2020-10-22 6:44 ` [ruby-core:100496] " zn
2020-10-22 15:05 ` [ruby-core:100506] " merch-redmine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-17254.20201008102052.14@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).