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

Support shimmed ruby versions #1407

Merged
merged 13 commits into from Nov 23, 2023

Conversation

hrabe
Copy link
Contributor

@hrabe hrabe commented Nov 19, 2023

The plugin currently only works, if in shimmed environment (e.g. rbenv / asdf) the global ruby version it the same as within the project. If global ruby version is something like 2.7.0 it fails within vscode format on save.

This is due to starting the ruby interpreter (spawn) within drives root folder, which falls back to global ruby version instead of project used one.

The fix sets the working dir for spawned ruby process to the directory, where the file to be formatted is contained.
This will automatically use the correct shimmed ruby version of the project or falls back (if no shim has been used) to global ruby version.

This also may make the .editorconfig obsolete.

@bschlenk
Copy link

yess, thank you! I've been banging my head against the wall trying to upgrade a large codebase to prettier 3, and this was the last blocker. Just tried your fix locally and it works

@kddnewton
Copy link
Member

Hey @hrabe - I think this makes sense to me. Happy to merge, but let's make sure we get CI green first. You should be able to rebase off main to get the latest fixes, and then if this becomes green I can merge it.

Copy link
Member

@kddnewton kddnewton left a comment

Choose a reason for hiding this comment

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

Just marking this as "request changes"

@hrabe hrabe requested a review from kddnewton November 21, 2023 08:01
@hrabe
Copy link
Contributor Author

hrabe commented Nov 21, 2023

@kddnewton all tests locally running well now.

@kddnewton
Copy link
Member

@hrabe it looks like everything is failing on CI with this PR. Any chance it's unable to find the correct bundle now that the cwd is changing? Are you able to replicate locally?

@hrabe
Copy link
Contributor Author

hrabe commented Nov 23, 2023

@kddnewton Now using the cwd only if file is given. Now clue how to reproduce CI issue, cause yarn run test / npm run test works locally. Assume, that test doesn't give a file and default process.cwd is than in root without bundled gem.
Would love to see the tests on CI now.

@kddnewton kddnewton merged commit 294ac98 into prettier:main Nov 23, 2023
12 checks passed
@hrabe
Copy link
Contributor Author

hrabe commented Nov 23, 2023

@kddnewton do you think we could bump a new version?

@hrabe hrabe deleted the support-shimmed-ruby-versions branch November 24, 2023 08:06
@hrabe hrabe mentioned this pull request Nov 27, 2023
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.

None yet

4 participants