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

Fix __FILE__ and __dir__ in primary Gemfiles #193

Merged
merged 2 commits into from
Feb 3, 2022

Conversation

indirect
Copy link
Contributor

@indirect indirect commented Feb 2, 2022

Appraisal is good! I found a bug: I have the habit of using ruby Pathname.new(__dir__).join(".ruby-version").read in my Gemfile, so that I can write my ruby version in just one place, in the .ruby-version file.

Unfortunately, the Gemfile classes calls instance_eval without telling Ruby what file the string came from, and so Ruby thinks that FILE should point to appraisal/lib/appraisal/gemfile.rb instead of the Gemfile itself, and that breaks anything inside the Gemfile that references either __FILE__ or __dir__.

This PR adds a test and passes in the path to the Gemfile, if it is known, to fix that.

Copy link
Member

@nickcharlton nickcharlton left a comment

Choose a reason for hiding this comment

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

Oh nice. Thank you @indirect!

@nickcharlton nickcharlton merged commit 97079f0 into thoughtbot:main Feb 3, 2022
@indirect indirect deleted the fix-__FILE__ branch February 3, 2022 18:49
@nickcharlton nickcharlton mentioned this pull request Feb 1, 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.

2 participants