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

Basic Bundler operations don't seem to work on Windows #209

Closed
chrisseaton opened this issue Jul 28, 2021 · 11 comments
Closed

Basic Bundler operations don't seem to work on Windows #209

chrisseaton opened this issue Jul 28, 2021 · 11 comments

Comments

@chrisseaton
Copy link

chrisseaton commented Jul 28, 2021

I have a basic gem. Its CI looks like this.

https://github.com/Shopify/seafoam/blob/master/.github/workflows/workflows.yml

I enabled Windows, and there even a basic bundle exec rspec doesn't work on Windows.

Shopify/seafoam@9ef19e5

https://github.com/Shopify/seafoam/runs/3186334852

I found this in a more complex gem, but I'm reproducing here to make the problem more clear in simpler code. That gem does bundle exec rake, so it's not a Rake / RSpec thing.

@MSP-Greg
Copy link
Collaborator

@chrisseaton

Not sure what the issue is. YARD uses rspec (the only repo I immediately thought of), and it's using Bundler 2 and a rake task.

I looked at the branch you added Windows CI to. You might add quotes around the 3.0 version in the workflow file, as it's interpreted as '3' by the parser. So, when Ruby 3.1 is released, it will jump to that... Also, personal preference, but '-latest` for OS designation may change, which you may not want...

@eregon
Copy link
Member

eregon commented Jul 29, 2021

https://github.com/Shopify/seafoam/runs/3186334964#step:3:22

Setting BUNDLER_VERSION=1.17.2 for "bundle config|lock" commands below to ensure Bundler 1 is used

Can you try by removing the BUNDLE WITH section in https://github.com/Shopify/seafoam/blob/722a029eb268c3e00d8a946c5f554ad0b28e265f/Gemfile.lock#L58-L59, or updating to 2.x with bundle update --bundler?

If that's not it, I suspect a potential regression in Bundler.

But should definitely make sure Bundler 2 is used first, Bundler 1 is no longer being developed and might not work with recent Rubies AFAIK.

@eregon
Copy link
Member

eregon commented Jul 29, 2021

Note that bundle exec rake --version does work in this repo's CI:
https://github.com/ruby/setup-ruby/runs/3171185439#step:17:10

I think the problem is there is no Rakefile in https://github.com/Shopify/seafoam/tree/windows-ci
Also rake has some nasty exception/backtrace swallowing, some of it got recently fixed: ruby/rake#367

@chrisseaton
Copy link
Author

Note that bundle exec rake --version does work

Yes in my other repo it actually finds rake, starts to run it, then during the load of Gems it then complains rake isn't installed! I get backtraces like this

C:/hostedtoolcache/windows/Ruby/2.7.1/x64/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:374:in `block in replace_bin_path': can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
	from C:/hostedtoolcache/windows/Ruby/2.7.1/x64/lib/ruby/gems/2.7.0/gems/bundler-2.1.4/lib/bundler/rubygems_integration.rb:402:in `block in replace_bin_path'
	from D:/a/shopify-cli/shopify-cli/vendor/bundle/ruby/2.7.0/bin/rake:23:in `<main>'

I think the problem is there is no Rakefile

Does Bundler need a Rakefile to run? It doesn't in macOS or Ubuntu.

@chrisseaton
Copy link
Author

I think the problem is there is no Rakefile

I don't think it's using Rake or not. I added a Rakefile, and same issue.

Shopify/seafoam@5667055

https://github.com/Shopify/seafoam/runs/3191396713#step:4:11

C:/hostedtoolcache/windows/Ruby/2.7.4/x64/lib/ruby/gems/2.7.0/gems/bundler-1.17.2/lib/bundler/rubygems_integration.rb:462:in `block in replace_bin_path': can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
	from C:/hostedtoolcache/windows/Ruby/2.7.4/x64/lib/ruby/gems/2.7.0/gems/bundler-1.17.2/lib/bundler/rubygems_integration.rb:482:in `block in replace_bin_path'
	from D:/a/seafoam/seafoam/vendor/bundle/ruby/2.7.0/bin/rake:23:in `<main>'

@chrisseaton
Copy link
Author

It is fixed by upgrading to most recent Bundler though, so I'll investigate in that direction.

@chrisseaton
Copy link
Author

It does work with 2.2.17, but doesn't work with 2.1.4. I'm not going to bisect that further, but that's the fix - you need to use a more recent Bundler on Windows than you do on other platforms, and it needs to be at least I guess 2.2 or so.

I don't know if that needs to be documented, or tested for, or something like that.

@eregon
Copy link
Member

eregon commented Jul 29, 2021

I added bundle exec rake in this repo CI, and it passes for everything except JRuby on Windows, which is a known bug: e08bf35 #18 (comment)

Does Bundler need a Rakefile to run? It doesn't in macOS or Ubuntu.

rake certainly does. The error might just be confusing or the wrong one, but that's just a guess.

@eregon
Copy link
Member

eregon commented Jul 29, 2021

Documented in 77d7ca9.

@eregon eregon closed this as completed Jul 29, 2021
@chrisseaton
Copy link
Author

rake certainly does

I don't run rake though.

@eregon
Copy link
Member

eregon commented Jul 29, 2021

^ indeed, my bad, I was confusing with some other log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants