prettier / plugin-ruby

Prettier Ruby Plugin
MIT License
1.47k stars 98 forks source link

Remove bundler dependency #1453

Closed jlahtinen closed 3 months ago

jlahtinen commented 4 months ago

I had an issue where my default ruby version with rvm was 3.2.2 but my project was using 3.1.4.

By requiring bundler/setup from server.rb resulted to:

.rvm/gems/ruby-3.2.2/gems/bundler-2.5.10/lib/bundler/definition.rb:452:in `validate_ruby!': Your Ruby version is 3.2.2, but your Gemfile specified 3.1.4 (Bundler::RubyVersionMismatch)

I couldn't understand what problems bundler was resolving so I think it can be just removed.

jlahtinen commented 4 months ago

Just FYI: Any error ruby server.rb command causes is not currently logged anywhere.

I debugged this by removing stdio setting from spawn options and I added async stderr/stdout on data listeners. Very similar to this https://nodejs.org/api/child_process.html#child-process

kddnewton commented 3 months ago

Requiring bundler has solved a lot of problems with this plugin in the past. Without it, incorrect versions of the various gems can get activated a wreck havoc on the Ruby environment.

For example, this is an actual bug in your Ruby environment. Requiring bundler is showing that you have a different Ruby activated for than the one used by your Gemfile, which can cause incorrect versions of gems to be required.

jlahtinen commented 3 months ago

What should be the correct Gemfile (or default? - i think this project does not provide that file, doesn't it?) for bundler/setup to use? If project doesn't have any I think bundler falls back to the default "wreck havoc".

I do not want that prettier plugin uses my project's Gemfile, I want to have better control over it or use the default "wreck havoc" :)

kddnewton commented 2 months ago

Probably

source "https://rubygems.org"
gem "prettier"

would work. Make sure you're using BUNDLE_GEMFILE=path/to/gemfile when you're running the command so that it picks the right gemfile.