Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installing RDoc from a git source #1113

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

st0012
Copy link
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
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
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
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
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
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
@ioquatix
Copy link
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
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"
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants