Open glebm opened 5 years ago
Hacky workaround:
# Put this in Gemfile:
require 'appraisal/bundler_dsl'
::Appraisal::BundlerDSL.class_eval do
def eval_gemfile(path, contents = nil)
(@eval_gemfile ||= []) << [path, contents]
end
private
def eval_gemfile_entry
@eval_gemfile.map { |(p, c)| "eval_gemfile(#{p.inspect}#{", #{c.inspect}" if c})" } * "\n\n"
end
alias_method :eval_gemfile_entry_for_dup, :eval_gemfile_entry
self::PARTS << 'eval_gemfile'
end unless ::Appraisal::BundlerDSL::PARTS[-1] == 'eval_gemfile'
Proper support for eval_gemfile
should also convert absolute paths back to File.expand_path(..., __dir__)
calls in the output.
Decided against using Appraisal in this case though, as there doesn't seem to be any option for configuring the gemfiles
directory path.
Decided against using Appraisal in this case though, as there doesn't seem to be any option for configuring the gemfiles directory path.
Would you be able to open an issue for this bit specifically?
Just FYI, this is still valid. I stumbled upon it with neovim and Shopify/ruby-lsp in a project that uses appraisal (I don't have control over that and cannot remove appraisal). ruby-lsp injects itself with a .ruby-lsp/Gemfile
that looks like this:
# This custom gemfile is automatically generated by the Ruby LSP.
# It should be automatically git ignored, but in any case: do not commit it to your repository.
eval_gemfile(File.expand_path("../Gemfile", __dir__))
gem "ruby-lsp", require: false, group: :development
gem "ruby-lsp-rails", require: false, group: :development
In particular, thus there's eval_gemfile
, see in https://github.com/Shopify/ruby-lsp/blob/5d59a71ffba325f56424afdac6462a4e7387e849/lib/ruby_lsp/setup_bundler.rb#L134 .
The Ruby language server consequently crashes ("Client ruby_ls quit with exit code 127 and signal 0). ~/.local/state/nvim/lsp.log
contains
Ruby LSP Rails failed to initialize server: /path/to/rails/project/ ruby-lsp/Gemfile:4:in
run': undefined method
eval_gemfile' for #<Appraisal::Gemfile:0x000000011ea6df28 @sources=[], ...
eval_gemfile
is not supported by appraisal.Error:
eval_gemfile
is useful for sharing dependencies between multiple Gemfiles.E.g. I have a
rubocop.gemfile
that's included into the mainGemfile
but also into a separate rubocop-only Gemfile for running as a separate task on CI.