Skip to content

Allow "ruby file:" syntax in gemfile #247

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

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

Conversation

swelther
Copy link

Given in the gemfile the following ruby syntax is used:

ruby file: "../.ruby-version"

Appraisal would fail with wrong number of arguments (given 0, expected 1) (ArgumentError)

…/appraisal-2.5.0/lib/appraisal/bundler_dsl.rb:66:in `ruby': wrong number of arguments (given 0, expected 1) (ArgumentError)
	from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:27:in `run'
	from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:19:in `instance_eval'
	from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:19:in `run'
	from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:25:in `block in dup'
…

This PR fixes this issue by allowing keyword arguments.

There is just one "visual" downsize that the syntax in the appraisal gemfiles is converted to Ruby 1.8 syntax:

-ruby file: ".ruby-version"
+ruby {:file=>".ruby-version"}

Not sure if this is a big issue. Could be probably ignored because it still works and is just some minor visual thing.

@swelther swelther force-pushed the fix/allow-ruby-file-syntax-in-gemfile branch from b967a15 to dbcd772 Compare November 14, 2024 11:03
@swelther
Copy link
Author

Hm seems I opened the PR too fast, in a real example the ruby line is omitted. Need to check why or if only my integration is somehow wrong :)

@swelther
Copy link
Author

I didn't find the already existing spec for this feature, adapted the code to work now. Just wondering why the test does not fail.

@McRip
Copy link

McRip commented Mar 4, 2025

Hello,
we are also looking forward to see this fix merged. Is there anything that blocks this from beeing released?

This allows the use of the `ruby file:` syntax in
Gemfiles, e.g.:

```ruby
ruby file: "../.ruby-version"

…
```

Previously, Appraisal would fail with `wrong number of arguments (given
0, expected 1) (ArgumentError)`

```
…/appraisal-2.5.0/lib/appraisal/bundler_dsl.rb:66:in `ruby': wrong number of arguments (given 0, expected 1) (ArgumentError)
	from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:27:in `run'
	from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:19:in `instance_eval'
	from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:19:in `run'
	from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:25:in `block in dup'
…
```
@nickcharlton nickcharlton force-pushed the fix/allow-ruby-file-syntax-in-gemfile branch from 1e2555e to d2f797a Compare March 25, 2025 11:54
@nickcharlton
Copy link
Member

I just rebased to get the tests to run, but the output is a bit unfortunate. To maintain support for older Ruby versions, it might have to stay. Unless anyone can think of another approach?

@swelther
Copy link
Author

swelther commented Apr 1, 2025

hm looks like the syntax is different depending on the Ruby version. Should I update the spec to make it pass with every version or is this a no-go?

@nickcharlton
Copy link
Member

Ah yeah, interesting. I think we might just need a different approach.

I still can't think of a nicer way to do it, but we could write out a string with the value?

@swelther
Copy link
Author

swelther commented Apr 1, 2025

Yeah sure, that could work :) I'll make some changes tomorrow 🤞

@swelther
Copy link
Author

swelther commented Apr 2, 2025

Just pushed a version that could work. Not sure about the solution, I basically reimplement the ruby_version_entry method. But if I just call it the test would not fail without my fix.

What do you think?

@swelther
Copy link
Author

swelther commented Apr 2, 2025

At least the test is now green :) Except for "jruby-head", wondering what is happening there 🤔

But spec/acceptance/bundle_without_spec.rb:6 is failing, but the reason does not seem to be my changes, when I comment them out it still fails locally. Any idea what do to about that one?

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.

3 participants