Bug 2172250

Summary: ruby: Missing rdoc symbolic links in the ruby_libdir.
Product: [Fedora] Fedora Reporter: Jun Aruga <jaruga>
Component: rubyAssignee: Vít Ondruch <vondruch>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: jprokop, mo, mtasaka, pvalena, ruby-packagers-sig, strzibny, vondruch
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-21 10:18:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jun Aruga 2023-02-21 17:50:13 UTC
Description of problem:

I noticed the following error even when rubygem-rdoc was installed.

```
LoadError: cannot load such file -- rdoc/task
```

Maybe the ruby.spec needs the logic to create symbolic link files in the ruby_libdir like the rubygem-json does.

```
ln -s %{gem_dir}/gems/json-%{json_version}/lib/json.rb %{buildroot}%{ruby_libdir}/json.rb
ln -s %{gem_dir}/gems/json-%{json_version}/lib/json %{buildroot}%{ruby_libdir}/json
ln -s %{_libdir}/gems/%{name}/json-%{json_version}/json/ %{buildroot}%{ruby_libarchdir}/json
```

I found this issue on Fedora 37, then I was able to reproduce it on Fedora rawhide too.

Version-Release number of selected component (if applicable):
ruby-3.2.1-179.fc39.x86_64

How reproducible:

Steps to Reproduce:

```
# dnf install ruby ruby-devel rubygem-rdoc

# rpm -q ruby ruby-devel rubygem-rdoc
ruby-3.2.1-179.fc39.x86_64
ruby-devel-3.2.1-179.fc39.x86_64
rubygem-rdoc-6.5.0-179.fc39.noarch

# ls /usr/share/ruby
English.rb          expect.rb       open3.rb           ruby_vm
abbrev.rb           fiddle          openssl            securerandom.rb
base64.rb           fiddle.rb       openssl.rb         set
benchmark           fileutils.rb    optionparser.rb    set.rb
benchmark.rb        find.rb         optparse           shellwords.rb
bigdecimal          forwardable     optparse.rb        singleton.rb
bigdecimal.rb       forwardable.rb  ostruct.rb         socket.rb
cgi                 getoptlong.rb   pathname.rb        syntax_suggest
cgi.rb              io              pp.rb              syntax_suggest.rb
coverage.rb         ipaddr.rb       prettyprint.rb     syslog
csv                 json            pstore.rb          tempfile.rb
csv.rb              json.rb         psych              time.rb
date.rb             kconv.rb        psych.rb           timeout.rb
delegate.rb         logger          racc               tmpdir.rb
did_you_mean        logger.rb       racc.rb            tsort.rb
did_you_mean.rb     mkmf.rb         random             un.rb
digest              monitor.rb      readline.rb        unicode_normalize
digest.rb           mutex_m.rb      reline             uri
drb                 net             reline.rb          uri.rb
drb.rb              objspace        resolv-replace.rb  vendor_ruby
erb                 objspace.rb     resolv.rb          weakref.rb
erb.rb              observer.rb     rinda              yaml
error_highlight     open-uri.rb     ripper             yaml.rb
error_highlight.rb  open3           ripper.rb

# ls /usr/share/ruby/rdoc
ls: cannot access '/usr/share/ruby/rdoc': No such file or directory
  => Problem!
```

Then in my case, I ran the commands below with a regular user. The ruby/openssl latest master commit is <b5ef6d151a2639ccb91be83285eed1c7b9d2c965>.

```
$ git clone https://github.com/ruby/openssl.git

$ cd openssl

$ bundle install --standalone

$ bundle exec rake compile -- --enable-debug

Actual results:
$ bundle exec rake compile -- --enable-debug
rake aborted!
LoadError: cannot load such file -- rdoc/task
<internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/usr/share/rubygems/rubygems/core_ext/kernel_require.rb>:37:in `require'
/mnt/git/ruby/openssl/Rakefile:2:in `<top (required)>'
/mnt/git/ruby/openssl/bundle/ruby/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/cli/exec.rb:58:in `load'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/cli/exec.rb:23:in `run'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/cli.rb:491:in `exec'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/cli.rb:34:in `dispatch'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/cli.rb:28:in `start'
/usr/share/gems/gems/bundler-2.4.6/libexec/bundle:45:in `block in <top (required)>'
/usr/share/gems/gems/bundler-2.4.6/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/usr/share/gems/gems/bundler-2.4.6/libexec/bundle:33:in `<top (required)>'
/usr/bin/bundle:25:in `load'
/usr/bin/bundle:25:in `<main>'
(See full trace by running task with --trace)
```

Expected results:
It compiles without error.


Additional info:

Comment 1 Jun Aruga 2023-02-21 17:59:03 UTC
The temporary workaround is below.

```
# cd /usr/share/ruby
# ln -s /usr/share/gems/gems/rdoc-6.4.0/lib/rdoc.rb .
# ln -s /usr/share/gems/gems/rdoc-6.4.0/lib/rdoc .
```

Comment 2 Jun Aruga 2023-03-15 11:48:49 UTC
Any update about how to fix this issue?

Comment 3 Vít Ondruch 2023-03-21 10:18:54 UTC
(In reply to Jun Aruga from comment #1)
> The temporary workaround is below.
> 
> ```
> # cd /usr/share/ruby
> # ln -s /usr/share/gems/gems/rdoc-6.4.0/lib/rdoc.rb .
> # ln -s /usr/share/gems/gems/rdoc-6.4.0/lib/rdoc .
> ```

Let me address this first, because there are better workarounds IMHO:

1) I don't think you need to use Bundler for that specific case. I believe that running `rake compile` without Bundler should be good enough.
2) If I am wrong and the Bundler is needed, then adding `gem "rdoc"` into the Gemfile is the best option.

The right solution IMHO would really be to ask upstream to include RDoc in their Gemfile. But their answer will likely be "its part of the StdLib, therefore it is not needed". For some reason, there is some great resistance in the community to fully specify their dependencies.

Now the current state is partly due to history, where RDoc was shipped independently of Ruby. However, even currently, RDoc is still shipped independently of Ruby. And in the future, I suspect (hope) that RDoc might be moved from default to bundled gem. Based on this, we have never had the symlinks and I'll be glad if that stays like this. I don't see this would cause a lot of issues.

And frankly, the symlinks are painful. If there really was a need, maybe we should rather put some Ruby stubs which would load the real library, if it works.

Closing for the moment as WONTFIX. Feel free to re-open for further discussion.

Comment 4 Vít Ondruch 2023-03-21 10:25:18 UTC
Eh, just noticed that the RDoc used to be specified as development dependency and it was introduced together with the RDoc Rake task:

https://github.com/ruby/openssl/commit/4c7dcdff8e73a683df3a40555d1e5eb3441c69f1

Later it was moved into Gemfile (and I don't this this would be considered as state of the art these days):

https://github.com/ruby/openssl/commit/47283d91614ab799dc2347c37885a37f1b91afcb

And just recently removed here:

https://github.com/ruby/openssl/commit/b957145a8c3da1c1e101477a25c59f3de5f48afa
https://github.com/ruby/openssl/pull/578

Where the PR complains about GH actions. Not going to dig deeper.

Unsurprisingly, there is this [1] comment: "rdoc is always provided because it's the default gems. There is no reason why it required on Gemfile."


[1] https://github.com/ruby/openssl/pull/578#issuecomment-1348335342

Comment 5 Jun Aruga 2023-04-21 16:41:51 UTC
Thanks for your investigation!

And here I opened the PR to fix the error now.

Add rdoc as a development dependency.
https://github.com/ruby/openssl/pull/616