Skip to content

Allow installing RDoc from a git source#1113

Closed
st0012 wants to merge 2 commits intoruby:masterfrom
Shopify:fix-#1107
Closed

Allow installing RDoc from a git source#1113
st0012 wants to merge 2 commits intoruby:masterfrom
Shopify:fix-#1107

Conversation

@st0012
Copy link
Copy Markdown
Member

@st0012 st0012 commented May 29, 2024

This implements option 2 in #1107, which is to use extconf.rb to conditionally run rake generate when the gem is installed as a git source.

To make sure the target machine has the required dependencies for the generation, I modified rake generate to conditionally install the kpeg and racc.

task :generate do
unless ENV.key?('BUNDLE_GEMFILE')
Gem.install 'racc', '> 1.4.10'
Gem.install 'kpeg', '>= 1.3.3'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colby-swandale do you know if there's any rubygems API to better handle these dependencies without bundler?

Copy link
Copy Markdown
Member

@colby-swandale colby-swandale May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand the context where Bundler wouldn't be available?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bundler will be available, but this will be executed in 2 scenarios:

  • When a developer runs rake generate (or any tasks that depend on it) manually
  • When a user installs RDoc through git source

In the later case, I want to avoid installing all of RDoc's development dependencies as most of them aren't needed for generating the missing files.

@st0012 st0012 marked this pull request as ready for review June 1, 2024 11:21
@st0012
Copy link
Copy Markdown
Member Author

st0012 commented Jun 1, 2024

@nobu Thanks for the suggestions 👍

@st0012 st0012 requested a review from nobu June 18, 2024 17:58
@st0012
Copy link
Copy Markdown
Member Author

st0012 commented Jun 25, 2024

@nobu Would you mind giving this another look? If you're not against it, I'd like to give it a try.

st0012 and others added 2 commits March 22, 2025 03:39
Co-authored-by: Vinicius Stock <vinistock@users.noreply.github.com>
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
@ioquatix
Copy link
Copy Markdown
Member

This does not work, at least when I tested it.

The problem is, extconf.rb is executed from the root directory, so the relative path (computed from Dir.pwd is wrong):

The fix is:

git_path = File.expand_path("../../.git", __dir__)
if File.exist?(git_path)
	system("rake generate")
end

At least that gets us to the next issue:

> ruby ./ext/rdoc/extconf.rb
Generating lib/rdoc/markdown.rb...
rake aborted!
Gem::GemNotFoundException: can't find gem kpeg (>= 0) with executable kpeg (Gem::GemNotFoundException)
/home/samuel/.gem/ruby/3.4.1/bundler/gems/rdoc-c75f094920b3/Rakefile:80:in 'block (2 levels) in <top (required)>'
Tasks: TOP => generate => lib/rdoc/markdown.rb
(See full trace by running task with --trace)
creating Makefile

@ioquatix
Copy link
Copy Markdown
Member

ioquatix commented Mar 21, 2025

Would it be crazy to do this:

# rdoc.gemspec

  if ENV["RDOC_FROM_SOURCE"] # or something better???
    gem "kpeg"
    ...

@tompng
Copy link
Copy Markdown
Member

tompng commented Feb 7, 2026

#1107 is solved with #1410 (option 1 mentioned in the original issue)

@tompng tompng closed this Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants